It seems the only time depth is used to discard data is during rasterization, i.e. at the fragment level.

In the geometry stage, I've only see culling and clipping of vertices. Is it not possible to determine whether if a triangle is behind another triangle using just vertex data (depth?) and discard if so? Wouldn't this save all the work later in scan conversion?


3 Answers 3


It doesn't work well to do depth tests at the vertex level.

Triangles are surfaces. All three vertices of a triangle could be occluded by other triangles in the scene and the middle of that triangle could still be visible. The only way to determine whether that triangle is completely behind something else is to interpolate position or depth along the triangle's surface and determine if, at every step of that interpolation, the triangle is still occluded.

This is precisely what the per-fragment depth test is already doing.

Thus, while you could do some "clever tricks" on a per-vertex basis to try to test if a triangle is fully occluded by others prior to the per-fragment test, they will never be completely accurate unless you do exactly the thing you're trying to avoid: step along the surface of the triangle as your rasterization resolution and test the triangle there.

  • 1
    \$\begingroup\$ Here's an example using some basic cubes. \$\endgroup\$ Commented Jan 12, 2018 at 18:07
  • 12
    \$\begingroup\$ Also, if you discard data at the vertex level, you'd have to be careful around transparent polygons, like glass, water, or foliage. \$\endgroup\$
    – Nolonar
    Commented Jan 12, 2018 at 20:58
  • \$\begingroup\$ @Nolonar Although to be fair, that doesn’t work well with per-fragment depth tests either (out-of-the-box; of course there are solutions like depth-peeling). \$\endgroup\$ Commented Jan 13, 2018 at 16:02

You can determine if a triangle is behind another triangle. However, that's not the operation you would need to do if you wanted to do culling at the triangle level. You would have to determine if the triangle is behind a forest of triangles: you have to determine if the triangle is behind any one triangle in the scene.

Triangle to triangle culling is expensive. Fragment by fragment culling is much much cheaper. Eventually the number of triangles will start to add up and fragment culling will be far cheaper.

This will also happen sooner than you think because we can't just test individual triangles. We have to test them together. If you have a triangle that's behind a quad (two triangles), it may be that your triangle being tested isn't occluded by either of the triangles that make up the quad on their own. This means now you need complex geometry tests to see if a triangle is covered in this way.

In the end, testing the triangle will be substantially more expensive than just doing the fragment tests.


This may be of interest:

Position-Only Shading Pipeline

the Cull Pipe uses these critical results to compute visibility information for all the triangles whether they are culled or not. On the other hand, the Replay Pipe consumes the visibility information to skip the culled triangles and shades only the visible triangles that are finally passed to the rasterization phase


It seems to solve exactly the problem you are asking about.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .