diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-08-06 11:57:48 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-08-06 11:57:48 +0000 |
commit | 1b1daf15148bf836be116260e7ed7c79bbfa055b (patch) | |
tree | fd3e9cfefc7a038823a6d664090bf9f83b1fd9e5 /data | |
parent | d9acb7a1cf5684f58145f652e787ac5e1a73e1a1 (diff) |
Fussiness
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@209 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'data')
-rw-r--r-- | data/shaders/lighting.frag | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/data/shaders/lighting.frag b/data/shaders/lighting.frag index 5545b03..d3e3534 100644 --- a/data/shaders/lighting.frag +++ b/data/shaders/lighting.frag @@ -50,9 +50,9 @@ void main() { /* Emission */ emit = col_emit; - /* Fill-in light (light 2) */ if ( fill_light_enabled ) { + /* Light 2: Fill-in light for lander */ float diff_fac, spec_fac; diff_fac = max(dot(norm, normalize(light2vc)), 0.0); @@ -60,28 +60,29 @@ void main() { } else { - /* Spotlight (light 0) - positional, spotlight */ + /* Light 0: Lander craft's spotlight */ float falloff, spot; float diff_fac, spec_fac; + vec3 E, R; falloff = 1/ ( gl_LightSource[0].constantAttenuation + gl_LightSource[0].linearAttenuation * light0dist - + gl_LightSource[0].quadraticAttenuation * pow(light0dist, 2.0) ); + + gl_LightSource[0].quadraticAttenuation * light0dist * light0dist ); spot = max(dot(normalize(-light0vc), gl_LightSource[0].spotDirection), 0.0); spot = pow(spot, gl_LightSource[0].spotExponent); - diff_fac = max(dot(norm, normalize(light0vc)), 0.0); + diff_fac = max(0.0, dot(norm, normalize(light0vc))); diff += col_ambi_diff * gl_LightSource[0].diffuse.rgb * spot * falloff * diff_fac; - vec3 E = normalize(-pos); - vec3 R = normalize(-reflect(light0vc, norm)); + E = normalize(-pos); + R = normalize(-reflect(light0vc, norm)); spec_fac = pow(max(0.0, dot(R, E)), 80.0); spec += vec3(1.0, 1.0, 1.0) * gl_LightSource[0].specular.rgb * spot * falloff * spec_fac; - /* Background glow (light 1) - diffuse only, directional */ - diff += col_ambi_diff * gl_LightSource[1].diffuse.rgb * max(dot(vec3(light1vc), norm), 0.0); + /* Light 1: Background glow */ + diff += col_ambi_diff * gl_LightSource[1].diffuse.rgb * max(0.0, dot(vec3(light1vc), norm)); } |