Occlusion quereis and depth test using shaders

Anybody have an idea how to implement a shader version of the NV_OCCLUSION_QUERY? I need to do this for adding more functionality, for example, compute and retrieve the penetration depth in collision tests.

Thanks,

I do not think this is possible…

While gathering data on visible samples can be done by running a special shader on each fragment and summing it after reading the data to the CPU, you won’t be even able to write a shader that exacly computes the number of samples (because there is no programmable blending).

As Zengar points out, the GPU doesn’t have generalized programmable methods for doing information gathers like this.