Occlusion Culling - SkaterXLModding/skater-xl-mapping-wiki GitHub Wiki

Header

Table of Contents

Welcome

This guide will cover the fundamentals of setting up, adjusting, and utilizing occlusion culling to optimize larger maps. This not only a very common technique in all of game development, but is heavily used by the SXL developers themselves. Occlusion culling is not only a very powerful tool, but also surprisingly easy to set up and initialize on projects. With minimal effort, we can save very heavily on performance.

What is Occlusion Culling

Occlusion culling is a computational process in which objects are hidden if they are no longer visible, due to being occluded by objects in the foreground. Take a look at the example below. From the viewpoint of the skater, the sphere is not visible. Despite this, the game engine will continue rendering that sphere.

image

But, by baking occlusion culling, we can have it so that the sphere would no longer be rendered when it is being occluded. The concept can be expanded, tweaked, and capitalized upon for huge performance savings on maps of all sizes, and particularly large environments. If you have ever pushed the camera through the ground or a wall on a map, especially a map like Downtown LA, and noticed 90% of the environment vanish, you have seen first hand the effects of occlusion culling in action.

It is also worth noting, that Unity Engine uses another culling type called Frostum Culling by default, and in combination occlusion culling when baked. Frostum culling simply unrenders things beyond the cone of vision a camera has. For more info on these forms of culling check the Unity Manual on the topic.

Getting Started

Base occlusion culling is actually quite simple to set up. A good first step is identifying all the meshes in your scene you will want to work with the culling. For SXL mapping purposes this generally means the majority of our meshes in the scene, or really anything that will not move in the scene. In other words, identify static meshes. In the example below, all the meshes besides the sphere, and the skater are organized as the static meshes.

image

Once the desired meshes have been organized or identified in some manner, select them (or their parent if possible) and mark as Static.

image

Although all the inputs are marked as static in this example, only checking Occludee Static and Occluder Static are required for occlusion culling

Going forward, the Occlusion Culling tab is going to be required. Open it up by navigating to Window > Rendering > Occlusion Culling

image

Basic Occlusion Culling

Once the desired meshes have been marked static, it is as simple as coming to the Occlusion Culling tab, and pressing the Bake button at the bottom.

image

Once the data has finished baking, it can be easily visualized as well to understand further how the culling is functioning. By selecting the Camera object in the scene, it can be moved and otherwise manipulated through the scene as we view the culling working in realtime. The images below show this, as the camera moves through the scene, you can see the effects of what it can see change what is being rendered in the scene.

image

image