/* * lighting.vert * * Lighting calculations * * (c) 2007-2008 Thomas White * * thrust3d - a silly game * */ varying vec3 normal; varying vec3 light0vc; varying vec3 light0hvc; varying vec3 light1vc; varying vec3 light2vc; varying vec3 light2hvc; varying vec3 col_ambi_diff; varying vec3 col_emit; void main() { vec3 E, L; /* 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); /* 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)); /* Fill-in light */ light2vc = normalize(vec3(gl_LightSource[2].position)); L = vec3(gl_LightSource[2].position) - vert; light2hvc = normalize(E + L); /* Material properties */ normal = gl_NormalMatrix * gl_Normal; col_ambi_diff = gl_Color.rgb; col_emit = gl_FrontMaterial.emission.rgb; /* Coordinates */ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; gl_Position = ftransform(); }