Why Occlusion Culling Improves Performance
Are you looking to have your scene optimized? Occlusion Culling will help with rendering what’s important!
What is Occlusion Culling?
It’s a process that prevents game objects that are not in view, not rendered. In Unity’s terms:
Occlusion culling is a process which prevents Unity from performing rendering calculations for GameObjects that are completely hidden from view (occluded) by other GameObjects.
Now that we have an idea of what it does, let's implement it!
We first need to decide which game objects will be occluded. They have to be static, or if the tags have been switched for “dynamic elements” to be viewed as static.
In my case, I have separated all of my game objects to either be static or dynamic in an empty game object called “ — -STATIC — -.”
With the static game object selected, at the very top right, next to Static status, there is a dropdown you can click. Click on it and select everything. We want Unity to calculate what we want to occlude.
Click yes to the pop-up prompt. We want the children to be everything as well.
Click on the drop-down again, and select “Contribute GI” to be unchecked. Say yes to the pop-up prompt. We want to make sure that the Global Illumination is not occluded so Unity won’t have to recalculate the data.
Open the Occlusion Culling window: Window > Rendering > Occlusion Culling.
We want to bake the Occlusion Culling data from our scene. All of the static game objects will be processed within cells and have their data taken into account for when they can be visible or not.
When I switch between the “Visualization” and “Bake” tabs, you can see that it is working! Game objects that are in front of the camera will only render. You can now see how powerful this is and how it can speed/optimize your game!
Read the documentation over at Unity for more information on Occlusion Culling!