Lighting seems relative to camera orientation?
I have what is I suspect a really noob question. I set up a global light, and use glLookAt to position & orient my camera. For the most part all is well. However, I notice that as I rotate the camera (changing not the location of the camera, just the look-at-target), polygons get lighter and darker. I thought maybe I was picking up some specular lighting, but I think I've disabled that.
Here is the code (JOGL):
gl.glEnable(GL.GL_LIGHTING);
gl.glEnable(GL.GL_LIGHT1);
gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, new float[] { .1f, .1f, .1f, 1f}, 0);
gl.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, new float[] { 1, 1, 1, 1}, 0);
gl.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, new float[] { 0, 0, 0, 0}, 0);
float[] pos = new float[] { .866, .5, 0, 0 };
gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, pos, 0);
Any idea what I am doing wrong?
thanks
snak
Everytime you set the light position it is transformed by the current modelview matrix. To place it statically in the world set the light position every frame after you set the modelview matrix to the camera transformation.
After the definition if the w part of a position of a light is 0 it is a directional light. If you want it to be a point light you have to specify the w with 1.
---> float[] pos = new float[] { .866, .5, 0, 1 }; <---
Everytime you move the camera you should also update the light position to get correct results.
---> float[] pos = new float[] { .866, .5, 0, 1 }; <---
Everytime you move the camera you should also update the light position to get correct results.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement