Skip to main content

How to set up a scene for occlusion culling

By default, Unity will put the entire scene into one big chunk of space, called a View Volumes.

If you place an Occlusion Area into the scene, Unity will only calculate occlusion data for the inside of that space, which can make the occlusion data much smaller. If your scene is split into multiple seperate areas, consider covering them with Occlusion Areas instead of letting Unity calculate the entire scene as one big volume.

You can set occlusion settings from the Static flags on an object, or the Occlusion window.

image-1643384082055.png

Only big, solid things should be occluders!

This is a simple rule of thumb. If it's small, or transparent, or it has a hole in it, it shouldn't be an occluder. Trees shouldn't be occluders because they have leaves which create lots of tiny holes which can't be represented by the occlusion. Complex edges are bad.

If it's always visible, don't make it an occludee!

If you have a skybox, or an ocean made of a gigantic plane, there is no point in allowing it to be occluded. The number of false positives will exceed the performance gain.

Make smaller objects occludees, but not occluders.

Just because something is small doesn't mean it won't benefit from occlusion culling.

Use the EditorOnly tag to create fake occluders!

If an object has the "EditorOnly" tag, it won't render in-game. However, it'll still be considered during the baking process.

How do I preview occlusion culling?

In Unity 2018, occlusion culling affects the Scene camera. Besides that, if you select Visualization in the Occlusion window, you can see how the occlusion culling works from the perspective of cameras in the scene. 

When you select Visualization, the scene Hierarchy will be filtered to only show objects with Camera components, and the occlusion culling for the currently active camera's perspective will be shown. You can see the raycasting used by the camera and the low-res scene the rays are cast against to determine what is being occluded and where.

To go back to normal, switch to the other tabs in the Occlusion window or close it.

What do the "Bake" settings mean?

In the Occlusion window, there's a "Bake" section with some settings and a block of text. As the text notes, you don't really need to change the settings because they're already tuned for a good balance between speed and performance.

Smallest Hole sets the threshold for a gap in geometry to be considered a "hole" which can be seen through. The smaller this is, the longer it will take to generate occlusion. Set this to a value that suits your scene, ideally between 0.05-0.5. (5cm to 50cm)

Smallest Occluder sets how much detail the baked occlusion data will take into account. The smaller this is, the more small things will be taken into account when calculating the occlusion, and the more calculations the occlusion will do in runtime when calculating what's visible. Set this to a value slightly larger than the average player's size, so 2-6. (2m to 6m)

If you want to know more about them, visit this article on the Unity blog which explains them in more depth.