diff options
Diffstat (limited to 'data/shaders/lighting.vert')
-rw-r--r-- | data/shaders/lighting.vert | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/data/shaders/lighting.vert b/data/shaders/lighting.vert index af80574..914d6ac 100644 --- a/data/shaders/lighting.vert +++ b/data/shaders/lighting.vert @@ -10,45 +10,33 @@ */ varying vec3 normal; -varying vec3 col_ambi_diff; -varying vec3 col_emit; varying vec3 light0vc; -varying vec3 light0half; -varying float light0dist; - +varying vec3 light0hvc; varying vec3 light1vc; varying vec3 light2vc; +varying vec3 light2hvc; -vec3 v4conv3(vec4 a) { - vec4 div = a/(a.w); - return div.xyz; -} +varying vec3 col_ambi_diff; +varying vec3 col_emit; void main() { - vec4 vert; - vec3 vert_to_light; - vec3 vert_to_eye; - - vert = gl_ModelViewMatrix * gl_Vertex; - normal = gl_NormalMatrix * gl_Normal; - /* Spotlight - positional light */ - vert_to_light = v4conv3(gl_LightSource[0].position - vert); - light0dist = length(vert_to_light); - light0vc = normalize(vert_to_light); - vert_to_eye = v4conv3(-vert); - light0half = normalize(normalize(vert_to_eye) + light0vc); + vec4 vert = gl_ModelViewMatrix * gl_Vertex; + light0vc = gl_LightSource[0].position.xyz - vert.xyz; + light0hvc = vec3(gl_LightSource[0].halfVector - vert); /* Diffuse "background glow" - this can be normalised only once, here, since 'position' * is really 'direction' and is the same for all vertices. */ - light1vc = normalize(v4conv3(gl_LightSource[1].position)); + light1vc = normalize(vec3(gl_LightSource[1].position)); /* Fill-in light */ - light2vc = normalize(v4conv3(gl_LightSource[2].position)); + light2vc = normalize(vec3(gl_LightSource[2].position)); + 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; |