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:
- Render objects in random order
- Sort objects based on screen size (visible + not visible)
- In next frame, render biggest objects first. The smaller objects are more probable to be occluded by a big object.
- Check which objects are completely occluded; suspend drawing of these for N frames. N should be bigger for smaller objects.
- 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.
Regards
Thor Henning Amdahl