Version: 2022.2
Language : English
Occlusion culling
Using occlusion culling with dynamic GameObjects

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 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
  • Be opaque
  • 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.

  1. Select all of the GameObjects that you would like to be Static Occluders.
  2. 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.
  3. Select all of the GameObjects that you would like to be Static Occludees.
  4. In the Inspector window, open the Static Editor Flags drop-down menu and select Occludee Static.
  5. 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.
  6. In the Inspector window, ensure that the Camera’s Occlusion Culling property is enabled.

Baking the data

Occlusion culling inspector bake tab.
Occlusion culling inspector bake tab.
  1. In the top menu, select Window > Rendering > Occlusion Culling to open the Occlusion Culling window.
  2. Select the Bake tab.
  3. 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

Occlusion Culling window Visualization tab.
Occlusion Culling window Visualization tab.
  1. 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.
  2. Select a Camera in the Scene.
  3. 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.
  4. Use the Occlusion Culling popup in the Scene view to configure the visualization.
  5. 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 PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary
, 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 rendering.

Occlusion culling
Using occlusion culling with dynamic GameObjects
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961