PDA

View Full Version : Inward-pointing normal?



kingcu
11-13-2005, 07:52 PM
Hi,

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:

1. Enable depth test;
2. Enable lighting;
3. Enable light0;
4. Set light properties (ambient, etc);
5. Set the material properties;
6. Enable GL_NORMALIZE;

I didn't touch either the projection matrix or the modalview matrix.

Any one has any idea how this could be?

Thank you,
wt

charliejay
11-14-2005, 01:01 AM
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? :D )

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...

CJ

kingcu
11-14-2005, 06:42 AM
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. :confused:

charliejay
11-15-2005, 04:45 AM
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)?

CJ