3
votes

In OpenGL you can draw only back-facing polygons, only front facing polygons or both. If you render a manifold triangle mesh, then clear the frame-buffer but not the depth buffer, then again render only the back facing polygons. What do expect to see?

I think the following answer given to me is wrong:

You should see the back facing triangles. The first render pass will result in the depth buffer having the depth values of the triangles that are front facing. The second render pass you are rendering the back facing triangles, hence those that have the greatest depth value. Every triangle that is rasterized will have its depth value compared to the current depth value for that pixel. Since the depth buffer is set to all the closest depth values (small values) but is discriminating on the farthest depth values (large values) the back facing triangles will be rendered."

But I think the answer is:

Since the depth buffer is not cleared, and still contains the depth values of the front facing triangles, it would throw out the back facing triangles, and display nothing.

Which answer is correct?

2

2 Answers

1
votes

It depends! Assuming the mesh is of an object that is a 2-dimensional manifold (i.e. topologically equivalent to a plane over sufficiently small areas around any point on the surface) and the first pass renders front- and back-facing triangles or just front-facing ones, and the depth function is GL_LESS or GL_LEQUAL then the second paragraph is right, since the front-facing triangles are always in front of the back-facing triangles and hence will always cause the depth test to fail.

Of course, if you use GL_GREATER or GL_GEQUAL as your depth function, the reverse is true so the first paragraph is correct.

0
votes

I think the second paragraph is false.

Imagine a Moebius band which is a closed manifold. You can see clearly some back facing triangles (in white, front facing are in black) that are closer to the eye. In the second pass they will pass the depth test and be rendered:

alt text