skip to content

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%

answer

  1. distance alone ignores the lens
  2. projected size or projected error
  3. two thresholds instead of one
  4. complementary dither while both draw
  5. flat cards far away

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.

solid answer

~40 s

Each LOD records its **geometric error**, how far its surface can deviate from the full mesh. Project that to pixels with `error * screenHeightPx / (2 * distance * tan(fovY / 2))` and choose the coarsest level below about one pixel; a plain **distance** threshold ignores field of view and resolution, so a zoomed scope shows coarse meshes. Popping has three parts. **Hysteresis** uses one threshold for going coarser and a looser one for coming back, so a tree near the boundary stops flipping. A **dithered cross-fade** draws both levels for a short time with complementary screen-door patterns, so every pixel shows exactly one of them and nothing needs sorting. Distant trees become **impostors**, pre-rendered images on cards, with views captured from many directions so they do not swivel.

code

pseudocode · 11 lines
pseudocode
// error[0] = 0 for the full mesh; error grows with the level index
function selectLod(obj, camera, current):
    ppm = camera.screenHeightPx / (2 * distance(camera, obj) * tan(camera.fovY / 2))
    lod = current
    // coarser: only while the next level would still look right
    while lod + 1 < obj.lodCount and obj.error[lod + 1] * ppm < 1.0:
        lod = lod + 1
    // finer: only once the current level is clearly too coarse
    while lod > 0 and obj.error[lod] * ppm > 1.25:
        lod = lod - 1
    return lod

go deeper

for a junior

Recall what an LOD chain is and that distant objects get coarser meshes because their triangles shrink below a pixel.

for a middle

Derive pixels per metre from the field of view, explain screen-space error, and describe hysteresis and dithered cross-fades as fixes for popping.

for a senior

Diagnose a popping forest into its causes, aggressive thresholds, flip-flopping and synchronised switching, and weigh cross-fade cost against impostors.

for a principal

Set the project's LOD rules: the error budget per quality tier, who authors and validates levels, and when impostors or cluster-based schemes replace hand-made chains.

## What a level of detail is A **level of detail** (LOD) is one of several versions of a mesh, from LOD0, the full mesh, to coarse versions with a fraction of the triangles, and often an **impostor** at the end. Far away a tree covers a few hundred pixels and thousands of its triangles are smaller than a pixel: they cost vertex and rasterization work and shade badly, because small triangles waste pixel-quad work. Choosing the right level per instance per frame is the second half of the visibility problem: culling removes what is not seen, LOD reduces the cost of what is. ## Choosing the level Three metrics are common: | Metric | Rule | Weakness | |---|---|---| | Distance | switch at fixed distances per level | ignores field of view and resolution | | Projected size | switch when the bounding radius in pixels falls below a value | ignores how well each level approximates the mesh | | Screen-space error | coarsest level whose projected geometric error is under a pixel budget | needs an error value stored per level | The projection comes from the camera. At distance `d`, half the view height in world units is `d * tan(fovY / 2)`, and that maps to half the screen height in pixels, so `pixelsPerMetre = screenHeightPx / (2 * d * tan(fovY / 2))`. A worked example, using this scenario's figures: a screen 1440 pixels tall with a 60 degree vertical field of view gives about `1247 / d` pixels per metre. A tree LOD whose surface deviates by 0.2 m from the full mesh projects to about 1 pixel of error at 250 m, so it may be used from there on. Narrow the view to a 15 degree scope and the same distance shows about 4.4 times as many pixels per metre: a distance-only rule would show that coarse level magnified. The pixel budget is a quality knob: platforms or quality tiers can scale it as an **LOD bias**. ## Why trees pop - The switch happens where the difference is visible: thresholds are too aggressive, or a coarse level loses branches and changes the silhouette. - A tree hovering near its threshold flips back and forth as the camera bobs. - Every tree in a forest switches at the same distance, so a visible wave of changes runs ahead of the player. ## Fixes 1. **Hysteresis**: go coarser only when the coarser level's projected error falls below, say, 1.0 pixel, and go back finer only when it rises above 1.25. Between the two values the current level stays, so small camera movements change nothing. 2. **Dithered cross-fade**: for a short time or a distance band, draw both levels. A fade value `t` runs from 0 to 1; the outgoing mesh discards the pixels whose dither threshold is below `t`, the incoming mesh discards the rest. Each pixel shows exactly one mesh, so there is no blending and no sorting, and temporal anti-aliasing smooths the pattern. The costs are drawing two meshes during the fade and pixel discards, which can weaken early depth testing. 3. **Geomorphing** for terrain and heightfields: vertices slide toward their coarser positions over a distance band, so the surface changes continuously. 4. **Per-instance variation**: a small random offset on each tree's threshold breaks up the wave. 5. **Impostors** for the farthest trees: a camera-facing card with a pre-rendered image. A single image swivels as the camera moves around or above it, so better impostors store views from many directions in an atlas, often with normals and depth so they can be lit, and blend the nearest views. The switch to the impostor needs a cross-fade like any other level. ## Making the levels Good transitions start with good levels: simplification that preserves silhouettes, matching materials and normals across levels, and an error value per level measured, not guessed. Finer-grained schemes split a mesh into clusters, each choosing its own level by projected error, which avoids whole-object switches altogether at the cost of more complex data.

  • Why does a dithered cross-fade usually rely on temporal anti-aliasing to look smooth?
    On its own, the screen-door pattern shows a visible stipple of two meshes. Temporal anti-aliasing blends several frames with a sub-pixel jitter, so the alternating pixels average into what reads as a smooth fade. Without it, renderers shorten the fade or use a finer dither so the stipple is brief.
  • What goes wrong with a single-image impostor for a tree seen from a helicopter?
    The card was captured from the side and turns to face the camera, so from above the tree looks like a flat cut-out swivelling in place. Storing views from many directions, including above, and blending the nearest ones fixes this, at the cost of atlas memory.
  • Why should LOD selection use projected error rather than triangle count?
    Triangle count says what a level costs, not what it looks like. Two levels with the same count can differ greatly in how far their silhouettes deviate. Projected error ties the switch to what the player can actually see at this distance, field of view and resolution.

A landscape painter does not paint each leaf on a distant hillside, only shapes and colour, because the eye cannot resolve more at that size. Picking a LOD by projected error asks the same question: how much detail can this many pixels show?

  • LOD distance thresholds need no change when the field of view narrows.
  • Cross-fading LODs needs alpha blending and back-to-front sorting.
  • Hysteresis means waiting a fixed time before every LOD switch.
  • A single camera-facing card works as an impostor from every angle.
  • Fewer triangles always means a less visible LOD change.