I know this is weird. I have some problem with the direction of the normal. I know it should be pointing outward; however, when I try to disply a 3D unit cube made of 6 polygons, for each polygon, I have to set the normal to point toward the inside of the cube to get the proper color. Otherwise, if I use the regular outward-pointing normals, everything is black.
I am using JOGL. And here are what I did:
- Enable depth test;
- Enable lighting;
- Enable light0;
- Set light properties (ambient, etc);
- Set the material properties;
- Enable GL_NORMALIZE;
I didn’t touch either the projection matrix or the modalview matrix.
Any one has any idea how this could be?
Just some thoughts…
Are you culling back faces, front faces, no faces?
Do you define back faces as clockwise or counterclockwise?
Are you lighting back faces, front faces, (no faces?) ?
There are settings for all of these, if I remember correctly.
Also GL’s lighting is affected by the modelview matrix somehow, something along the lines of light positions being transformed by it… (I don’t use GL lighting much, can you tell? )
Would recommend doing a simple test using flat shading and no lighting to make sure you’re actually seeing the front faces of the cube, and then get the lighting going on top of that…
I am not using any culling, just glBegin(GL_POLYGON) with vertices specified in counter-clockwise direction. Tested with flat shading, the color is fine. For the light position, it’s far away from the cube (at least, I can make sure it’s not inside the cube). Getting really frustrated now.
JOGL: does it have gluLookAt, or an equivalent?
If so, what happens if you set the camera up at the light position, and look at the cube; do you see what you should see, or exactly the opposite of it (in very loose terms)?