aboutsummaryrefslogtreecommitdiff
path: root/data/shaders
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-31 14:19:53 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-31 14:19:53 +0000
commit33ab5dffb5574e8f208b7ec216475170c9863633 (patch)
tree097165e6ae79a565e73347cf0a9e0a58b3a67132 /data/shaders
parentc566f87fe5853e4f1596792652f203c7386c8699 (diff)
Match shader results to non-shader results
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@200 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'data/shaders')
-rw-r--r--data/shaders/lighting.vert13
1 files changed, 9 insertions, 4 deletions
diff --git a/data/shaders/lighting.vert b/data/shaders/lighting.vert
index 914d6ac..ad6ef27 100644
--- a/data/shaders/lighting.vert
+++ b/data/shaders/lighting.vert
@@ -22,10 +22,14 @@ varying vec3 col_emit;
void main() {
+ vec3 E, L;
+
/* Spotlight - positional light */
- vec4 vert = gl_ModelViewMatrix * gl_Vertex;
- light0vc = gl_LightSource[0].position.xyz - vert.xyz;
- light0hvc = vec3(gl_LightSource[0].halfVector - vert);
+ vec3 vert = vec3(gl_ModelViewMatrix * gl_Vertex);
+ light0vc = normalize(vec3(gl_LightSource[0].position) - vert);
+ E = vec3(0.0, 0.0, 1.0) - vert;
+ L = vec3(gl_LightSource[0].position) - vert;
+ light0hvc = normalize(E + L);
/* Diffuse "background glow" - this can be normalised only once, here, since 'position'
* is really 'direction' and is the same for all vertices. */
@@ -33,7 +37,8 @@ void main() {
/* Fill-in light */
light2vc = normalize(vec3(gl_LightSource[2].position));
- light2hvc = normalize(vec3(gl_LightSource[2].halfVector - vert));
+ L = vec3(gl_LightSource[2].position) - vert;
+ light2hvc = normalize(E + L);
/* Material properties */
normal = gl_NormalMatrix * gl_Normal;