Game Optimization: Culling in games


Culling in games is like an optimization trick where the game engine ignores or doesn't draw anything the player can't see or hear at that moment.
Imagine you're looking through a window. You don't bother describing or drawing everything that's behind the wall to your left, or miles down the street beyond your view. Culling does the same for the computer.
Its main purpose is to save processing power (both for the CPU and the graphics card) by avoiding unnecessary work. If an object is behind a wall, too far away, or outside the camera's view, rendering it is pointless.
The Core Problem:
“Rendering Everything is Slow”
When a 3D scene is rendered, the computer (specifically the GPU) goes through the rendering pipeline process. A major bottleneck in this pipeline is sending "draw calls" (instructions to draw an object) to the GPU and then having the GPU process all the polygons (triangles) that make up those objects. If you have millions of polygons across thousands of objects, and the camera only sees a tiny fraction of them, rendering everything is a massive waste of computational power.
Rendering Pipeline—In game engines, the rendering pipeline transforms 3D models and scenes into a 2D image displayed on the screen. This process involves several stages, including vertex processing, culling, lighting, shading, rasterization, and post-processing, which the GPU performs.
Types of Culling
1) Frustum Culling:
Not drawing anything outside the camera's visible "pyramid" of sight. - "If an object is entirely outside the view frustum, don't draw it."
but testing every single triangle of every single object against the frustum's six planes (near, far, left, right, top, bottom) would be incredibly slow. This leads us to the concept of a "conservative test."
Instead of testing every individual triangle of a complex 3D model (which could have thousands or millions of triangles), we use simpler, coarser shapes that completely enclose the object. These are called bounding volumes.
Conservative Test - means it's designed to never report a visible object as invisible.
Bounding Volumes in Detail
AABB (Axis-Aligned Bounding Box):
A rectangular box whose sides are always perfectly aligned with the global X, Y, and Z axes of your 3D world.
OBB (Oriented Bounding Box):
A rectangular box that can be rotated to align with the object's local axes perfectly. It "hugs" the object more tightly
Game engines often use AABBs for their speed, accepting the trade-off of occasional false positives, especially for objects that aren't frequently rotated or are generally compact. OBBs might be used for specific, highly elongated objects or more precise culling passes later in the pipeline.
2) Occlusion Culling:
It is a process that eliminates drawing calculations for objects that are completely hidden (obscured or "occluded") by other objects that are closer to the camera and opaque. This improves rendering efficiency by influencing the following:
Draw Calls: Fewer commands sent from the CPU to the GPU.
Vertex Processing: Fewer 3D points needing transformation.
Pixel Fill Rate (Overdraw): Fewer pixels are being drawn and then immediately overwritten by something in front of them.
Occluder - an object within your scene that acts as a "blocker." It's something solid and opaque that obstructs the view of other objects behind it.
eg - wall, building, terrain, giant rock, closed door
The general process of occlusion culling involves:
Mark Blockers: The game flags big, solid objects as "occluders."
Check Hiding: For other objects, it tests if they're completely hidden by those occluders.
Don't Draw Hidden Stuff: If an object is hidden, the game skips drawing it that frame.
Occlusion Culling Techniques:
2) Early-Z Rejection (or Early Depth Test)
3) Backface culling:
No Need to Draw the Back! The graphics card then checks: "Is this piece facing away from the camera?" If it is, then you, the player, can't possibly see that side anyway (because it's facing away from you, or it's inside a solid object like the other side of a wall).
most solid 3D objects (like a closed box or a character model), roughly half of their tiny pieces are always facing away from the camera. By simply ignoring these "back faces," your game's graphics card has half as many pieces to draw, making everything run much faster and smoother.
4) Hierarchical Culling: Optimizing the Tests
Even with fast bounding box tests, testing every single object individually in a massive scene would still be too slow. This is where hierarchical culling comes in. It's about organizing your scene's objects into a tree-like structure (a hierarchy) and testing visibility from the top down.
The Idea: If a large "parent" bounding volume is outside the view frustum, then all the objects (its "children") contained within that parent volume must also be outside the view frustum. This means we can discard a huge chunk of the scene with just one test.
Subscribe to my newsletter
Read articles from Priyanshu Shukla directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Priyanshu Shukla
Priyanshu Shukla
I am developer from India, I started my coding journey in late 2022 and currently exploring Web Dev soon will be shifting towards my interest in AI and Game Dev