0
$\begingroup$

Why are there very similar yet distinct arrays: gl_ClipDistance[] vs gl_CullDistance[]?

What would be some use cases where the need for two distinct entities become apparent?

$\endgroup$
1
$\begingroup$

The two are different because they do different things. Clipping and culling aren't the same thing at all. If an edge crosses a clip plane, the primitive has to be clipped to be within that plane. This means generating new primitives from the old one.

If all vertices of a primitive are outside of a cull plane, then the entire primitive is culled.

You use the cull planes when you want the VS to be able to cull out primitives based on some calculation. You use clip primitives when you want primitive rendering to be bounded to some non-clip-space region (though line and point width can violate those borders).

$\endgroup$
1
  • $\begingroup$ I ran this simple experiment on the triangle example from Sascha Willems' Vulkan repo. In the vertex shader if(0 == gl_VertexIndex) gl_CullDistance[0]=-1.0f; and expected the whole triangle to disappear but it didn't. I had to set the gl_CullDistance[0] to -1.0f for all three vertices to make the triangle disappear. On the other hand, gl_ClipDistance[] worked as expected. $\endgroup$ – Vectorizer May 30 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.