Hi there, I'm triyng to do a simple point entity light shader where the light position is harcoded in the shader ( 0, 0, 0 ). The problem is that when I move my ball, it always recives the light in the same direction.
This is my vertex shader:
vec4 lightPos;
vec3 vertexPos, normal, s;
varying float i;
void main()
{
normal = normalize( gl_NormalMatrix * gl_Normal );
vertexPos = vec3( gl_ModelViewMatrix * gl_Vertex );
lightPos = vec4( 0, 0, 0, 1 );
s = normalize( lightPos - vertexPos );
// The diffuse shading equation
i = dot( normal, s );
gl_Position = ftransform();
}
And this my fragment shader:
varying float i;
void main (void)
{
gl_FragColor = vec4( i, i, i, 1.0);
}
In the picture attach you can see the result. Allways is the same result when I move it arroun the 0,0,0 position.
Any help is welcome,
thaks in advance.