diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-08-06 15:48:20 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-08-06 15:48:20 +0000 |
commit | 31606fee6eb5917e602103067b1f0d85ae1ff476 (patch) | |
tree | 15db6cf920dfb0f9a4adba14f9b57f7d82c8de5f /data | |
parent | 56564957104fbeaa1ba41698275a28d18a194c29 (diff) |
Give the spotlight an ambient component
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@223 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'data')
-rw-r--r-- | data/shaders/fill-light.frag | 2 | ||||
-rw-r--r-- | data/shaders/lighting.frag | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/data/shaders/fill-light.frag b/data/shaders/fill-light.frag index 249c881..eb89c79 100644 --- a/data/shaders/fill-light.frag +++ b/data/shaders/fill-light.frag @@ -41,7 +41,7 @@ void main() { norm = normalize(normal); /* Ambient */ - ambi = col_ambi_diff * gl_LightModel.ambient.rgb; + ambi = min(1.0, col_ambi_diff * (gl_LightModel.ambient.rgb + vec3(0.5, 0.5, 0.5))); /* Emission */ emit = col_emit; diff --git a/data/shaders/lighting.frag b/data/shaders/lighting.frag index e47108f..ab13e52 100644 --- a/data/shaders/lighting.frag +++ b/data/shaders/lighting.frag @@ -51,9 +51,6 @@ void main() { norm += (texture2D(normalmap, gl_TexCoord[0].st).rgb - vec3(0.5, 0.5, 0.5)) / 2.0; } - /* Ambient */ - ambi = col_ambi_diff * gl_LightModel.ambient.rgb; - /* Emission */ emit = col_emit; @@ -65,15 +62,19 @@ void main() { spot = max(dot(normalize(-light0vc), gl_LightSource[0].spotDirection), 0.0); spot = pow(spot, gl_LightSource[0].spotExponent); + /* Ambient */ + ambi = col_ambi_diff * (gl_LightModel.ambient.rgb + gl_LightSource[0].ambient*spot*falloff); + + /* Diffuse */ diff_fac = max(0.0, dot(normalize(light0vc).xyz, norm)); + diff += col_ambi_diff * gl_LightSource[0].diffuse.rgb * spot * falloff * diff_fac; + /* Specular */ L = normalize(gl_LightSource[0].position.xyz - pos); E = normalize(-pos); R = normalize(-reflect(L, norm)); spec_fac = max(0.0, dot(R, E)); spec_fac = pow(spec_fac, shininess); - - diff += col_ambi_diff * gl_LightSource[0].diffuse.rgb * spot * falloff * diff_fac; spec += vec3(1.0, 1.0, 1.0) * gl_LightSource[0].specular.rgb * spot * falloff * spec_fac; /* Light 1: Diffuse background glow */ |