Feature Library

Heightfield chunks

0.69 GPU · 0.92 CPU ms
A still of the Heightfield chunks demo
Still
The live demo starts when it’s in view.Drag the ground to sculpt · right-drag to look · Space flies or pauses · L shows the levels

Ground in square chunks that stream round the viewer, from a game’s own world.

What it costs a frame

0.69 ms
0.92 ms
GPU
0.69 ms
CPU, median
0.92 ms
CPU, 95th pct
1.30 ms
Draw calls
64
Weight
Moderate

Measured 13 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 0.51–0.98, CPU 0.53–0.92 ms). What ran: Measured flying by itself at 14 m/s over the endless landscape, 38 m up, with the default rings (1 m within 96 m, 2 m within 224 m, 4 m within 480 m: about 210 chunks shown, about 60 drawn after culling). New chunks are made from the height formula and built, nearest first, inside a 2 ms allowance; most frames build none and a few build one or two. The levels view is off. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool0.690.921.30
apple · Apple A19 Proin a browser tab · 16 November 20264.941.542.90
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20264.261.714.30

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
three.js 0.187.0No other packages

What it’s for

  1. An open world or a big level whose ground streams round the player
  2. A terrain editor that sculpts across chunk borders, with undo
  3. A flight or drone view over endless procedural country
  4. A map or site model whose ground comes in tiles
  5. Streaming any grid of tiles in a frame allowance, nearest first
  6. Hiding seams between tiles of different detail
  7. Baking a height formula into tiles that agree at their edges

Pitfalls, in brief

  1. Store every border sample in both chunks (a corner in four) and write it to all of them on every edit.
  2. Sample a height formula on the world lattice, at whole-number sample indices times the spacing, not at a chunk’s origin plus an offset: then a border sample is the same number to the bit in both chunks.
  3. The resolution must be an odd number of samples (an even number of cells): 129 is 128 cells.
  4. Read normals and shade from the world’s heights, past the chunk’s own edge, not from the chunk alone.
  5. After an edit, reshape the neighbours whose normals and shade read the changed area (the shade reaches 12 m past a chunk), not only the chunks whose heights changed: their border lighting otherwise stays the old one.
9 more in brief
  1. Reshape every chunk a stroke reaches in the same frame.
  2. Skirts hide the cracks where a fine chunk meets a coarse one (the coarse edge cuts straight between its vertices, the fine one follows the ground).
  3. Give every ring a let-go distance past its take distance (32–64 m).
  4. Plan the rings again only after the viewer has moved some metres (8 here) or something changed.
  5. Keep each job small: a unit starts only while the allowance is open, so a frame overruns by one unit at most.
  6. One material and one mesh pool per resolution: a chunk coming into view must never compile anything.
  7. Where no chunk is made yet the world reads the formula; between samples it blends the samples round the point exactly as a made chunk does, so the ground does not move by a hair when the chunk is made.
  8. Let go of what was made from the formula: a world made from a formula without end grows by every chunk the focus ever passed (66 KB each at 129², some 12 MB a minute in the demo’s flight) unless chunks are forgotten when let go.
  9. Pointer picking marches the heights, not a physics ray: the colliders lag while the ground is being sculpted.
14 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Fully custom code.

Mark Jarzynski and Marc Olano, “Hash Functions for GPU Rendering” (JCGT, 2020): the PCG hash that fills the demo landscape’s table of random values

Thatcher Ulrich, “Rendering Massive Terrains using Chunked Level of Detail Control” (SIGGRAPH 2002 course notes): skirts hung from chunk edges to hide cracks between levels: the well-known method the source uses

terrainheightfieldchunksstreaminglevel of detailLOD ringshysteresisskirtscracksseamsshared bordersframe budgettime slicingnearest firstmesh poolsculptterrain brusheditorundoambient occlusionproceduralvalue noiseopen worldflight

Near it in the frame