Count the no of Z fail

Dear All,

Is it possible to count the no of times Z comparison failed.This is very useful for
solving one of my algorithm


For each object ? For each fragment ? For all the buffer ?

Depending on what you really need to do, occlusion queries might help you.

Otherwise there is the stencil buffer, but it might be really difficult to do so with it if not impossible (due to high counts).

Yes, that is possible.

Use Occlusion Queries, to count pixels of what you render.

First render your object with depth-function GL_ALWAYS (and maybe color and depth-writes disabled, so that it has no effects, after all).
Count how many pixels were rendered.

Second, render your object, as you would render it usually and again count the number of pixels rendered.

Subtract the second number from the first and you know how many pixels were rejected during the z-test.


Thanks a lot

Dear Jade and Jin

Thanks a lot.


You just misspelled our names but this is okay :slight_smile: