Occlusion query should also return rejected samples

I have a suggestion for the occlusion query testing. Instead of just returning the number of samples passed, it is also interesting to know the number of samples rejected. This way you will have an estimate of how big objects are in the screen space.

With this a probability based occlusion algorithm could be implemented:

  1. Render objects in random order
  2. Sort objects based on screen size (visible + not visible)
  3. In next frame, render biggest objects first. The smaller objects are more probable to be occluded by a big object.
  4. Check which objects are completely occluded; suspend drawing of these for N frames. N should be bigger for smaller objects.
  5. Repeat from 2.

This is a simple algorithm with little overhead. It will not create false positives like other occlusion algorithms based on bounding box/ball.

The only thing that needs to be changed is that the glGetQueryObjectiv function returns two values instead of one.

Thor Henning Amdahl

Nice idea, I hope the hardware supports it.

It would surprise me if the modern hardware does not support it.

For the old 3Dfx Voodoo cards you had these counters exposed in Glide.

Originally posted by Thor Henning Amdahl:
For the old 3Dfx Voodoo cards you had these counters exposed in Glide.
The thing is that the Voodoo cards were very simple in comparison with current GPUs so something which was simple to do in old cards might have performance implications in new ones with all those depth culling optimizations.