Occlusion culling
From DmWiki
| Table of contents |
Occlusion culling (or hidden surface determination) is a culling method that uses the notion of occluders to cull unseen objects away from a scene. An occluder is anything that is occluding (blocking) another object on the screen. So occlusion culling algorithms are used to determine what objects cannot be seen because they are behind other objects--even though they are inside the view frustum. There are generaly two types of occlusion culling algorithms--geometric methods and image space methods.
Geometric occlusion culling usually tests objects with other objects in a 3D environment. Occluders are selected based on their efficiency. For example, a big wall makes a good occluder. And to check to see if objects are behind that wall, compare bounding volumes, then render accordingly.
Image space occlusion culling algorithms work on a flat surface. The general idea is to represent as much of the screen as is possible with 2D data, which is then used to cull away unnecessary objects.
Occluder fusion is also one of the functions in an occlusion algorithm. Occluder fusion is simply the joining of 2 or more occluders to become one big occluder. With geometric algorithms this is hard to do since it requires manually connect the vertices of occluders together. With an image space algorithm, occluder fusion is implicitly achieved which is one of the plus points of image space algorithms.
Selecting Occluders
This is one of the main issues with occlusion culling. Selecting efficient occluders algorithmically is a challenge. Some people resort to putting tags on various 3D objects so that their game engine knows what object can be used as an occluder and what object cannot. This saves the engine time in trying to compute the most efficient occluders.
There really is no difference in selecting occluders for geometric occlusion methods and for image space occlusion methods. One thing to realize is that most of the time, a very small amount of the onscreen objects can actually be used as a decent occluder.
Tips/Keep in Mind
- Put occluders in a hierarchy--whatever is being used for geometry, be it an octree, a BSP tree, and ABT, etc. This will save time from doing geometrical (or image based) tests on occluders that are themselves not visible
- If using geometrical methods then occluder fusion could be too much for not much gain. With image based algorithms occluder fusion is free, but with geometrical methods it includes slicing occluders against the view volume and joining occluders together. This may cause delays depending on CPU-/GPU-boundness. If for example, if CPU bound then that extra processing is most probably a big waste. On the other hand, if GPU-bound then that processing could balance things out a bit.
- Do not use all the occluders in a scene. In an average scene, maybe there are 10-15% of the objects take up most of the space. So keep a threshold; don't over do it.
- Think about what is to be occluded. Today rendering static geometry is cheap. Things that cast dynamic shadows, skins, or use other expensive shaders are not. Those objects are potential candidates to be tested. A simple poly mesh that's just part of the scene is not.
- Also keep in mind that today's GPUs batch and buffer rendering commands. Some CPU time can be "wasted" for free if the GPU is busy drawing rendering commands that are already queued. Take advantage out of this: first draw lots of opaque static meshes (like the sky, for example) without occlusion. This will fill up the queue and keep the GPU busy. Then start to occlude the more expensive stuff like characters, alpha-blended geometry and so on.
- Think about using hand-generated occluders if possible. That way, the ratists(?) can tag the biggest geometry as potential occluders. And it will save the engine from doing unnecessary pre-processing on the current scene.
Links
- Optimizing rendering using occluders (http://www.devmaster.net/forums/showthread.php?t=4737), DevMaster forums
- Occlusion Culling Algorithms (http://www.gamasutra.com/features/19991109/moller_haines_01.htm), Gamasutra
- Occlusion Culling for Walkthroughs of Large Virtual Environments (http://www.billbaxter.com/projects/occlusion.html), Bll Baxter
- Rendering the Great Outdoors (http://www.gamasutra.com/features/20020717/bacik_01.htm), Gamasutra
- Hierarchical Occlusion Maps and Occlusion Culling (http://www.cs.unc.edu/~zhangh/hom.html), Hansong Zhang, Univerisity of North Carolina - Chapel Hill
- Wikipedia: Hidden surface determination
- Online Occlusion Culling (http://www.abo.fi/~jstaffan/occlusion)
