chunk-core.js  ·  stream-core.js  ·  dag-core.js  ·  interactive companion

Levels of Detail

Far from the eye, the engine draws the world with bigger cubes. That sounds like one idea, but in the code it is five separate decisions, each made in a different place, and each with a trap that took a measurement to find. This page takes them one at a time, with the real code running on real worlds. Wherever a section uses a 2D model instead, it says so.

0
extra data for a coarse lod
8 B
a voxel count per node
K = 4
the cut's one knob, in the viewer
8³
cells: the unit of choice
0
holes along an axis, under shadow
1
lod apart, face neighbours
where? selectChunks split a chunk while dist < K · size §2–3 what? lodRule per 8³ brick: k fullest + each column's best §4–8 seams? uOpenSides + the seam tail, for neighbours one lod apart §9 when? coverOf complete beats finer §10 colour? cellAttr the count-weighted mean, quantized once §11
01

The DAG already is the pyramid

A texture keeps a mip chain: each level is computed from the one below and stored beside it. This engine stores nothing extra for its coarse lods. A node of the DAG at level l is a cube 2l voxels on a side, and it either holds something or it doesn't. So "the world at lod l" is just "the DAG, read down to level l and no further". A coarse cell is a node. A chunk at lod l is 64³ of them, which is one node at level l + 6, so asking for a coarse chunk walks only six levels below its own node.

wordwhat it issize in voxels
level ka depth in the DAG, counted up from the voxels (level 0) to the root (level D)2k
lod lwhich level a chunk's cells come from; lod 0 cells are voxels—
cellthe thing one cube draws: a level-l node at lod l2l
brick8³ cells, a level-(l + 3) node: where coarse cells are chosen (§7) and where the pose lives8 · 2l
chunk64³ cells, a level-(l + 6) node: the unit of a job, a cache entry and a draw64 · 2l

Slide the lod and watch three things. The cube count falls by about 4× a lod on smooth shapes, because what's drawn is a surface, and a surface has a quarter as many cells each time a cell doubles. It falls by more on solids at first, because more of the inside is buried. And on the gyroid, any (keep a cell if it holds anything) visibly fattens the walls, which is §4's problem.

The same world, level by level (census of the real store)

levelnode sidenodes in the treeunique (DAG)sharedas a chunk

The tree column is how many cells a coarse lod could draw, before the face test. The DAG column is what is stored: every coarse cell of a level is one of these few nodes. That's why coarse jobs are cheap to ask for, and why §7 can cache a coarse brick's choice per node.

The one thing a coarse lod does need: a count. any only needs "is this node empty?", which the DAG answers for free. Every better rule needs how full a node is, so keeps one float64 per node, summed children-first. A float64 is exact to 253, so a count is exact up to level 17 (817 = 251). Past that, a node missing one voxel has the same count as a full one. That made a job differ from expandChunk once (edit-log.md §2), and it's why exists: the full node of each level is the one whose eight children are all the full node below, and hash-consing makes that an exact test.

02

Where each lod goes: the cut

Start from the top chunk, the whole world at its coarsest lod. Split any chunk that is closer to the eye than K of its own sides, skipping the empty children (the DAG names them). What's left when nothing more splits is the cut. Its leaves partition the world, so every voxel is drawn by exactly one chunk, and each leaf is at the coarsest lod the rule allows at its distance. That's the clipmap of ifsandwhats.md §8.4, built as a cut through an octree rather than as nested boxes.

// selectChunks (stream-core.js), without the heap and the cap
if (c.lod > minLod && c.dist < detail * c.size) c.kids = childrenOf(world, c);   // split: 8 children, minus the empty ones
else leaves.push(c);                                                           // a leaf: drawn at this lod

Chunks per lod (bright: leaves, faint: split above them)

Drag the white eye marker; hover a chunk to see why it stopped splitting. Things to try:

Two K's. The streamer's own default is K = 2 (DEFAULTS.detail), and its tests, benches and experiments are measured there. The viewer has opened at K = 4 since 2026-11-09: you tried it while chasing lod acne (§8), and it looked better with no speed difference you could see. Doubling K halves a cell on screen (§3) and puts each lod's ring twice as far out. This page starts where the viewer does; the chip takes it back to 2.

At K = 4 the cap binds. From the default eye, maxChunks 1,024 refuses splits on every deep world here (on 2026-11-28: 129 on the kit D = 14, 47 on the terrain, 367 on the kit D = 16; at K = 2, none), so the viewer's defaults run capped on big worlds, and §3 shows the refused leaves above the ceiling. No leaf had a neighbour two lods finer on any of them.

The cap is not a threshold, and a fine lock shows it. When a split's children don't fit under maxChunks it is refused, but the heap goes on, and a later chunk with fewer non-empty children may still fit and split. Unlocked, every split is still under K · size, so by the proof above a jump needs a refused chunk nearer than (K + 1)/2 of its sides, 2.5 at K = 4; on the kit D = 14 the refusals start at 3.15, so none can happen there. Locked, nothing bounds it: on the kit D = 14 locked at 2, 1 or 0, splits ran out to dist / size 7.7–8.2 while lod-6 chunks at 3.5–4.1 were refused, and 2 or 3 of those leaves sat beside a neighbour split twice. That's the case §9's seam fix excludes, so a fine lock on a capped world can crack a seam. lod-locked.md's "face neighbours are the same lod" holds only while the cap doesn't bind (measured on 2026-11-28; not yet in the engine's tests).

Locked is a cut, not a cell rule. In the viewer it sits in the same menu as shadow, any and adaptive, but those decide which cells a coarse chunk draws (§4), while the lock decides which lod each chunk is drawn at. So locked is two things: stream-core's lock for the cut, and shadow's cells. Because the cells are shadow's, every chunk already made stays right when you go between the two or move the slider: the page hands the streamer the new lock and nothing is flushed. The chunks of the old lods keep drawing until the new lod's arrive, which is §10's fallback. The one-lod promise holds trivially: face neighbours are at the same lod, unless the cap held some coarser.

Why face neighbours differ by at most one lod. Say a leaf c of side S had a neighbour two lods finer across a face. That neighbour's parent p has side S/2 and was split, so it is less than K·S/2 from the eye. It lies inside c's face neighbour, within S/2 of c, so c is less than K·S/2 + S/2 from the eye. But c is a leaf, so it is at least K·S away. Both hold only if K < 1. (The first version of this comment said √3, which is the bound for boxes touching at a corner. The test found it slack: seams only meet across faces.)

One cut over several worlds

A universe (2026-11-19, universe-log.md) draws worlds as instances, never baked into one DAG: a world, the corner of its cube, one of the 48 turns, and 2scale universe voxels a world voxel. Its cut is : each instance's top chunk is a tree, and every tree's chunks go in one heap. Nothing else is new, because the rank dist / size is the same number in either frame. A scale multiplies both, and a turn moves neither. So worlds of different depths and scales each get the right lod with the eye taken into their own voxels (toLocal), and one maxChunks is spent where it shows most across the whole universe: a near chunk of a small world and a far chunk of a big one are compared as they look.

from the cut above
#instanceside, universe voxelsleaves by lodleavesthe same as selectChunks alone
…

Built here, when this table is first seen, with the real buildKit, createUniverse and selectForest: the renderer explainer's six instances of three kits (a D = 10 kit as it is, turned a quarter about y, mirrored and at ×2, another D = 10 kit, and a D = 12 kit at ¼, as big on the plane as the D = 10 ones). The last column runs selectChunks on each world alone, with the eye in that world's voxels, and compares the leaves key for key, as test/stream-core.test.js does. It can only agree while the shared cap doesn't bind. The renderer explainer's §11 draws these instances from above, with the cache's view of them.

Two things to try. At K = 4 from the low eye the cap binds and the instances near the eye take most of it (431 and 419 leaves against 24 for the far copy); at K = 2, or with maxChunks raised, it doesn't, and every tree is its world's own cut. And lock the lod at 3: a lock is a lod of each world, not a size in the universe, so the D = 12 kit at ¼ draws 264 chunks of 2-voxel cells where each D = 10 kit draws 8 of 8-voxel ones.

03

Why distance over size: a cell's size on screen

The split rule compares distance with size, and that is the whole reason it works. A cell of side 2l at distance d spans about 2l/d radians. A leaf stopped splitting because d ≥ K · 64 · 2l, so its cells span at most 1/(64K) radians, whatever its lod. Each point below is a leaf of the cut you just made in §2. Its height is the size of one of its cells on screen, from about the chunk's centre, which is chunkFootprint's side over 64. The thin curves are each lod's cell size as distance grows, and the cut hops from one curve to the next, which gives the sawtooth.

from §2
04

What a coarse cell is: six rules

The cut says which lod; the next question is what a cell at that lod shows. At lod 0 there's nothing to decide. At lod l a cell holds c of its 8l voxels, and a lod rule decides whether to draw it. Cells are binary, drawn or not, so a coarse rule can only choose which cells to keep. Each of the obvious answers is wrong somewhere (coverage-findings.md):

rulekeepsright onwrong on
anyevery cell with c ≥ 1smooth solidsanything porous: fills it in (1.2–6.8× the volume on specimens, 3.6× the coverage on wires)
majoritycells at least half fullthe fewest wrong voxels per cellanything thinner than half a cell vanishes: coverage 0.00 on sheets, wires and most testbed rows from lod 2
volumeper brick: the round(C / 8l) fullest cellsvolume, to within half a cellthin things: fewer, fuller cells block less light (0.46 on sheets)
opacityper brick: as many cells as a ray through 2l independent voxels would hit1-voxel sheetsalmost never acts: real content is lumpy, so it caps back to any
adaptiveper brick: the same, with the depth measured from the brick (§5)everything tested but two cases (medians 0.97–1.02)1-voxel sheets (0.49 at lod 3) and dust on a lattice (3.7×). At several pixels a cell, its dropped cells are see-through holes
shadowper brick: adaptive's cells, plus the fullest cell of every column of the brick, along x, y and z, that holds anythingno see-through hole along an axis, ever; fewer cells than any. The viewer's rule since 2026-11-10coverage: exactly any's, by construction (1.01–1.09 on smooth solids, 1.11–1.24 on 1-voxel content, lods 1–3). Oblique views aren't promised

What "right" means here is coverage, the measure coverage-plan.md decision 8 chose: along each axis, cut every column into segments one brick deep and count the segments that hit something, coarse over fine. 1.00 means the coarse version blocks as much light as the voxels do. Volume alone can be gamed (right amount, wrong place), and so the table also shows the voxel error: voxels drawn over empty space plus voxels dropped, over the true count.

rulecellsvolumeerrorcover →cover ↓

Click a row to draw that rule. Green: coverage within 5% of 1.00.

The brick under the pointer

Hover over either panel.

A 2D teaching model, 128 × 128 pixels: a cell holds 4l pixels (not 8l), a brick is 8 × 8 cells, and adaptive's root is a square root (a ray crosses √s of s samples in 2D, the cube root in 3D). shadow's columns are the brick's rows and columns, two axes, not three. The rules are otherwise written as keepCount and addShadow have them. Paint on the left panel (drag; shift or right button erases). §6 runs the real 3D code.

Try the 1-pixel walls under each rule, then the foam, then the lattice dust. The wall is 2D's version of the 3D sheet: majority deletes it, volume keeps a dashed line, and adaptive keeps a sparser dash than opacity. On the lattice dust, volume is the only rule that's right. Neither failure is a bug in a formula; both come from one number per brick standing in for a correlation that depends on direction (§5). Then shadow: it keeps every wall whole, since each of a wall's cells is alone in its column across the wall, and a column's fullest cell is always kept. What it gives back is any's over-coverage, which the table shows. Why the engine chose that trade is §8's story.

05

Adaptive: one formula, with its depth measured

The first run showed that volume and opacity are one formula. Suppose a ray through a coarse cell crosses m independent fine samples of density p. It hits one with probability 1 − (1 − p)m, so a brick of n cells should keep

k = n · (1 − (1 − p)m)        m = 1: volume (k = n·p = C / 8^l)     m = 2^l: opacity (every voxel independent)

A sweep of m found no single best value: 1 for solids, up to 6 for porous specimens at lod 3. m behaves like a correlation length, so the rule has to measure it, and the brick already holds the measurement. If its voxels were s independent samples per cell, a cell would be occupied with probability q = 1 − (1 − p)s. The brick knows q (occupied cells over n) and p (voxels over volume), so it can solve for s, and a ray crosses about the cube root of that:

s = log(1 − q) / log(1 − p)     // independent samples per cell
m = clamp(cbrt(s), 1, 2^l)      // adaptiveDepth: q = 1 carries no evidence, so it's read as 2^l
k = min(round(n · (1 − (1 − p)^m)), occupied)

The numbers are keepCount and adaptiveDepth from chunk-core.js, called with a brick of n = 512 cells, C = p · 512 · 8l voxels, and the occupied count from the slider. The slider runs from the fewest cells C voxels can fill (one lump) to the most (scattered).

Drag "occupied cells" from left to right with the density fixed. At the left end the voxels are packed into as few cells as possible, one lump, and m = 1: keep exactly the volume. At the right end the same voxels are spread so every cell gets some, and m = 2l: keep what a ray through independent noise would hit. Everything real is in between, and adaptive reads where. The flat-sheet case is the failure written out: q = 1/8 and p = 1/32 read as about 4 samples a cell, so m ≈ 1.6, and 26 of the sheet's 64 cells survive where face-on the sheet is opaque. The test suite holds that 26 by hand.

shadow starts from this same count (keepCount gives it adaptive's k), then adds back the fullest cell of every column of the brick, along each axis, in which the k left nothing. How many that adds depends on where the cells sit, which none of these numbers says, so the curve can't show it. On the sheet every cell is its own column along the normal, so shadow keeps all 64; on a solid lump the front cells already fill every column, and it adds almost nothing.

06

The rules on real content, in 3D

The real , run over every chunk of a 256³ world, under each rule. The table measures each one as experiments/coverage.mjs does: volume, voxel error, and slab coverage over all three axes, against the world's own voxels. Four worlds are shapes from experiments/shapes.mjs; five are built on this page to break a rule each (the three adversarial worlds of coverage-plan.md decision 11, and two kinds of dust).

rulecubesvolumeerrorcoveragems

Click a row to draw it. Coverage within 5% of 1.00 is green; beyond 25%, red.

Things to look for: any thickening the foam (watch its volume column climb with the lod); majority erasing the sheet and the wires entirely; adaptive keeping the foam's coverage near 1.00 while drawing fewer cubes than any; and the two places adaptive is wrong: the flat sheet (it thins it out) and the lattice dust (it over-covers). Those two are the deferred "anisotropic adaptive" question, which measures correlation per axis. Dust isn't a target (your call, 2026-10-10: the content will be custom fields).

And shadow, the rule the viewer draws with: on every world its coverage is any's to the last digit, while it draws fewer cubes. That isn't luck. Slab coverage counts brick-deep segments along the axes, and a brick-deep segment is a column of one brick, whose fullest cell shadow always keeps. The read-out checks the equality on each world as it measures. So shadow buys its missing holes with any's over-coverage; binary cells can't have both (§8).

07

Why the choice is made per brick

volume, opacity and adaptive can't decide one cell at a time, since they set a budget for a group. The group is the 8³ brick, a node at level l + 3, and that choice of group is load-bearing in three places:

shadow's columns are the brick's, for the same reasons. Its second pass () reads the brick's own cells and counts and nothing else, so all three hold for it, and fastChunk's cached masks pick the same cells. A column through the world crosses several bricks and each keeps its own, so the world keeps them all.

Inside a brick, ties are common: every cell a flat sheet crosses holds exactly the same count. Breaking them by Morton index would always drop the brick's high corner first. So is a fixed shuffle of the 512 positions, the same in every brick.

TIE_RANK: the 512 positions of a brick, slice by slice (dark: kept first)

A 1-voxel sheet at lod 2: one 64 × 64 layer of cells

The TIE_RANK and shadow layers are the real expandChunk's output, under adaptive and shadow. The Morton layer is this page's: the same 26 cells a brick, taken in Morton order instead.

08

Lod acne: why the viewer draws shadow

On 2026-11-09 you saw small dark specks on the stylized barbarian, in the cape, along the belt and round the axe hand, and only at coarse lods (lodacne.md). They were adaptive working as designed. Two facts turn its dropped cells into holes:

And they show because a coarse cell is several pixels on screen (§3), not one. adaptive was chosen on coverage-findings.md §4's premise that a cell is about a pixel, where a dropped cell reads as a slightly lighter pixel. At several pixels it reads as a hole.

rulekept cellsof any'sopaque columnsholesof opaqueholes along this axis

Click a row to draw it. Holes are pooled over the three axes, as experiments/lod-acne.mjs pools them.

The measure is lod-acne.mjs's, run here on every chunk of the world at one lod. For each axis, a coarse column is the 2l × 2l fine columns under one coarse cell, through the whole world. It's opaque if every one of those fine columns hits a voxel, and a hole if it's opaque and no kept cell, buried ones included, lies in it. The kept cells are the real expandChunk's. The hollow worlds are the solid ones' skin, the real : every voxel with an empty face neighbour, which is how --hollow builds one. As the experiment does, the page checks as it goes that any's columns are the fine ones', column for column.

The fix the engine took is the one this section's table has as shadow (lodacne.md §6 A, built 2026-11-10): keep adaptive's cells, then keep the fullest cell of every column of the brick, along x, y and z, that holds anything. A brick then blocks every column its occupied cells block, so no axis-aligned hole can open, and a sheet keeps every cell. It is one function, , which expandChunk and fastChunk's mask cache both call.

Simpler than first written. The plan said "the best cell of every column in which adaptive keeps nothing". A mutant that refilled every column survived the test, and it was right to: adaptive keeps a prefix of one order (count, then TIE_RANK), and a column's best cell comes first among its own column in that order. So a column with anything kept already has its best, and the condition can go. The code keeps every column's best; the test's oracle keeps the stated form, which holds the two equal.

On the assets that showed it (D = 10, experiments/lod-acne.mjs, not run on this page)

lodhollow barbarian: holescells against any'ssolid barbarian: holescellsknight (closed): holescells
10.32% → 00.65 → 0.750.30% → 00.94 → 0.960 → 00.99 → 0.99
24.10% → 00.43 → 0.652.90% → 00.85 → 0.910 → 00.96 → 0.97
314.48% → 00.30 → 0.627.35% → 00.73 → 0.850 → 00.92 → 0.95
426.92% → 00.20 → 0.6211.00% → 00.57 → 0.800 → 00.84 → 0.90

Each cell is adaptive → shadow; holes as a share of opaque columns, cells as a share of any's. From docs/lodacne-results.md (2026-11-09). The assets aren't in the repo, so the page can't run it.

What it costs is §6's other column: shadow's coverage is any's, exactly. Slab coverage counts brick-deep segments along the axes, which are the very columns shadow fills. So it removes the holes by giving back any's over-coverage (1.01–1.09 on smooth solids, 1.11–1.24 on one-voxel content, lods 1–3), while drawing fewer cells than any and sitting between the two on volume. Binary cells can't have both; drawing a coarse cell part-transparent (coverage-findings.md Q3) is the parked way out.

The decisions round it

Telling acne from other specks. Acne moves when the lod does: fly closer until the region is lod 0, where every rule is any, and a speck that stays isn't acne. And switching the rule to any makes acne vanish; if a speck survives that, it's something else (a gap in the mesh, or a dark texel baked into the colour).

09

Seams: where two lods meet

A job hides a cell's face when the cell next to it is occupied, and for a boundary cell it asks the neighbour chunk at the same lod (the apron). But the neighbour may be drawn at another lod, where that cell may not exist, or may be bigger than what it covers. Then a hidden face has nothing in front of it, and you see through the world. A job can't know how its neighbours will be drawn (that changes with every step of the eye), so the fix happens at draw time, in the shader:

// GLSL_DECODE. uOpenSides: one bit per side, set by coverOf when the same-lod neighbour across it isn't drawn.
uint recShown(uint r){ return recMask(r) | (boundaryBits(recCell(r)) & uOpenSides); }

An open side shows every boundary face. That covers faces of cells that have a record; a cell the apron alone buried has none. So each job appends those cells after its records, as the seam tail (mask 0), drawn only when some side is open. And a tail cell is kept only if the coarser cell across its face, the level-(l + 1) node holding the neighbour, isn't completely full.

A 2D teaching model: a side view, two chunks of 32 × 40 voxels, faces drawn as bright lines. A red slit on the seam is a fine stretch where one side is solid, the other isn't, and no face separates them, which in 3D is a hole into an interior with no faces of its own.

Things to try: right half at lod 1 with everything on, then turn each fix off. Without the open side, cracks appear on both sides of the seam, including the coarse side, because its apron saw the fine side's coarse cells, which are fatter than what's drawn. Without the tail, cells buried only by the apron still leave cracks. Turn the full test off and the tail grows (every buried boundary cell joins it) without fixing anything more. Then try lod 2, which the cut never makes when K ≥ 1: the full test looks only one level up, and it can drop a tail cell that was needed.

Why a full coarser cell needs no tail record (stream-plan.md, decision 11). Take a boundary cell n at lod l, and let P be the level-(l + 1) node holding its neighbour. The neighbour chunk is drawn at l − 1 or l + 1 (one lod apart, §2). If it's finer: P full means its children are full, and full cells are kept by every rule (§7). If it's coarser: P itself is the cell drawn, and a full cell is kept. Either way the space across the face is drawn solid, so no crack can open there. Without this test a solid chunk underground carries its whole boundary shell, about 23K records.

What seams cost on a real world (§6's world, every chunk, one lod)

lodchunksrecordsburied only by the apronin the taildropped by the full testtail ÷ records
…

Each lod under the viewer's rule (any at lod 0, shadow above). "Buried only by the apron" is border: 'closed''s records less the apron's: cells that show a face only when outside counts as empty. At lod 2 and up a 256³ world is one chunk, with no neighbours, so lods 0 and 1 are the ones with seams.

10

When lods change: complete beats finer

The cut is what the eye wants. Jobs take time, so what's on screen is whatever is resident, chosen by . Its rule: a region is drawn from its children only if all of them are resident; otherwise its parent stays up. So a region never mixes a chunk with its own descendants (nothing is drawn twice), the picture changes only when a replacement is whole, and the fallback is one lod coarser or finer in normal motion. The top chunk is pinned, so something always covers everything.

Below is the real streamer (createStreamer) running the real job (createJobRunner) on the main thread, on §2's world and eye, so you can throttle it and watch the transitions. In the viewer the same jobs run on workers.

drawn as wanted coarser: a parent standing in finer: children not yet merged hole: nothing to draw open side (seam tail on)

Two more filters, not on this page

Occlusion culling skips what the cover draws, without changing it (occlusion.md, ). After the raster pass, the viewer draws each raster chunk's box, grown by one of its cells, inside a WebGL2 occlusion query, depth-tested with every write off. A chunk whose box passed nothing is skipped in later frames and its box asked again, so it comes back once something stops hiding it. Like the frustum test, it filters what's drawn: the cut, the cover and what's resident are decided as before, and stream-core.js knows nothing of it. Its rule is a skip must never change a frame at rest. A cube inside the grown box is at least a cell behind the box's front faces along every ray, so a box that passes nowhere holds no cube that could win a pixel, and occlusionSelftest holds the frames drawn with skips to the frames drawn without, byte for byte. The price is time, not pixels at rest: a result describes a past frame, so a chunk the eye's move reveals can be missing for up to 2L − 1 frames when results are L frames late. It's on by default in the caves, the kit, the dungeon, the city and both universes, and off on open worlds, where every query is pure cost. This page runs no GL queries, so it isn't live here.

The placement preview has its own lod plan, and "complete beats finer" again (). While you place a world with the box (gizmo-log.md), its preview is drawn from the child's own lods, made a few milliseconds a frame and kept, under any, the bake's rule. One chunk of its coarsest lod comes first, whole, so there is always something to draw. At rest it draws the finest lod whose chunks are all made, and asks for the next finer one (about four times the cubes, so the steps before cost a third of the last). Moving, it makes nothing and draws the finest complete lod of at most 218 cubes. A lod with one chunk missing is never drawn, for the same reason coverOf never mixes a chunk with its descendants: the picture changes only when a replacement is whole.

11

A coarse cell's colour

A drawn coarse cell needs a colour. Its word is the mean colour of every voxel under it, weighted by voxel count (), so it doesn't depend on which lod you start from. Taken exactly, that's 8l evaluations of the field a cell, 512 at lod 3, which a job can't afford. So the walk descends meanDepth levels below the cell, and each sub-cell at the floor counts as its voxel count times the field at its centre. The default is 1: eight samples, one per child, weighted by the child's count.

meanDepth 1

the exact mean

difference, in 6-bit steps

The cell under the pointer: its eight children

Hover over a cell.

Every word here is the real cellAttr's, on the shape's own colour field. "The exact mean" is cellAttr with meanDepth = lod, which samples every voxel. The "rounded at every lod" figure is this page's: the children's 6-bit words averaged and rounded again, level by level.

12

The rules, and where to read

Each has a test behind it, and most are a sentence in CLAUDE.md. They're the finer points of the sections above, in the form you'd trip over them.

rulewhyheld by
a brick's cells are a function of its node and lodbrick dedup on the ray path, fastChunk's mask cache and the stamp all rest on it; a rule that looked outside its brick would make them silently wrong (§7)ray-core.test.js: one brick per node; job-core.test.js, fastChunk against expandChunk byte for byte under every rule
a new lod rule is written four timesits formula again in ruleDownsample, the dense oracle, a sparse case (dense content caps every per-brick rule at "keep all", where a mutant hides), and fastChunk's maskschunk-core.test.js; shadow came with 9 mutants there and one in job-core.test.js
shadow opens no axis-aligned holethe reason it's the viewer's rule (§8); its coverage is any's for the same reasonchunk-core.test.js: every brick's projections are its occupied cells', the world's is any's at lods 1–3, and adaptive must have opened holes in those cases
never compare a count to 8level: ask isFullcounts are float64, and past level 17 a node one voxel short has the full count (§1)job-core.test.js and edit-core.test.js, where a job once differed from expandChunk
face neighbours differ by at most one lodthe seam tail's full test looks one level up (§9). It holds for K ≥ 1 while the cap doesn't bind; a fine lock on a capped world breaks it (§2)stream-core.test.js: "the cut: face neighbours differ by at most one lod when detail >= 1, and not always below"
a chunk job is expandChunk with seams; shortcuts live elsewhereshortcuts go in the runner or fastChunk, never in expandChunk, so the dense oracles stay putjob-core.test.js fails until a change reaches fastChunk
quadsShown equals shownMaskthe viewer counts a chunk's faces under its open sides from per-side totals (quads plus openQuads), after its records are dropped; the count must be the faces the shader shows (§9)chunk-core.test.js, all 64 sets of open sides
complete beats finera region never mixes a chunk with its own descendants, so nothing is drawn twice and the picture changes only when a replacement is whole (§10)frameChecker in stream-core.test.js on every simulated frame, and the page's invariants()
a new streamer decision brings a frame invariantin frameChecker and the same check in the viewer's invariants(); the lock brought checkLockedstream-core.test.js; stream.test.js in the browser
a lock is a cut, not a cell rulelocked draws shadow's cells, so moving the slider flushes nothing (§2)stream-core.test.js: a flight locked 2 → 0 → 3 → 1 in one revision, 4 mutants; stream.test.js, 6 page mutants
each tree of a forest is selectChunks alonedist / size is the same in every frame, so a universe needs nothing new for its lods (§2)stream-core.test.js, key for key; this page, live
a skip must never change a frame at restocclusion filters what's drawn, never the cut; a cube in the grown box can't win a pixel its box didn't (§10)occlusion-core.test.js with a fake GPU; occlusion.test.js and occlusionSelftest, byte for byte
a preview lod is drawn only when all its chunks are madethe preview's "complete beats finer" (§10)gizmo-core.test.js
a coarse word is summed in floats and rounded onceso a cell's colour doesn't depend on the lod it's built from (§11)attrs.test.js: every word against the dense oracle, lods 0–3, meanDepth 0–3

Reading order for the code

Line numbers are looked up as the page loads, so they're right for the files you're serving. Click one to copy file:line.

#wherewhat to read for
1A chunk at lod l is a node at level l + 6: nodeAt, chunkNode, and the world smaller than a chunk.
2 The one word per node every rule needs, and the exact full test past level 17.
3 selectChunks: the heap, the cap, minLod, the one-lod proof; splitsAt, the split rule with the lock.
4The six rules, TIE_RANK, adaptiveDepth and keepCount; then , shadow's columns.
5 Where the walk hands a brick to the per-brick rule, and the sort.
6 boundaryBits, shownMask, the tail and its full test.
7The shader's half of seams: one line.
8coverOf: complete beats finer, the four states, and open.
9 Where the rule is chosen per lod: the streamer's default is any at 0 and adaptive above (its tests run that); the viewer hands it shadow above.
10cellAttr, meanUnder, and the baked field's mean hook.
11The fast job's per-node brick masks, which rest on §7's rule.
12 The measurements and proofs behind §4–9.
13A universe's cut: every instance's tree in one heap, and the forest's keys (§2).
14The tracker's rules: no result drawn, one query in flight, hidden asked again first (§10).
15The preview's lod plan (§10).

What this page leaves out