diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-06-04 17:12:50 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-06-04 17:12:50 +0000 |
commit | f30bb8be1f801d66590699e317fae455e35af3eb (patch) | |
tree | 70fb459c8ff2933fa5adbf05a2cf372c55c5b947 /data/shaders | |
parent | 347c83d7467af1f21e7a85088936aa7a6da13cc3 (diff) |
More matching non-shader graphics to shader graphics
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@70 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'data/shaders')
-rw-r--r-- | data/shaders/lighting.frag | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/data/shaders/lighting.frag b/data/shaders/lighting.frag index e7a5b3b..4616feb 100644 --- a/data/shaders/lighting.frag +++ b/data/shaders/lighting.frag @@ -39,23 +39,27 @@ void main() { /* Emission */ emit = col_emit; - - /* Spotlight (light 0) - positional, spotlight */ - 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); - spec += vec3(1.0, 1.0, 1.0) * gl_LightSource[0].specular.rgb * pow(ndothv, 80.0); - - /* Background glow (light 1) - diffuse only, directional */ - diff += col_ambi_diff * gl_LightSource[1].diffuse.rgb * max(dot(vec3(light1vc), norm), 0.0); - + /* Fill-in light (light 2) */ if ( fill_light_enabled ) { + diff += col_ambi_diff * gl_LightSource[2].diffuse.rgb * max(dot(vec3(light1vc), norm), 0.0); - spec += vec3(1.0, 1.0, 1.0) * gl_LightSource[2].specular.rgb * pow(ndothv, 80.0); + spec += gl_LightSource[2].specular.rgb * pow(ndothv, 80.0); + + } else { + + /* Spotlight (light 0) - positional, spotlight */ + 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); + spec += vec3(1.0, 1.0, 1.0) * gl_LightSource[0].specular.rgb * pow(ndothv, 80.0); + + /* Background glow (light 1) - diffuse only, directional */ + diff += col_ambi_diff * gl_LightSource[1].diffuse.rgb * max(dot(vec3(light1vc), norm), 0.0); + } if ( texture_enabled ) { |