PDA

View Full Version : How to get the depth value on the other side



shapeare
12-13-2011, 06:05 AM
I rendered a model from the viewpoint of the light. The depth buffer contains many 1.0s except the places where my model lies. It is understandable, because the depth of the background is infinite, thus should be 1.

Now, I want to get the depth value of the points on the other side. I inserted the following statement in my code


glDepthFunc(GL_GREATER);

This time, the value in the depth buffer are all 1.0.

My explanation for this is that if OpenGL renders the background first, then the depth buffer will be filled with 1.0, obviously, all the points in the model has a depth value that is less than 1.0, so they cannot pass the depth test.

Am I right? How to get the depth value on the invisible side?

tksuoran
12-13-2011, 06:32 AM
Try glClearDepth(0.0); glDepthFunc(GL_GREATER), clear and render models.

thokra
12-13-2011, 08:49 AM
Simple, render the back faces into the depth buffer. Done.

shapeare
12-13-2011, 07:28 PM
Try glClearDepth(0.0); glDepthFunc(GL_GREATER), clear and render models.
This method works fine for me. Thank you very much.


Simple, render the back faces into the depth buffer. Done.
Do you mean using


glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);

thokra
12-14-2011, 02:57 AM
No. That's culling the back faces. Rendering the back faces means culling the front faces.