diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-07-31 18:33:52 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-07-31 18:33:52 +0000 |
commit | e9a81bde4f1a0f6ba345ea3cb4a4fedeaa206087 (patch) | |
tree | 6eba47aa9e8c77c8c2a0d2fe9eddaab8b5aaf4ff /data | |
parent | 16a04f0160578db97752cb06c1f3722013e57046 (diff) |
Move things around. Specular lighting still not quite right...
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@202 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'data')
-rw-r--r-- | data/shaders/lighting.vert | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/data/shaders/lighting.vert b/data/shaders/lighting.vert index ad6ef27..d6c9bd4 100644 --- a/data/shaders/lighting.vert +++ b/data/shaders/lighting.vert @@ -22,14 +22,17 @@ varying vec3 col_emit; void main() { + vec4 vert; vec3 E, L; + vert = gl_ModelViewMatrix * gl_Vertex; + normal = gl_NormalMatrix * gl_Normal; + E = vec4(0.0, 0.0, 1.0, 0.0) - vert; + /* Spotlight - positional light */ - 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); + light0vc = vec3(gl_LightSource[0].position - vert); + light0hvc = normalize(E + light0hvc); + light0vc = normalize(light0vc); /* Diffuse "background glow" - this can be normalised only once, here, since 'position' * is really 'direction' and is the same for all vertices. */ @@ -37,11 +40,9 @@ void main() { /* Fill-in light */ light2vc = normalize(vec3(gl_LightSource[2].position)); - L = vec3(gl_LightSource[2].position) - vert; - light2hvc = normalize(E + L); + light2hvc = normalize(E + light2vc); /* Material properties */ - normal = gl_NormalMatrix * gl_Normal; col_ambi_diff = gl_Color.rgb; col_emit = gl_FrontMaterial.emission.rgb; |