summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2012-01-24 12:59:18 -0600
committerDave Parks <davep@lindenlab.com>2012-01-24 12:59:18 -0600
commite02f007d2013e089c07f3abefe2d87d85cbcc834 (patch)
treee5d1342952d33265ce12ebeea4fb4bed8a0c1377 /indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
parent18e7f1bffd875bb933212367f0d62dfc4da871b9 (diff)
SH-1427 Fix for spot lights not working properly on alpha objects, and fix for alpha lighting of point lights not matching deferred lights.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl9
1 files changed, 4 insertions, 5 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 93b1a114db..8c96d55342 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -70,17 +70,17 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
vec3 lv = lp.xyz-v;
//get distance
- float d = length(lv);
+ float d = dot(lv,lv);
float da = 0.0;
if (d > 0.0 && la > 0.0 && fa > 0.0)
{
//normalize light vector
- lv *= 1.0/d;
+ lv = normalize(lv);
//distance attenuation
- float dist2 = d*d/(la*la);
+ float dist2 = d/la;
da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
// spotlight coefficient.
@@ -88,7 +88,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
da *= spot*spot; // GL_SPOT_EXPONENT=2
//angular attenuation
- da *= calcDirectionalLight(n, lv);
+ da *= max(dot(n, lv), 0.0);
}
return da;
@@ -123,7 +123,6 @@ void main()
col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
vary_pointlight_col = col.rgb*diffuse_color.rgb;
-
col.rgb = vec3(0,0,0);
// Add windlight lights