PDA

View Full Version : Getting vertices/polygons after depth buffer test?



Argumn
07-29-2008, 01:00 AM
I am looking for a way to retrieve all remaining and visible vertices or polygons (better both) after the depth test has been performed. What I require is the amount of vertices that are visible to the view with the current settings in form of vector data(and not as an image)
Is this possible at all with opengl?

ZbuffeR
07-29-2008, 04:17 AM
No.

Why ? Because depth test is a _fragment_ operation. It does not operates on triangles nor vertices.

But it is fairly easy to remesh a depthmap, if it is useful for you.

charliejay
07-29-2008, 09:03 AM
Suggestion:

Make one render pass of your scene including the colour buffers if required, which will create a depth image in the z buffer.

The render it again, not writing to any of the buffers, and using occlusion testing - use gl points, and draw a single pixel for each vertex; this should give you a pretty good idea of whether your vertices are hidden.

The render it again, not writing to any of the buffers, and using occlusion testing - this time use polygons, and any polygon where one of more pixels passes the depth test is visible.

Two provisos that I can think of:

- you'd have to use a depth test that passed equality on the second and third passes, ie. [less than or equal], instead of just [less than].

- you might have to include a z offset for the vertices testing pass, as I'm not sure whether the z values of a vertex at a given pixel are guaranteed to be the same as the z value of a polygon at that pixel.

There may very well be better ways to do this...

What's remeshing a depthmap?