Hi, I want to use diffuse and ambient light. My problem is, that if I move with the camera (translate the ModelViewMatrix) the brightness of the faces changes although the light should be fixed.
Here is my vertex shader:
attribute vec3 position;
attribute vec3 normal;
void main() {
gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1);
gl_Normal = normalize(gl_NormalMatrix * normal);
vec3 light = normalize(vec3(gl_LightSource[0].position));
float NdotL = max(dot(gl_Normal, light), 0.0);
vec4 ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
vec4 globalAmbient = gl_LightModel.ambient * gl_FrontMaterial.ambient;
gl_FrontColor = NdotL * gl_LightSource[0].diffuse + globalAmbient + ambient;
}
I set the light position each frame after translate the MoselViewMatrix:
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, mPosition);
What should I do?
PS: Is there an IDE/addon for Eclipse for GLSL?