Probably not. If you render the object’s vertices as GL_POINTS
, you can use a query object (for GL_SAMPLES_PASSED
) to determine how many of those points were rendered, but it won’t tell you which ones.
But you could use
layout(early_fragment_tests) in;
on the fragment shader then record the current primitive ID in a SSBO, using an atomic counter for the index. The early_fragment_tests
option forces the depth test to be performed prior to executing the fragment shader, so if the fragment shader is actually executed then you know that the depth test passed.
You can use glColorMask
, glDepthMask
and glStencilMask
to prevent anything from being written to the framebuffer.