summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2011-05-25 18:18:34 -0500
committerDave Parks <davep@lindenlab.com>2011-05-25 18:18:34 -0500
commit9ef81de6e15fe41a056112810237d2fdb908775b (patch)
treee92d2a8ef96a49b7523145b49674360534e9a0f1 /indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
parent354f0e84eb178be79aa08420725ea745376f0e83 (diff)
SH-1527 Fix for black alpha objects with lighting and shadows enabled and no lights around.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl25
1 files changed, 15 insertions, 10 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index a2a7dea20d..a012cb5030 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
//get distance
float d = length(lv);
- //normalize light vector
- lv *= 1.0/d;
+ float da = 0.0;
+
+ if (d > 0.0 && la > 0.0 && fa > 0.0)
+ {
+ //normalize light vector
+ lv *= 1.0/d;
- //distance attenuation
- float dist2 = d*d/(la*la);
- float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ //distance attenuation
+ float dist2 = d*d/(la*la);
+ da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
- // spotlight coefficient.
- float spot = max(dot(-ln, lv), is_pointlight);
- da *= spot*spot; // GL_SPOT_EXPONENT=2
+ // spotlight coefficient.
+ float spot = max(dot(-ln, lv), is_pointlight);
+ da *= spot*spot; // GL_SPOT_EXPONENT=2
- //angular attenuation
- da *= calcDirectionalLight(n, lv);
+ //angular attenuation
+ da *= calcDirectionalLight(n, lv);
+ }
return da;
}