diff options
Diffstat (limited to 'data/shaders/lighting.vert')
-rw-r--r-- | data/shaders/lighting.vert | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/data/shaders/lighting.vert b/data/shaders/lighting.vert index 914d6ac..d9306e6 100644 --- a/data/shaders/lighting.vert +++ b/data/shaders/lighting.vert @@ -9,10 +9,11 @@ * */ +varying vec3 pos; varying vec3 normal; varying vec3 light0vc; -varying vec3 light0hvc; +varying vec3 light0half; varying vec3 light1vc; varying vec3 light2vc; varying vec3 light2hvc; @@ -22,10 +23,15 @@ varying vec3 col_emit; void main() { + vec4 vert; + + vert = gl_ModelViewMatrix * gl_Vertex; + pos = vert.xyz; + normal = gl_NormalMatrix * gl_Normal; + /* Spotlight - positional light */ - vec4 vert = gl_ModelViewMatrix * gl_Vertex; - light0vc = gl_LightSource[0].position.xyz - vert.xyz; - light0hvc = vec3(gl_LightSource[0].halfVector - vert); + light0vc = gl_LightSource[0].position.xyz - vert.xyz; /* Don't normalise here */ + light0half = normalize(normalize(light0vc) + normalize(-vert.xyz)); /* Diffuse "background glow" - this can be normalised only once, here, since 'position' * is really 'direction' and is the same for all vertices. */ @@ -36,7 +42,6 @@ void main() { light2hvc = normalize(vec3(gl_LightSource[2].halfVector - vert)); /* Material properties */ - normal = gl_NormalMatrix * gl_Normal; col_ambi_diff = gl_Color.rgb; col_emit = gl_FrontMaterial.emission.rgb; |