Log inGet started

World detail — terrain, voxels, streaming, LOD

Updated December 5, 2026
  • cluster LOD — every static mesh, and every copy of an instanced draw, draws a level of detail the GPU cuts per cluster, per view, from how large the mesh's own simplification error shows on screen (below)
  • terrain — a heightfield drawn through a quadtree LOD cut that refines under the camera
  • voxels — a VoxelWorld split into chunks, each meshed on the GPU into its own child entity
  • spatial streaming — a cell store that stands and releases groups of entities as sources move

Cluster LOD: the level of detail every static mesh has

A static mesh is split into clusters of up to 124 triangles, and a bake builds coarser levels of those clusters into a hierarchy. Each frame, for each view, the GPU draws the coarsest clusters whose simplification error projects to at most renderer.clusterErrorPx() pixels (1 by default). Detail falls off continuously and cluster by cluster: a mesh needs no authored LOD levels, no distance bands and no swap code, a near and a far part of one large mesh each draw the detail they show, and every copy of an instanced draw is cut from its own distance.

A mesh draws its hierarchy once its bake has landed. renderer.mesh.clusters(mesh) says which set it draws:

kindwhat the mesh draws
dagthe LOD hierarchy
singleone level of clusters at full detail (a mesh asset with clusterLod = false)
lod0its full-detail clusters, the same triangles at every distance

Every static mesh asks for its bake when it reaches the device:

  • A .mesh asset bakes at the depth its clusterLod setting asks for (true, the default, is the hierarchy), whether it materialises through meshRef:handle() or through renderer.mesh.create(meshRef:load()).
  • A mesh built from geometry — renderer.mesh.create({ positions, indices, ... }), the form generated rocks, trees, buildings and props take — bakes the hierarchy from the definition the engine holds, with no CPU copy. A clusterLod = false field in the src bakes one level instead.
  • A mesh an instanced population draws is asked for its bake by the renderer.mesh.drawInstanced that draws it, whichever way it reached the device (the engine's own preloaded meshes, a mesh stood by renderer.mesh.update, an asset named by its AssetRef): a mesh no set was asked for bakes at its asset's clusterLod depth, or the hierarchy when no asset answers for it, and a mesh held off the device bakes once the registration brings it back.
local tree = renderer.mesh.create({ positions = P, indices = I, normals = N, uvs = U })
renderer.mesh.drawInstanced(tree, { transformBuffer = "forest.xf", instanceCount = n, material = bark })
-- every copy draws the tree's hierarchy once its bake lands

The mesh draws lod0 while its bake runs and its hierarchy from the frame the bake lands. renderer.mesh.clusters(mesh).status reads the two together: queued or baking while the bake is in flight, adaptive for the hierarchy, singleLevel for one level, unbaked for a mesh drawing lod0 with no bake asked for, and excluded (with its reason) for a mesh drawn outside the clusters. Geometry created with keepCpu, morphTargets, skinning or skins, and geometry rewritten in place with renderer.mesh.update / renderer.mesh.setVertices, draws its full-detail set; renderer.mesh.scheduleClusters bakes such a mesh once its shape holds.

Bakes run off the frame, several at once: renderer.mesh.clusterBakes().concurrency whatever they hold, and more while the geometry they hold is under renderer.mesh.clusterBakeHeldBytes, so the many meshes a world load brings in reach their hierarchies together. A finished hierarchy is kept by the geometry it was built from: a mesh that leaves the device when nothing displays it, and is shown again, draws its hierarchy again without a second bake, and so does a mesh created again or a second mesh of the same geometry. renderer.mesh.clusterBakes().cache says how much is kept and how often a bake found its set there.

Reading the work a cut saves:

renderer.mesh.clusters(mesh)          --> { kind = "dag", levelCount, clusterCount, triangleCount, ... }
renderer.drawStats().clusterTriangles --> triangles the camera views drew from the cluster lists
renderer.cullStats().views            --> per view: clustersLodRejected, clustersDrawn, trianglesDrawn

Skinned, morphing and compute-written meshes, blended materials, line materials and shaders with a hand-written vertex stage draw outside the clusters, so they take no cluster cut. topics/rendering-geometry covers how the cluster raster draws and shades.

What is resident right now

Reading a Terrain, VoxelWorld or StreamingSource component's fields back tells you what was asked for. The streaming namespace answers the other question: what is standing, what it costs, and for a piece that is not on screen, which of a closed set of reasons it is not.

local reading = streaming.observe()
reading.totals        --> voxelChunks / voxelChunksMeshed / voxelChunksFailed /
                      --  voxelGpuBytes / terrainEntities / terrainBound /
                      --  terrainIndexCount / cellsTotal / cellsResident /
                      --  cellsPending / cellBytesResident
reading.terrain       --> per Terrain entity: bound, nodeCount, indexCount,
                      --  vertexCapacity, meshGuid, and the eye the cut refined under
reading.voxel         --> per VoxelWorld: chunksTotal / meshed / queued / failed /
                      --  empty, gpuBytes, and one row per chunk
reading.cells         --> the store's config, its counters, and one row per cell

Each axis reads on its own too: streaming.terrain(), streaming.voxel(), streaming.cells().

The same document is served at /zero/runtime/observations/streaming. It is built by the call and published as its last act, so the namespace and the VFS node carry one reading rather than two derivations of it:

local served = require("@builtin::modules.json").decode(
    vfs.read("/zero/runtime/observations/streaming"))
served.reading.totals.voxelChunksFailed

Nothing is computed per frame. An engine nobody is observing pays nothing, and streaming.observe() is the only thing that builds the reading.

Which pool a number belongs to

voxelGpuBytes is what the voxel chunk builds reserved on the device — the vertex pool at the renderer's own stride plus one u32 per reserved index. It is that pool alone. The terrain pool is reported as vertexCapacity per terrain entity, the streaming store's bytes as cellBytesResident, and every resource the device holds under any system is renderer.gpuMemory() and asset.observe().

Why a piece is not on screen

streaming.whyNotDrawn(entityOrName)                     -- whichever system holds it
streaming.whyNotDrawn({ entity = "Vox", chunk = "0_0_0" })  -- one voxel chunk
streaming.whyNotDrawn({ cell = "3_-2" })                    -- one streaming cell

The answer is { kind, reason, detail }. reason is one of the set streaming.reasons() enumerates, and detail names what it is about:

reasonwhat it means
drawnthe engine holds this subject's geometry and is drawing it
notManagedno terrain, voxel or streaming system holds it
notBuiltnothing has built this subject's geometry
buildQueueda build has been asked for and has not run yet
buildFaileda build ran and the engine did not carry it through — detail is the engine's own message
builtEmptya build ran over a region holding nothing to draw
emittedNothingthe build ran and the shader wrote no geometry into the capacity it reserved
outsideRadiusno streaming source is close enough to want it resident
evictedit was resident, the store released it, and its content now reads from the file the release wrote
hiddenthe entity carrying the geometry is switched off

A voxel world that stands and draws nothing

A chunk's state is the engine's verdict on the build, not the component's record of having asked for one. VoxelWorld:dirtyChunks() empties as soon as each chunk has been attempted; VoxelWorld:chunks() says what became of the attempt:

for _, chunk in ipairs(world:chunks()) do
    print(chunk.key, chunk.state, chunk.detail)
end
-- 0_0_0  buildFailed  the compute shader never compiled within 10000ms, so the dispatch was dropped

Each row carries state, detail, dispatches and failures from the engine's dispatch record, the block count the build read (solidVoxels), what it reserved (reservedVertices, reservedIndices, gpuBytes), and the entity and mesh the chunk draws through.

The join is the buffer prefix: every buffer of a build is created under one, and the engine's dispatch record names it — so chunk.buildPrefix is what holds a chunk against compute.program.status(shaderGuid) directly.

Reserved is not emitted, and the row carries both

reservedVertices / reservedIndices are the capacity the build asked the device for, sized off an upper bound before the shader ran. emittedVertices / emittedIndices are what the shader actually wrote, read back off the counters it increments as it emits.

They are different numbers and the difference is a whole class of failure. A dispatch the device carried through that wrote nothing leaves a chunk holding a MeshHandle, a plausible gpuBytes, failures = 0 — and no geometry. That chunk reads emittedNothing, and meshed is only ever reported for a chunk whose counters say geometry is there.

The read is issued once the engine has recorded the dispatch reaching the device — a read issued before that returns the zeros the build wrote into the counters, which is indistinguishable from a shader that emitted nothing. Until it lands, the chunk reads queued with a detail saying the answer is not in yet; emittedVertices and emittedIndices are absent from the row.

Gpu.emitted(chunk.buildPrefix) waits for that read rather than reporting the absence, for a caller that wants the number and not the state.

Publishing a reading of your own

/zero/runtime/observations is generic. Any Luau system can put a reading on the engine's shelf and gain a VFS leaf without a change to the engine:

__observations.publish("mySystem", { resident = 12, pending = 3 })
-- served at /zero/runtime/observations/mySystem as
-- { name = "mySystem", publishedAtMs = ..., reading = { ... } }
__observations.names()   --> { "mySystem", "streaming" }

The document is serialised at the moment of the call, so the bytes the VFS hands out are the bytes of the table the publishing call built.