View Full Version : Vertex Count after the Z Order

07-17-2008, 11:01 PM
I have a question, can I read the current vertices count after the Z Sort? If I send at the OpenGl pipeline 40 vertices and They have all the same coords I think (Im sure :) ) the output is one vertices. Well I wnat read this values. Is It posible?

Thanks all for replies.

07-18-2008, 12:08 AM
I'm not sure what you're trying to achieve here, but OpenGL does not store your vertices. They are streamed and not sorted.
They are also not magically merged into a single vertex. Conceptually and technically they remain separate.

Any "sorting" (early-Z and other, really) happens at the fragment level before or after the fragment shader.
If you're interested in determining how many vertices map to specific screen coordinates, it may be possible to disable depth testing, use a fragment shader that kills any fragment that is not on the corners of the triangle, and do the counting in the stencilbuffer.
Not sure about what would happen to the edge cases though. And you wouldn't get counts for off-screen vertices.

If you intend to find out which input vertices map to the exact same 3D coordinates I think you're out of luck.

Dark Photon
07-18-2008, 04:43 AM
I have a question, can I read the current vertices count after the Z Sort?
As T101 said, it's not at all apparent what you're trying to do.

Vertices after Z sort has no meaning. Occlusion is based on fragments. You could in fact have a triangle where all 3 vertices are occluded but 95% of the triangle area is visible on the screen.

If what you want is to be able to probe the Z buffer and say "if I rendered an object (point, triangle, bunch of triangles, etc.) here, would I see it given the current state of the depth buffer?", you can in fact do that quite easily using occlusion queries. This allows you to establish what actually made it to the depth buffer.

See ARB_occlusion_query (http://www.opengl.org/registry/specs/ARB/occlusion_query.txt) and NV_occlusion_query (http://www.opengl.org/registry/specs/NV/occlusion_query.txt).