I am writing a very simple directional light shader and I want to pass in my own light position coordinates (treated more like a directional light) instead of using gl_LightSource[0].position. I've been searching around and couldn't find any clear explanation on how to store my light position coordinate into eye space coordinates.
I've tried multiplying my vector with gl_ModelViewMatrix in the shader, and I've tried doing it on the CPU side but still can't produce the same result as gl_LightSource[0].position.
The light position (or direction rather) is (-1, 0, 0)
vertex shader:
Code :varying vec3 vertex_light_position; varying vec3 vertex_normal; uniform vec3 light_position; void main() { gl_FrontColor = gl_Color; gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; vertex_normal = normalize(gl_NormalMatrix * gl_Normal); // using my own light position coordinate vertex_light_position = normalize(light_position); // old version //vertex_light_position = normalize(gl_LightSource[0].position.xyz); }
So basically my question is how do I properly store my vector into eye space coordinates?
I appreciate anyone taking the time to explain this to me. Thanks