aboutsummaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-06-02 23:45:50 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-06-02 23:45:50 +0000
commit0af3ca0db832ce3dca5b606d1b9564d3a9878431 (patch)
tree124047de509e3474abcd2a9a44698426c35946eb /data
parent70b33bdff4d5bceb3d9faa36a7370690323ddd02 (diff)
Make shader lighting attenuation agree with fixed function version
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@63 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'data')
-rw-r--r--data/shaders/lighting.frag4
1 files changed, 3 insertions, 1 deletions
diff --git a/data/shaders/lighting.frag b/data/shaders/lighting.frag
index 4947e98..e7a5b3b 100644
--- a/data/shaders/lighting.frag
+++ b/data/shaders/lighting.frag
@@ -41,7 +41,9 @@ void main() {
emit = col_emit;
/* Spotlight (light 0) - positional, spotlight */
- float falloff = 1 - length(light0vc) * gl_LightSource[0].linearAttenuation;
+ float falloff = 1/ ( gl_LightSource[0].constantAttenuation
+ + gl_LightSource[0].linearAttenuation * length(light0vc)
+ + gl_LightSource[0].quadraticAttenuation * pow(length(light0vc), 2.0) );
float spot = max(dot(normalize(-light0vc), gl_LightSource[0].spotDirection), 0.0);
spot = pow(spot, gl_LightSource[0].spotExponent);
diff += col_ambi_diff * gl_LightSource[0].diffuse.rgb * spot * falloff * max(dot(normalize(light0vc).xyz, norm), 0.0);