How do you use documentation throughout your workflow? Share your experience with us by taking this survey.
Getting started with occlusion culling
This page describes how to set up your SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info See in Glossary for occlusion cullingA feature that disables rendering of objects when they are not currently seen by the camera because they are obscured (occluded) by other objects. More info See in Glossary, bake your occlusion culling data, and visualize the results.
Setting up your Scene
Before you begin, identify all of the GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info See in Glossary in your Scene that you would like to be Static Occluders (GameObjects that do not move, and that block the view of GameObjects that are behind them) and Static Occludees (GameObjects that do not move, and are occluded by Static Occluders). A GameObject can be both a Static Occluder and a Static Occludee.
Good candidates for Static Occluders are medium to large solid GameObjects, such as a wall or a building. To be a Static Occluder, a GameObject must:
Have a TerrainThe landscape in your scene. A Terrain GameObject adds a large flat plane to your scene and you can use the Terrain’s Inspector window to create a detailed landscape. More info See in Glossary or Mesh RendererA mesh component that takes the geometry from the Mesh Filter and renders it at the position defined by the object’s Transform component. More info See in Glossary component
Not move at runtime
Note that if you are using LODThe Level Of Detail (LOD) technique is an optimization that reduces the number of triangles that Unity has to render for a GameObject when its distance from the Camera increases. More info See in Glossary groups, Unity uses the base level GameObject (LOD0) of a Static Occluder to determine what it occludes. If the silhouette of a GameObject varies considerably between LOD0 and other LOD levels, it might not be a good candidate for a Static Occluder.
Any GameObject that is likely to be occluded at runtime is a good candidate to be a Static Occludee, including small or transparent GameObjects. To be a Static Occludee, a GameObject must:
Have any type of Renderer component
Not move at runtime
When you have identified the GameObjects that you would like to be Static Occluders and Static Occludees, you can set up your Scene.
Select all of the GameObjects that you would like to be Static Occluders.
In the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info See in Glossary window, open the Static Editor Flags drop-down menu and select Occluder Static.
Select all of the GameObjects that you would like to be Static Occludees.
In the Inspector window, open the Static Editor Flags drop-down menu and select Occludee Static.
Add a CameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info See in Glossary to your Scene and select it, or select an existing Camera.
In the Inspector window, ensure that the Camera’s Occlusion Culling property is enabled.
In the bottom right hand corner of the Inspector window, press the Bake button. Unity generates the occlusion culling data, saves the data as an asset in your Project, and links the asset with the current Scene(s).
Visualizing the results
Ensure that the Occlusion Culling window and the Scene viewAn interactive view into the world you are creating. You use the Scene View to select and position scenery, characters, cameras, lights, and all other types of Game Object. More info See in Glossary are both visible. When the Occlusion Culling window is visible, Unity displays occlusion culling data and the Occlusion Culling popup in the Scene view.
Select a Camera in the Scene.
Move the Camera around, and observe the Scene view. You should see GameObjects disappear from view when the Camera cannot see them, due to either frustum culling or occlusion culling.
If required, tweak the bake settings in the Bake tab of the Occlusion Culling window, and repeat the baking process.
If you are using the Built-in Render Pipeline, you can use the Overdraw_ Scene View Mode to see the amount of overdraw that is occuring, and the Stats panel in the Game view to see the number of triangles, verts, and batches that Unity is renderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info See in Glossary.