skip to content

Culling, Occlusion and LOD

How renderers skip what cannot be seen: frustum tests on bounding volumes, Hi-Z and query occlusion, LOD that trades triangles for distance. Interviewers probe it because frame time is won here.

on this pageshow

explore

questions

6

In a real-time renderer, what do frustum culling, backface culling and occlusion culling each remove, and why are all three needed?

level: juniorimportance: must knowfreq 62%

answer

  1. three different things can be invisible
  2. outside the view, facing away, hidden behind
  3. object level vs triangle level
  4. depth testing still pays for vertices

basics

~20 s

Frustum culling drops whole objects outside the camera's view volume, backface culling drops triangles facing away from the camera, and occlusion culling drops objects hidden behind nearer geometry. Each removes work the other two cannot.

solid answer

~40 s

**Frustum culling** tests each object's bounding sphere or box against the six planes of the view frustum and skips anything wholly outside, before any draw is issued. **Backface culling** is a per-triangle test done after vertex processing: the triangle's winding on screen says whether it faces away, and on a closed opaque mesh roughly half the triangles go before rasterization. **Occlusion culling** handles what both miss, objects inside the frustum but hidden behind a wall; in a dense city where the camera sees one street, thousands of buildings sit inside the frustum behind the facades. The depth buffer would hide them too, but only after their draws, vertices and rasterization have been paid for. All three are conservative: drawing something invisible wastes time, culling something visible is a bug.

go deeper

for a junior

Name the three tests, say what each one throws away and at what granularity: whole objects for frustum and occlusion, single triangles for backface.

for a middle

Explain where each test runs and what it saves: backface culling after vertex processing, the other two before a draw is issued, and why depth testing does not replace them.

for a senior

Show you know where the time goes in a dense scene: frustum culling leaves everything behind nearby walls, so occlusion culling usually dominates the saving, and all tests must stay conservative.

for a principal

Frame culling as a budget question: which tests a project can afford per frame, at what granularity, and which content rules (closed meshes, sensible bounds) keep them effective.

## Why a renderer culls at all A frame has a fixed time budget, and most of what a game world contains is not visible from any one camera position. **Culling** means deciding, as cheaply as possible, that some piece of work cannot affect the image and skipping it. Three different reasons make something invisible, and each has its own test: - it is **outside the view**: to the side of, above, below or behind the camera, or beyond the far plane; - it **faces away**: the back side of a closed surface; - it is **hidden behind** something nearer that is opaque. ## Frustum culling The camera sees a truncated pyramid called the **view frustum**, bounded by six planes (near, far, left, right, top, bottom). Testing every triangle against it would cost more than drawing them, so the test runs on a **bounding volume** per object: a sphere or a box that encloses the whole mesh. If the volume is entirely on the outside of any one plane, the object cannot be visible and is never submitted. Frustum culling usually runs on the CPU or in a GPU compute pass, often over a hierarchy so that a whole block of the world can be rejected with one test. ## Backface culling On a closed, opaque mesh, triangles on the far side of the surface are always covered by the near side. Each triangle is authored with a consistent **winding order** (clockwise or counter-clockwise when seen from the front). After the vertices are transformed and projected, the fixed-function stage before rasterization computes the triangle's signed area on screen; if the winding is reversed, the triangle faces away and is dropped. Two consequences matter: 1. It removes roughly half the triangles of a closed mesh, but only **after** their vertices were processed, so it saves rasterization and pixel work, not vertex work. 2. It must be **turned off** for open or two-sided geometry, such as leaf cards, flags or a single-sided cloth, or their back side disappears. ## Occlusion culling Frustum culling keeps everything inside the view volume, including objects behind a wall. In a city where the camera stands in one street, the frustum may contain thousands of buildings while the facades of a few dozen hide the rest. **Occlusion culling** tests objects against what is already known to be in front: a depth buffer from occluders, a downsampled depth pyramid, hardware occlusion queries, or precomputed visibility for interiors. It is usually the most expensive of the three tests to run, and in dense scenes usually the one that saves the most. ## Why the depth buffer is not enough The depth test does make hidden objects invisible, and early depth testing can skip shading their pixels. But by then the renderer has already issued the draw, processed every vertex and rasterized every triangle. Culling removes the object before any of that is spent. | Test | Granularity | Usually runs | Saves | |---|---|---|---| | Frustum | object, cluster or hierarchy node | CPU or compute pass, before submission | draws, vertices, pixels | | Backface | triangle | fixed-function, after vertex processing | rasterization and pixel work | | Occlusion | object or cluster | CPU or GPU, before submission | draws, vertices, pixels | ## Conservative by design Every culling test may keep something that turns out to be hidden (a **false positive** costs only time), but must never reject something visible (a **false negative** is a visible bug: an object vanishes or pops in late). Bounding volumes are looser than the meshes they enclose for exactly this reason, and an occlusion test that cannot decide, for example because an object crosses the near plane, reports it visible. ## Traps in practice - **Bounds that miss the motion**: an animated object whose bounds were computed in one pose, or a door swinging past its static box, can be culled while part of it is still on screen; bounds must cover the whole motion or be recomputed. - **Inconsistent winding**: a mesh exported with mixed winding loses scattered triangles to backface culling; the fix belongs in the content, not in turning culling off. - **Mirrored instances**: a negative scale flips the winding on screen, so the renderer must flip its front-face rule for those instances or they render inside out. - **One view only**: shadow and reflection views need their own culling against their own frusta, because an object outside the main camera's view can still cast a visible shadow.

  • Why is backface culling turned off for foliage cards and cloth?
    Those surfaces are open: a single sheet of triangles that the player can see from both sides. Backface culling would drop the sheet whenever its back faced the camera, so leaves and capes would vanish as they turn. Such materials are drawn two-sided, often flipping the normal for the back side so lighting stays correct.
  • Why test a bounding volume rather than the object's triangles?
    A sphere costs one distance comparison per plane and a box only a few more, while a mesh may have thousands of triangles. The test only has to be conservative: if the volume is outside, every triangle inside it is too. A loose volume costs an occasional wasted draw, never a wrong image.

  • The depth buffer already hides occluded objects, so occlusion culling is pointless.
  • Hardware backface culling removes triangles before their vertices are processed.
  • Frustum culling tests each triangle against the camera's view.
  • Backface culling is safe on every mesh, including leaves and flags.
  • A culling test may reject an object if it is probably hidden.
open as a page

How should a renderer choose a mesh's level of detail, and how do you stop trees from visibly popping as the player walks toward them?

level: middleimportance: must knowfreq 55%

basics

~20 s

Choose the coarsest level whose geometric error, projected to pixels, stays under a threshold, so field of view and resolution count. Hysteresis stops flip-flopping, dithered cross-fades hide the switch, and impostors replace the farthest trees.

open as a page

How does a bounding-volume hierarchy speed up frustum culling of a city with tens of thousands of buildings, and when is a flat array faster?

level: middleimportance: should knowfreq 50%

basics

~20 s

A hierarchy tests a node's bounds once: outside rejects the whole subtree, fully inside accepts it with no further tests, and only straddling nodes recurse with the planes they still cross. A flat SIMD array often wins for moving objects.

open as a page

In GPU-driven rendering, how does a compute pass cull tens of thousands of instances and compact the survivors, and what does moving culling off the CPU cost you?

level: seniorimportance: should knowfreq 40%

basics

~20 s

A compute pass runs one thread per instance, tests its bounds against the frustum and a depth pyramid, and appends survivors to dense per-draw lists through atomic counters. The CPU loses same-frame knowledge of visibility and debugging gets harder.

open as a page

How does Hi-Z occlusion culling test an object's bounds against a depth pyramid, and why do many renderers draw last frame's visible objects before building it?

level: seniorimportance: should knowfreq 45%

basics

~20 s

Hi-Z culling builds a mip chain of depth keeping each region's farthest value, then rejects an object whose nearest depth is behind it. Drawing last frame's visible set first gives a current pyramid without stale-depth false culls.

open as a page

How do portals and potentially visible sets cull the rooms of an indoor level, and what does a precomputed visible set give up?

level: middleimportance: nice to knowfreq 28%

basics

~20 s

Portals split a level into rooms joined by openings and narrow the view to each visible opening at run time. A potentially visible set precomputes, per cell, which cells can ever be seen, trading memory and static geometry for an almost free lookup.

open as a page