What Is Occlusion Culling In Unity?
Occlusion Culling is a method to significantly reduce the processing power required to render a scene for a user, by only rendering required parts of the scene at runtime.
Today’s Objective: Add Occlusion Culling to my Unity scene, limiting unnecessary draw calls.
Note: This project is created in the Universal Rendering Pipeline, so if you are using Standard or HDRP, some options may look slightly different.
Preparing for Occlusion Culling:
In order to prepare a scene to use Occlusion Culling, you must go through all the objects in your scene and decide if they are:
- An Occluder: A static object that other objects could be hidden behind.
- An Occludee: A static object that could be hidden behind other objects.
- Neither: An object that, for any number of reasons, should not affect OC.
To set an object as one of these options, simply use it’s Static Flags:
After you’ve done that for all appropriate objects in your scene, you’re almost done.
Make sure that the Occlusion Culling checkbox is ticked on the camera in your scene:
Generating the Occlusion Culling Information:
After your scene is set up, we must move on to baking the OC data (yes, just like you would bake lighting data).
Open “Window/Rendering/Occlusion Culling”:
Under the “Bake” tab, you will find a few parameters that you can change if necessary (usually they are fine as-is). Through any tab, you will also see buttons at the bottom, one-of-which will also be called “Bake”:
Simply click “Bake” and your Occlusion Culling is active!
If you don’t see your OC happening in the Scene View, check:
- Are you on the Visualization tab of the OC window?
- Is the mode set to Visualize on the popup tab and the box ticked?
- Have you selected a camera (Shouldn’t be necessary, but check)?