Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cheap attenuation
float dist = length(lightVector);
float lightR = (lightPosRadius.w / uViewSize.y);
if(dist < lightR){
float attenuation = dist/(1.0 - (dist/lightR) * (dist/lightR));
attenuation = attenuation / lightR + 1.0;
attenuation = 1.0 / (attenuation * attenuation);
if (attenuation > 0.0) {
// normalize vectors
float normalPower = max(0.0, dot(normal, -normalize(lightVector.xyz)));
lightColor += diffuse * 2.0 * lc * normalPower * attenuation;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.