diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-08-06 11:57:49 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-08-06 11:57:49 +0000 |
commit | 74b8dae4b4d403570373dced50df8b741846ca21 (patch) | |
tree | 2cc4cf7d14174f437859de633443a647ea0a788e /data | |
parent | acf1eb14767d5d7c5ffa3b2c9402ea459f4ffb42 (diff) |
Introduce 'v4conv3' conversion function
General fussiness
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@212 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'data')
-rw-r--r-- | data/shaders/lighting.frag | 9 | ||||
-rw-r--r-- | data/shaders/lighting.vert | 13 |
2 files changed, 13 insertions, 9 deletions
diff --git a/data/shaders/lighting.frag b/data/shaders/lighting.frag index d3e3534..a9febe4 100644 --- a/data/shaders/lighting.frag +++ b/data/shaders/lighting.frag @@ -18,6 +18,9 @@ varying float light0dist; varying vec3 light1vc; varying vec3 light2vc; +varying vec3 col_ambi_diff; +varying vec3 col_emit; + uniform sampler2D texture; uniform sampler2D normalmap; @@ -27,9 +30,6 @@ uniform bool texture_enabled; uniform bool texture_emits; uniform float alpha; -varying vec3 col_ambi_diff; -varying vec3 col_emit; - void main() { vec3 ambi; @@ -49,7 +49,7 @@ void main() { /* Emission */ emit = col_emit; - + if ( fill_light_enabled ) { /* Light 2: Fill-in light for lander */ @@ -77,7 +77,6 @@ void main() { 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; diff --git a/data/shaders/lighting.vert b/data/shaders/lighting.vert index 59d026d..0178530 100644 --- a/data/shaders/lighting.vert +++ b/data/shaders/lighting.vert @@ -21,26 +21,31 @@ varying vec3 light2vc; varying vec3 col_ambi_diff; varying vec3 col_emit; +vec3 v4conv3(vec4 a) { + vec4 div = a/a.w; + return div.xyz; +} + void main() { vec4 vert; vec3 vert_to_light; vert = gl_ModelViewMatrix * gl_Vertex; - pos = vec3(vert); + pos = v4conv3(vert); normal = gl_NormalMatrix * gl_Normal; /* Spotlight - positional light */ - vert_to_light = vec3(gl_LightSource[0].position - vert); + vert_to_light = v4conv3(gl_LightSource[0].position - vert); light0dist = length(vert_to_light); light0vc = normalize(vert_to_light); /* Diffuse "background glow" - this can be normalised only once, here, since 'position' * is really 'direction' and is the same for all vertices. */ - light1vc = normalize(vec3(gl_LightSource[1].position)); + light1vc = normalize(v4conv3(gl_LightSource[1].position)); /* Fill-in light */ - light2vc = normalize(vec3(gl_LightSource[2].position)); + light2vc = normalize(v4conv3(gl_LightSource[2].position)); /* Material properties */ col_ambi_diff = gl_Color.rgb; |