2026-11-16 · 23 min · threejs · three-js · webgpu · computer-graphics · gpu-driven-rendering
A 2:49 narrated explainer, drawn in code. Every number and picture in it is this article's own; the sources are below.
› transcript
The top number is every triangle in this scene. The yellow one is how many actually get drawn. Each colour is a cluster of about a hundred and twenty-eight triangles, and each one picks its own detail. Hi, I'm Vertie. This is three-nanite. Let's build its hierarchy, then cut it. Take a few neighbouring clusters as a group. The vertices it shares with other groups are locked. Merge them and simplify to half. The outer border cannot move, so it still meets its neighbours. Split the result into half as many clusters, and repeat until one is left. Here is a small hierarchy, the source clusters at the bottom, each row half the one below. A cluster is drawn when its error, projected to pixels, is small enough, and its parent's is not. Move the camera, and the cut follows it. Fine where the camera is close, coarse far away. Now let each child measure its parent from its own bounds. Siblings disagree, and holes open. Every group carries one error and one sphere. The group's error in mesh units, times a constant from the screen height and field of view. Divided by the distance to the nearest point of its sphere. Siblings share that sphere, so they agree. The article's widget does the same thing. With the shared test, the curve never breaks. Switch to own bounds, and three holes open at once. Back to shared, and they close. So I built the whole hierarchy in the page. Twenty-five rocks, each choosing its own cut. The colour is the level. Raise the threshold, and every rock climbs to coarser levels, until only the top of the hierarchy is left. Thirty-two million triangles in the scene. At one pixel, the cut draws about two hundred and twenty-eight thousand. My crack test found no open edges in any cut. Zoom in, and the clusters near the camera get small. Freeze the cut and pull back. Only what was inside the old view was ever drawn. What makes Nanite fast is the other half. Clusters of triangles under thirty-two pixels go to a compute rasteriser. It writes depth and ids with one atomic, and shades each pixel once, afterwards. Nanite streams pages of groups. three-nanite streams whole levels. And it culls hidden clusters, not just hidden props. WebGL2 has no compute shaders, so none of this is there. So the win is drawing fewer triangles, not cheaper ones. Here the yellow number stays under two million. The hierarchy and its cut work in WebGL2. Cheap pixel-sized triangles still need compute. Group, lock, halve. Share the bounds. And try the demo in the article. Every source is in the full article. I'm Vertie. Bye!
Why read this
Hightop 30%Rebuilds the cluster DAG and its cut in the page with a crack test, reads the repo against Karis 2021, and separates what it copies from what it can't.
- Runs in a browser
- Interactive explanations
- Original analysis
GPUs, kernels & systemsMITPractitioner tool
How this was scored
- Is it new?
- 1 of 3: An incremental tweak
- Can I trust it?
- 2 of 3: Measures key facts from files, code or configs
- Can I run it?
- 3 of 3: Open, permissive, runs on reader hardware with instructions
- Will I understand it?
- 3 of 3: Mechanism carried by interactives built from real code or data
- Can I act on it?
- 2 of 3: A concrete recipe, numbers or comparison
- Will it last?
- 2 of 3: A reference for a year or more
- Does it affect many?
- 1 of 3: A specialist community
- Only here?
- 2 of 3: A teardown or measurement few others did
Score 71 of 100, ranked 152 of 773 rated articles. Each question is answered 0–3 by hand, and a 3 is rare. How articles are scored
On 15 November apekshik posted "I built Unreal Engine's Nanite System in threejs", with a
video of a scene whose counter reads 184,407,248 triangles while the "drawn" counter
underneath moves between 67,234 and about 1.79 million. The repository is
apekshik/three-nanite, MIT, cloned for this
piece at b730aac (15 November).
Two weeks ago I went through three.js's own meshlet pipeline, which shipped in r187 and was also called "Nanite-like". That one has the rasteriser half of Nanite and none of the hierarchy. This one is the reverse, and its author says so in a reply under the post: r187 "still picks detail per object from 6 fixed LODs", while three-nanite "does the other half: per-cluster detail from a crack-free hierarchy, and it runs on WebGL2."
That is a claim I can test without trusting anybody's video. The hierarchy is a data structure and a selection rule. So I read the 490-line runtime and the builder, read the Nanite slides it cites, and then wrote the same structure from scratch for this page: a procedural rock, clustered and simplified into a DAG in your browser, drawn as 25 copies that each choose their own cut every frame. It is further down, behind a button.
Nanite-style virtual geometry (cluster LOD) for three.js: an offline GLB preprocessor and a WebGL2 runtime that works with stock materials.
- license
- MIT
- branch
- main
- forks
- 11
- open issues
- 0
- source
- 70.7 kB
- commit date
- 2026-11-15
GitHub REST API, 2026-11-23 — branch, createdAt, description, forks, license, openIssues, pushedAt, stars, topics
Why a mesh needs more than one level of detail per object
A GPU's cost tracks the triangles it is handed, and an engine's budget is set by the screen: 1920 by 1080 is about two million pixels. Brian Karis puts Nanite's goal in one line in the SIGGRAPH 2021 course notes: "there are only so many pixels on screen. Why should we draw more triangles than pixels?"
The usual answer is discrete LODs: four or five decimated copies of each mesh and a switch by distance. The switch is per object, so a long wall or a cliff face is as detailed at its far end as at the foot of the camera. And the switch pops, because a whole object changes at once. The fix people reach for, splitting the mesh into tiles with their own LODs, cracks along the seams wherever two tiles pick different levels.
Nanite's answer is to choose detail per cluster of about 128 triangles, from a hierarchy built so that any mix of levels it allows is watertight.
Clusters, groups and the locked border
The build is a loop, and page 46 of Karis's course notes draws it better than I can:

Spelled out, as the slides give it and as meshoptimizer's clusterlod.h implements it:
- Split the source mesh into clusters of at most 128 triangles.
- Group neighbouring clusters. The vertices a group shares with any other group are locked.
- Merge each group's triangles and simplify to half, never moving a locked vertex.
- Split the simplified triangles into clusters again. Each new cluster remembers the group that produced it; each old cluster remembers the group that consumed it.
- Repeat on the new clusters until one is left.
The lock is what makes mixing levels safe. A group's outer edge is exactly the same polyline before and after simplification, so a coarse version of one group meets the fine version of its neighbour without a gap. The price is that locked edges cannot simplify. If the same edges stayed locked at every level they would pile up as dense seams (Karis calls it "dense cruft"). They don't, because the groups are re-formed at every level: an edge on a group border at level 3 is usually inside a group at level 4 and gets simplified there. That regrouping is also why the structure is a DAG and not a tree. In the slide's own example, both new clusters are parents of all four old ones.
Karis groups clusters with a graph partitioner (minimum edge cut, so as few locked edges
as possible), and the streaming slides put groups at 8 to 32 clusters. three-nanite's
builder uses meshoptimizer's WASM build for the clustering and simplification, and
writes its own grouping because the JS build lacks meshopt_partitionClusters:
heavy-edge matching on shared boundary vertices, up to about 16 clusters per group. When
edge collapse stalls on UV seams it falls back to vertex clustering (simplifySloppy)
and doubles the recorded error, as clusterlod.h does.
One rule picks the cut
Each group gets an error when it is built: how far, in mesh units, the simplified triangles can sit from the ones they replaced. At run time that error is projected to pixels from the camera. With a vertical field of view , a viewport pixels tall and a group bounding sphere of centre and radius :
Subtracting the radius measures from the nearest point the group could occupy, the worst case. Then a cluster is drawn when
for a threshold in pixels. Source clusters have no producing group (error zero)
and the last cluster has no consumer (error infinite), so each path from the root to a
leaf crosses the threshold somewhere. Page 70 of the notes writes the same test as
ParentError > threshold && ClusterError <= threshold.
Two conditions make it work, and both are enforced at build time.
- Monotonic. A group's error and its sphere are forced to be at least as large as those of every group below it. Then projected error can only grow walking up a path, each path crosses exactly once, and exactly one cluster covers each piece of surface. The slides: the parent's stored error and bounds "need to be as big as their children."
- Shared. Every cluster made by a group stores that group's error and sphere, not its own. Siblings run the same arithmetic on the same numbers and cannot disagree. No cluster has to look at its neighbour, so the test is embarrassingly parallel; Nanite runs it on the GPU with one thread per candidate.
The widget below is a hierarchy small enough to draw whole: a curve cut into 32 clusters of four segments, paired and halved five times. Move the camera along it and the cut shifts, fine near the camera and coarse at the far end. Then switch the parent test to "own bounds", where each cluster projects its parent's error from its own sphere instead of the parent's. Siblings at different distances now reach different answers, and holes open where neither the parent nor one of its children is drawn.
In one dimension a pair always becomes one cluster, so the widget's hierarchy is a tree. The rule is the same on a DAG. Recorded, it looks like this: the camera moves right, the threshold goes up to 8 px, and then the switch to own bounds opens three holes at once.
A DAG built in this page
The demo below runs the whole thing in your browser when you press the button. It generates a rock (an icosphere subdivided eight times and pushed around by seeded noise: 1,310,720 triangles, or 327,680 on a phone), builds the DAG with meshoptimizer's WASM clusterizer and simplifier, and draws 25 copies of it. Each copy picks its own cut every frame by the rule above.
What it does, in the files under components/articles/three-nanite/:
- Build (
dag.ts). Clusters of at most 128 triangles frombuildMeshlets. Groups of about 8 clusters, grown greedily from a seed by the neighbour that shares the most vertices; that grouping is mine and is simpler than either METIS or three-nanite's matching. Vertices seen by two groups are locked. Each group is simplified to half withsimplifyWithAttributesand theErrorAbsoluteflag, so the error comes back in mesh units, then re-split. Group error is the maximum of its own and its members', and its sphere encloses its members' group spheres. A group that will not simplify past 85 percent is retried at the next level and then left as a root. - Cut (
engine.ts). For each copy: the camera moved into the copy's own space, one refine-or-not bit per group, then the rule per cluster plus a frustum test on the cluster's sphere. This is the flat form Karis describes for the GPU, run on the CPU. is in CSS pixels, so it means the same thing on a phone. - Draw. Every cluster is one geometry in a
THREE.BatchedMesh, and the cut is written into a pool of 65,536 instance slots with the publicsetGeometryIdAtandsetMatrixAtcalls, and three draws the batch through its multi-draw path, which is oneWEBGL_multi_drawcall where the browser has the extension.
On my M1 Max, headless Chromium (software WebGL through SwiftShader) built the 1.31M rock in 3,679 ms: 20,683 clusters in 2,566 groups over 15 levels, down to a 78-triangle root. In Node the same build takes about 3 s, and the 327,680-triangle rock about 0.75 s. At the starting view (the demo's frame was 718 by 404 CSS pixels in a 1280-pixel-wide window) the 25 copies hold 32,768,000 triangles, and the cut draws:
| triangles drawn | clusters | share of the scene | |
|---|---|---|---|
| 0.5 px | 597,658 | 4,933 | 1.8% |
| 1 px | 227,550 | 1,896 | 0.69% |
| 2 px | 74,170 | 628 | 0.23% |
| 4 px | 25,920 | 229 | 0.08% |
| 16 px | 4,382 | 45 | 0.01% |
At 16 px all 25 copies are drawn with 4,382 triangles.
Choosing that cut took 2.2 to 2.7 ms per frame on the CPU, because the flat form tests all 20,683 clusters of every visible copy. three-nanite walks the DAG from the root instead and touches only the groups near the cut; its report puts selection at 0.4 to 1.2 ms for 96 props. The frame times SwiftShader reports say nothing about a GPU, so I don't quote them.
Before drawing anything I wrote a crack test. For 8 camera distances, 4 directions and 5 thresholds it selects the cut, collects every triangle, and counts edges used by only one triangle. The rock is closed, so a crack-free cut has none. All 160 cuts on the 327,680-triangle rock came out at zero open edges and zero monotonicity violations, with up to five levels mixed in one cut. The 1.31M rock passed the same 160. The test did find something else: up to 25 edges in a cut are shared by three or more triangles, which are folds the simplifier leaves at coarse levels. three-nanite's report saw the same thing on its props (up to 608 such edges).
Here is the demo recorded in clusters mode: an orbit, a zoom, then the cut frozen while the camera pulls back, so you can see what was chosen for the close view. Near surfaces got small clusters. Everything outside the old view, whole rocks and the parts of rocks past the frame's edges, was culled by the frustum test and never drawn. There is no back-face or occlusion test, so the far side of a visible rock is still in the cut.
And in levels mode, with swept from 0.5 to 16 px and back. Blue is the source mesh, warm colours are coarse levels, grey the top of the hierarchy.
What it does not do is most of the list below: no streaming (everything is built and
resident), no occlusion culling, no triangle budget, no textures, no visibility buffer or
software rasteriser, and the DAG is built at load instead of offline. All levels together hold
2,621,320 triangles, twice the source, and each cluster gets its own copy of its vertices
because BatchedMesh copies every geometry into its own range: 1,788,623 vertices for a
655,362-vertex rock.
What three-nanite builds
The repository has two halves.
The preprocessor (src/build.js, three-nanite build model.glb out/) runs in Node on
meshoptimizer's WASM. It merges every triangle mesh in a GLB, builds the DAG as above,
writes four discrete LODs as a baseline, and lays the file out coarsest level first, so
"everything down to level L" is a prefix of each buffer. three-nanite verify runs a
brute-force crack test from 7 camera positions at 5 thresholds. On the author's six test
props (1.85M to 1.97M triangles each, AI-generated, not in the repo) the build takes 4.1
to 6.5 s and gives about 30,000 clusters in 2,200 groups over 13 to 15 levels, per
docs/REPORT.md.
The runtime (src/clod.js, 490 lines, three as the only dependency) is where the
trick is. ClodBatch extends THREE.Mesh and sets isBatchedMesh = true, then fills
BatchedMesh's private fields (_multiDrawStarts, _multiDrawCounts, _indirectTexture,
_matricesTexture) itself. three's renderer takes it for a batched mesh and issues one
WEBGL_multi_draw call per asset, and stock materials fetch each range's instance matrix
through gl_DrawID. That is why MeshStandardMaterial works unchanged. It is also why the
README warns that a later three release can break it: tested on 0.186.1 and 0.187.0. My
demo gets the same single call through BatchedMesh's public API instead, at the cost of
copying vertices per cluster and paying three's per-instance bookkeeping.
ClodSelector.select() walks the group DAG from the root per instance, with frustum tests
on groups and clusters, and the same two-sided test as mine
(gF[o + 4] * K > t * d means "still too coarse, refine"). Beside that it has a budget, streaming and occlusion culling, and my demo has none of
them:
- A scene-wide triangle budget. A priority queue over (instance, group) pairs starts from every prop's coarsest cut and refines the worst projected error first until the budget is spent. Because it refines in strictly decreasing error, the result equals some single global threshold, so the cut is still crack-free. The report has it holding a 300k budget at 300,000 to 300,900 triangles over a 300-frame flight.
- Streaming. In Nanite the unit of streaming is the group: a cluster cannot be drawn
until every sibling in its group is loaded, groups are packed into 128 KB pages, the
root page is always resident, and so is the whole culling hierarchy, so traversal can see
past what is loaded and ask for everything it needs at once.
loadClodStreamkeeps the same two things resident (the hierarchy, and a root prefix of at most 96 KB) and applies the same group rule:minMemberLevelmarks a group refinable only when all its members are loaded; otherwise the selector draws the coarser cluster and records the level it wanted. Geometry then arrives by HTTP Range requests, one whole level per asset at a time, and nothing is ever evicted. - Occlusion culling, of whole instances only, against a 64 by 36 depth map read back from a frame or more earlier, with no second pass.

What the 184 million means
The counter in the post is the sum of every prop at full detail; nothing close to that is
ever drawn. The report's measured scene is 96 props of two types, 182,548,704 source
triangles in docs/bench/igpu.json, and at a 2 px threshold it draws 1.66M to 2.86M
triangles between 3 m and 50 m, and 0.25M at 300 m. The video's scene has six prop types and
184,407,248 triangles, and reading frames eight per second through the busiest stretch, the drawn counter peaks
at 1,791,044.
So "under 2 million" matches the video. It does not hold for every view of the report's
own scene, where the 300-frame flight at 2 px runs from 0.88M to 3.31M.
The rest of the post holds up against the README, with three softenings:
- "No cracks" is tested (
verify, and my own test above). "No popping" is weaker. There is no geomorphing; clusters swap instantly. The report says swaps were not visible at 1 to 2 px in captured frames, and that at high thresholds or tight budgets they are. - "Only the detail in view is streamed in" is opt-in (
?stream=1in the demo), works one whole level per asset at a time and never evicts. Nanite streams 128 KB pages of groups. - "Hidden props are culled" is whole-prop occlusion against stale depth, also opt-in
(
?occ=1), so a prop that comes into view appears a few frames late.
The half it can't copy
This is the paragraph the post itself gets right: "WebGL2 has no compute shaders, so the win here comes from drawing far fewer triangles, not from making each one cheaper."
A 1 px threshold asks for triangles about one pixel across. A hardware rasteriser is built
for bigger ones: it shades pixels in 2 by 2 quads, so a triangle that covers one pixel still
pays for four, and Karis lists "pixel quad inefficiencies from dense meshes" among the
reasons for Nanite's design. Nanite's answer is
in the same slides: clusters whose triangles have edges under 32 pixels are rasterised by
a compute shader, which Karis reports as "3x faster than hardware on average". The
compute rasteriser does its depth test with a 64-bit InterlockedMax into a visibility
buffer, depth in the high bits and the visible cluster and triangle index in the low ones,
and materials are shaded afterwards, once per pixel. The demo frame in the talk rasterises
25,041,711 triangles from 199,420 clusters.
WebGL2 has none of that: no compute, no image atomics. The report measured what that costs. On the integrated AMD GPU it used, a PBR material at 1080p cost about 8 ms per million drawn triangles, against roughly 3 ms per million for the full-density mesh, because there most triangles are smaller than a pixel and get rejected before shading. The widget below is the report's single-crate table with my arithmetic on top: screen size, triangles per pixel and the GPU time at that rate.
From 12 m out, every mode in the report draws more triangles than the crate has pixels on screen. At 200 m a 1 px cut still draws 12k triangles for a crate about 11 pixels tall. The DAG cannot go below its root cluster, and the stored error at the top is pessimistic (fallback errors are doubled), so the pixel rule alone never gets far props down to game counts. Nanite absorbs that with the software rasteriser and, for tiny instances, visibility-buffer impostors. three-nanite absorbs it with the budget mode, which on the report's 96-prop scene keeps frames at 6 to 11 ms on that GPU by letting the effective error float as high as 32 px. The cost of that is in the report's own capture:

WebGPU is where the other half could live, and parts of it already do. three's r187
VisibilityBufferDrawingPipeline, which I read for the
meshlets article, has a compute rasteriser for small
triangles and a visibility buffer, packing depth and an id into 32 bits for atomicMax
because WebGPU core has no 64-bit atomics. It picks detail per object from a flat chain of
six LODs. three-nanite's examples/webgpu.html runs the same ClodBatch under
WebGPURenderer, where, the report says from reading three's source, the backend loops
drawIndexed once per range in JavaScript.
The report measured that at 7.5 ms for 2.03M triangles in 17,000 ranges on an RTX 5090,
against 5.7 ms in WebGL2: same ballpark, not faster. Nobody has put the DAG and the
compute rasteriser in one browser renderer yet.
Nanite, stage by stage
| Stage | Nanite (Karis 2021) | three-nanite | three r187 meshlets | This page's demo |
|---|---|---|---|---|
| Clusters | 128 triangles | 128 triangles | 64, padded | 128 triangles |
| Hierarchy | DAG, groups re-formed per level, borders locked | DAG, same recipe via clusterlod.h | flat chain of 6 whole-mesh LODs | DAG, same recipe, my grouping |
| Detail chosen | per cluster, GPU, BVH over groups | per cluster, CPU DAG walk | per object, GPU | per cluster, CPU, flat test |
| Crack-free mixing | yes | yes, tested | no mixing | yes, tested |
| Rasteriser | compute for edges under 32 px, hardware above | hardware only | compute or hardware | hardware only |
| Visibility buffer | 64-bit, materials deferred | no, forward shading | 32-bit packing | no, forward shading |
| Occlusion | two-pass HZB per cluster | one pass, whole instances, stale depth | optional HZB | none |
| Streaming | 128 KB pages of groups, root page resident | whole levels by HTTP Range, no eviction | none | none, built at load |
| Budget | none: chases pixel error | scene-wide triangle budget | none | none |
| Data size | about 11.4 bytes per input triangle in the talk | about 36 bytes per input triangle | small | built in memory |
The data-size row is the one that decides most real uses. A 1.9M-triangle prop becomes about 67 MB of uncompressed hierarchy (25 MB of vertices, 42 MB of 32-bit indices), close to the source GLB's size, which the author also said in a reply. The report's own recommendation for its game was to use the builder as an automatic decimator and keep props at about 60k triangles (about 3 MB each) when the DAG is shipped.
Would I use it
For what it claims, yes. The hierarchy and the cut are right, and they are the part of Nanite that is easy to get subtly wrong: I got zero cracks only because the rule shares the parent's bounds, which the widget above shows breaking in one click. On reality-capture meshes, a few million triangles of photogrammetry per room, per-cluster detail is exactly what you want: the near wall fine, the far corner coarse, no hand-made LODs.
I would not ship it as is for anything that has to run on integrated graphics or in
Firefox. Without the software rasteriser, a pixel threshold buys you pixel-sized
triangles that the hardware handles badly, so in practice the threshold sits at 4 to 8 px
or under a budget, and at that point it is a very good continuous LOD system rather than
Nanite. The README says Firefox has no WEBGL_multi_draw, so three falls back to one draw call
per cluster, and the library has no other path yet. The private-field BatchedMesh trick will need patching on some
future three release. And the files are big.
The next step I'd want is the merge the author suggested himself: this DAG feeding three's WebGPU compute rasteriser. Until then, read the README's "What it does not do" before the video. It says more plainly than the post what is missing.
