Course contentsShow
← Unity Game Development
Lesson 736 of 82811. Performance and Data PersistenceFree lesson

Configuring Occlusion Culling for Hidden Geometry

Learners will bake visibility data to prevent the GPU from rendering objects hidden behind walls or large structures within the scene.

Configuring Occlusion Culling for Hidden Geometry

In this lesson, you will learn how to reduce the burden on your GPU by preventing the rendering of objects that are physically blocked from the camera's view by walls, floors, or large structures.

Understanding Occlusion Culling

Even if an object is behind a thick concrete wall, Unity’s standard rendering pipeline may still send it to the GPU to be processed, wasting precious draw calls and pixel fill rate. Occlusion Culling solves this by pre-calculating visibility data. By "baking" your scene, Unity creates a set of cells that represent which objects are hidden from specific camera positions. If the camera cannot "see" an object because a static structure is in the way, that object is excluded from the rendering queue entirely.

Setting Up the Occlusion Data

To implement this, you must first ensure your structural objects (the things doing the blocking) are marked as Occluder Static in the Inspector. Smaller objects that disappear when hidden should be marked as Occludee Static.

  1. Open the Occlusion window (Window > Rendering > Occlusion Culling).
  2. Navigate to the Bake tab.
  3. Adjust the Smallest Occluder (the size of the smallest object that will hide other objects) and Smallest Hole (the smallest gap you want the system to account for) settings.
  4. Click Bake.

Unity will generate an OcclusionData asset associated with your scene. During gameplay, the camera will consult this data to perform a quick lookup; if the camera is inside a "cell" where certain objects are occluded, they are disabled before they reach the GPU.

Verification

Once baked, you can verify your configuration by selecting the Visualization tab in the Occlusion window. If you move your camera around in the Scene view while the game is running, you will notice objects vanishing in the Hierarchy or Scene view as the camera moves behind occluders. This confirms the data is functioning correctly, allowing your game to maintain high frame rates even in dense, complex environments.

Key Takeaway: Occlusion Culling optimizes rendering performance by pre-calculating visibility data to cull hidden objects, effectively eliminating unnecessary draw calls for geometry the player cannot see.