Game Development
Occlusion culling
Learn to cull out-of-view surfaces with Occlusion Culling.
Frustum culling vs Occlusion culling
By default, Unity does not render objects outside the camera view pyramid (Frustum Culling). However, objects that are inside the view field but completely hidden behind a massive wall or building are still rendered, wasting GPU power (Overdraw).
// Occlusion Culling:
// Even if inside the frustum, objects completely
// occluded by front obstacles are not rendered.
Occlusion Culling discards objects obscured behind blockers, eliminating redundant rendering.
Occlusion bake and static flags
Occlusion Culling data is pre-baked for the scene. Large structures that block visibility are marked Occluder Static, while objects that can be hidden behind them are marked Occludee Static.
// Editor setting:
// Window -> Rendering -> Occlusion Culling -> Bake
// 'Smallest Occluder' controls the blocker precision.
Once baking is complete, obscured objects are discarded instantaneously as the camera navigates between cells.
Exercise Simulate culling status
Inspect the inFrustum and isOccluded flags: if outside the view (!inFrustum) print "Frustum Disi", if in frustum but hidden (isOccluded) print "Occlusion ile Elendi", otherwise print "Cizildi" using Console.WriteLine.
Show example solution
using System;
class CullingTest
{
static void Main()
{
bool inFrustum = true;
bool isOccluded = true;
string status;
if (!inFrustum)
status = "Frustum Disi";
else if (isOccluded)
status = "Occlusion ile Elendi";
else
status = "Cizildi";
Console.WriteLine($"Durum: {status}");
}
}
Test yourself
-
Which system prevents rendering objects that are inside the camera frustum but hidden behind a wall?
- Occlusion Culling
- Frustum Culling
- Dynamic Batching
- Post-processing Bloom
Show answer
Occlusion Culling — Occlusion Culling detects and eliminates objects hidden behind other solid objects even if they reside inside the camera view.
-
Occluder static flag
StaticEditorFlags flags = StaticEditorFlags.____;
Show answer
StaticEditorFlags flags = StaticEditorFlags.OccluderStatic;
-
Culling terms
- Frustum Culling
- Doesn't render outside camera view
- Occlusion Culling
- Eliminates objects hidden behind
- Occluder
- Blocker that obscures objects behind it
- Occludee
- Object that can hide behind an obstacle
Next lesson: Summary - Performance