Occlusion Culling

Posted by unknownworlds 15 years ago

On of the important tasks in a first person engine is occlusion culling. Occlusion culling is the process of discarding elements of the world that aren’t going to contribute to the final rendered scene so that you don’t spend CPU and GPU time processing them. With expensive elements like dynamic lighting and shadows, this becomes especially important.

Here’s a Natural Selection 1 level rendered in our engine:

Even with the textures missing, some of you will probably recognize this spot. While this may look like a simple hallway, to the rendering engine it looks a lot more complicated. Here’s the same scene rendered in wireframe mode:

As you can see, there’s lots of stuff behind those walls that’s being rendered, but which we don’t actually see. In many first person engines this problem is solved by precomputing information throughout the level about what’s visible; this is known as a potentially visible set (PVS).

If you’ve ever done any mapping for the Quake or Half-Life engines, you’re probably familiar with the "vis" tool which performs this precomputation. This can be a slow process that requires a lot of tweaking and careful modeling. Because the data is precomputed, the environment can’t change much at run-time. And finally the PVS method is not very good when it comes to outdoor scenes.
To alleviate all of these problems, we’ve chosen to use a hardware assisted occlusion culling method that doesn’t require precomputation.

Here’s what the scene looks like with the occlusion culling system enabled:

As expected, most of the invisible geometry has been discarded during the rendering process. Because of way the algorithm utilizes the graphics card, the structure of the level doesn’t really affect the system. It works with outdoor environments as well as indoor environments and can handle polygons "soups" — collections of polygons that don’t really have any structure at all.

While real-time occlusion culling has some additional performance cost over precomputed systems like PVS, we think the benefits more than make up for it. And with clever optimizations, that cost can be reduced substantially.

For those that are technical minded and would like to learn more occlusion culling, our system is an implementation of the CHC++ algorithm (paper available online here).

Comments are closed.