PDA

View Full Version : Help with culling & depth test



ipo
10-26-2000, 11:07 PM
I hope someone can be of help in figuring out this problem. My scene contains two hexahedrons; the first is placed -5.0 units on the x-axis whereas the second is +5.0 units on the x-axis. The code is as follows:

glClearDepth(1.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_CULL_FACE);
drawScene();
glDisable(GL_CULL_FACE);

As I rotate the scene, everthing works just fine. Now, if I change the code to read as follows:

glClearDepth(1.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
drawScene();

then, as the rotation takes place, when one of the hexahedrons enters the 2nd quadrant on the x-z plane its face begins to display a series of diagonal black stripes that disappear as the hexahedron leaves the quadrant.

Further, if the code becomes

glClearDepth(1.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
drawScene();

then the black stripes show up when the hexahedrons enter the 3rd quadrant. In both cases, the stripes become more pronounced if I zoom out along the z-axis.

The scene uses GL_LIGHT0. Initially I thought the problem would be related to the position of the light but I found out that this does not seem to be the case as I am able to move the light around but the stripes remain.

I use the glut function to draw the hexahedron so I believe the problem is not related to the normal vectors either.

Does anyone know what the problem might be?

Thanks

DFrey
10-27-2000, 04:27 AM
You seem to be describing z-buffer artifacts. So my guess is you need to adjust the ratio of zFar/zNear.

ipo
10-27-2000, 03:35 PM
Thank you. The problem was precisely the zNear to ZFar ratio. Hope I can be of help in the future.

ipo