Skip to content
Snippets Groups Projects
Commit f7bff299 authored by Graham Linden's avatar Graham Linden
Browse files

SL-11330

Put back atten for non-ALM lighting that accounts for inverted lin atten setup of yore.
parent 9118cafb
No related branches found
No related tags found
No related merge requests found
......@@ -38,27 +38,20 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
vec3 lv = lp.xyz-v;
//get distance
float dist = length(lv);
if (dist > la)
{
return 0;
}
float d = length(lv);
//normalize light vector
lv = normalize(lv);
fa += 1.0;
float dist_atten = min(1.0 - (dist-1.0*(1.0 - fa))/fa, 1.0);
float da = max(dot(n, lv), 0.0);
lv *= 1.0/d;
//distance attenuation
float da = clamp(1.0/(la * d), 0.0, 1.0);
// spotlight coefficient.
float spot = max(dot(-ln, lv), is_pointlight);
da *= spot*spot; // GL_SPOT_EXPONENT=2
//angular attenuation
da *= dist_atten;
da *= calcDirectionalLight(n, lv);
return da;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment