diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index 2762a35403..45701002b8 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -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; } |