PDA

View Full Version : What is the easiest way to do occlusion culling?



Fezziwig
09-11-2012, 01:46 PM
I can't seem to find any easy to follow tutorials on how to implament occlusion culling

Any help is much appreciated!
Thanks,
Rowan.

cireneikual
09-11-2012, 03:46 PM
The easiest way that doesn't hurt performance that I can think of is to define occlusion planes, and then perform ray casts from the camera to the bounding box corners of any items that can be occluded. If all the rays intersect the plane, the object is occluded.

However, if you want hardware occlusion queries (using scene geometry as occluders), the easiest ways will hurt performance more than they will help. For hardware occlusion queries, you will need a more complex algorithm like CHC++ (http://www.cg.tuwien.ac.at/~matt/chc++/CHC_revisited.pdf) to make it perform well.

Fezziwig
09-12-2012, 09:21 AM
Although you seem fairly anti-hardware occlusion queries I'm just curious on how you would do it and see whether it has any effect on my programs fps.

Fezziwig
09-14-2012, 08:35 AM
~~~bump~~~

mhagain
09-14-2012, 05:27 PM
For hardware occlusion queries - glGenQueries a bunch of queries. glBeginQuery, draw an object's bounding volume, glEndQuery. glGetQueryObject with GL_QUERY_RESULT_AVAILABLE, if it's not available then use the last valid result, if it is then use the new result. If the object is new in the scene (e.g it may have been frustum culled in the previous frame) then the last valid result is "it's visible". You're screwed if you're using instancing, and you need to be careful to ensure that the cost of drawing bounding volumes plus issuing queries works out as less than the cost of just drawing everything anyway.

cireneikual
09-14-2012, 07:02 PM
I actually tried the method mhagain describes, but it is usually slower than using no occlusion queries. I don't know if you saw the link in my previous post, but it is a link to an article about CHC++, which makes hardware occlusion queries worth their expense. CHC++ supposedly works well with instancing too. However, it is pretty complicated to code. You need a spatial partitioning system to do it.

mhagain
09-15-2012, 03:59 AM
I actually tried the method mhagain describes, but it is usually slower than using no occlusion queries. I don't know if you saw the link in my previous post, but it is a link to an article about CHC++, which makes hardware occlusion queries worth their expense. CHC++ supposedly works well with instancing too. However, it is pretty complicated to code. You need a spatial partitioning system to do it.

This is definitely true and highlights the last point I made which is worth re-emphasizing: "you need to be careful to ensure that the cost of drawing bounding volumes plus issuing queries works out as less than the cost of just drawing everything anyway".

I guess that the real issue here revolves around what you're using hardware culling for. If it's for general-purpose full-scene visibility determination then yes, you do need the additional complexity and care.