Meshlets (cluster rendering)
Partition a mesh into small clusters of up to a few dozen vertices and about a hundred triangles, each with bounds and a normal cone, so the GPU can cull and draw them as independent units.
Also known as clusters, mesh clusters
In the family Performance, LOD & compression, cluster rendering
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { createMeshlets } from 'three/addons/utils/MeshletGeometryUtils.js' docs WebGPU meshlet examples built on meshoptimizer. |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | |
| Unity | None found | Not available; GPU Resident Drawer batches instances but does not cluster meshes. |
| Unreal 5.7 | Built in | Nanite encodes Static Meshes into hierarchical triangle clusters (meshlets) for per-cluster culling and LOD docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | Built in | MTLMeshRenderPipelineDescriptor (objectFunction + meshFunction cluster shading pipeline) docs |
How it works
An offline builder walks the triangle list and greedily grows clusters that stay within a vertex and triangle limit, preferring triangles that share vertices and are spatially close. Each meshlet gets a local vertex list referencing the global buffer, a micro index buffer with byte-sized indices, a bounding sphere, and a normal cone describing the range of facing directions.
At runtime a compute or task shader tests every meshlet against the frustum, the cone against the view direction, and optionally a depth pyramid. Survivors are drawn through a mesh shader or by software expansion into an index buffer. Because clusters are small and uniform, they also serve as the unit of LOD selection and streaming.
When to choose it
Reach for it when
- cull geometry at finer level than whole objects
- split large meshes for gpu processing in small clusters
- need data layout for cluster lod
- back-face cull groups of triangles together
- prepare meshes for mesh shaders
Choose it as the data layout for GPU-driven culling at sub-object granularity or as input to a cluster LOD scheme. Prefer Mesh shaders for the hardware path that consumes meshlets directly. Prefer whole-object culling in GPU-driven rendering when meshes are small or few, since meshlet overhead then buys nothing.
Field marks
- Poorly sized meshlets waste lanes on some GPUs, since optimal limits differ between vendors
- Normal cone culling is weak on curved or noisy meshes and can reject nothing
- Rebuilt clusters of skinned or deforming meshes have stale bounds unless inflated
- Thin or scattered geometry produces many tiny underfilled meshlets
Presets
meshoptimizer meshlet build limits
{
"max_vertices": 64,
"max_triangles": 126,
"cone_weight": 0
}Attribution: Values from the meshoptimizer README for NVIDIA GPUs (MIT license); raise cone_weight toward 0.25 if cone culling is used. · basis: 0
Meshlets — 3D cluster partitioning & normal-cone backface culling visualization
{
"P_CLUSTER_SIZE": 6,
"P_CONE_CULL": 0.75,
"P_WIRE_ALPHA": 0.75,
"P_ROT_SPEED": 1
}Show GLSL (146 lines)
const float P_CLUSTER_SIZE = 6.0; // P Meshlet Scale [3.0, 12.0, 0.25]
const float P_CONE_CULL = 0.75; // P Normal-Cone Cull [0.0, 1.0, 0.02]
const float P_WIRE_ALPHA = 0.75; // P Cluster Seams [0.0, 1.5, 0.05]
const float P_ROT_SPEED = 1.0; // P Orbit Speed [0.0, 2.5, 0.05]
mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }
vec3 hash33(vec3 p) {
p = fract(p * vec3(0.1031, 0.1030, 0.0973));
p += dot(p, p.yxz + 33.33);
return fract((p.xxy + p.yxx) * p.zyx);
}
// Sculpted organic-mechanical knot for meshlet clustering
float mapMesh(vec3 p, float spin) {
vec3 q = p;
q.xz = rot2(spin * 0.42) * q.xz;
q.yz = rot2(0.32 + 0.15 * sin(spin * 0.5)) * q.yz;
float ang = atan(q.z, q.x);
float rMaj = 0.72 + 0.10 * cos(ang * 3.0);
vec2 tq = vec2(length(q.xz) - rMaj, q.y + 0.10 * sin(ang * 3.0));
float dT = length(tq) - 0.30;
float dS = length(q) - 0.34;
// Smooth union between core and trefoil ring
float k = 0.16;
float h = clamp(0.5 + 0.5 * (dS - dT) / k, 0.0, 1.0);
return (mix(dS, dT, h) - k * h * (1.0 - h)) * 0.85;
}
vec3 calcNormal(vec3 p, float spin) {
vec2 e = vec2(0.0025, 0.0);
return normalize(vec3(
mapMesh(p + e.xyy, spin) - mapMesh(p - e.xyy, spin),
mapMesh(p + e.yxy, spin) - mapMesh(p - e.yxy, spin),
mapMesh(p + e.yyx, spin) - mapMesh(p - e.yyx, spin)
));
}
// 3D Voronoi meshlet assignment returning (clusterCenterObjSpace, seamDist, clusterHash)
void evalMeshlet(vec3 objP, float scale, out vec3 centerObj, out float seam, out vec3 mCol) {
vec3 sp = objP * scale;
vec3 n = floor(sp);
vec3 f = fract(sp);
float d1 = 8.0, d2 = 8.0;
vec3 bestCell = vec3(0.0);
vec3 bestSite = vec3(0.0);
for (int z = -1; z <= 1; z++) {
for (int y = -1; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
vec3 g = vec3(float(x), float(y), float(z));
vec3 o = hash33(n + g);
vec3 r = g + o - f;
float d = dot(r, r);
if (d < d1) {
d2 = d1;
d1 = d;
bestCell = n + g;
bestSite = (n + g + o) / scale;
} else if (d < d2) {
d2 = d;
}
}
}
}
centerObj = bestSite;
seam = sqrt(d2) - sqrt(d1);
vec3 h = hash33(bestCell * 1.9 + 7.3);
// Crisp categorical meshlet palette
mCol = 0.24 + 0.72 * h;
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float spin = iTime * max(P_ROT_SPEED, 0.0);
float scale = clamp(P_CLUSTER_SIZE, 2.5, 14.0);
float cullDemo = clamp(P_CONE_CULL, 0.0, 1.0);
float wireAmt = clamp(P_WIRE_ALPHA, 0.0, 1.5);
vec3 ro = vec3(0.0, 0.15, 2.55);
vec3 rd = normalize(vec3(uv, -1.5));
vec3 col = mix(vec3(0.035, 0.045, 0.07), vec3(0.095, 0.115, 0.16), smoothstep(-0.55, 0.55, uv.y));
vec2 bgG = abs(fract(uv * 10.0 - 0.5) - 0.5);
col += vec3(0.02, 0.03, 0.045) * smoothstep(0.03, 0.0, min(bgG.x, bgG.y));
float t = 0.0;
bool hit = false;
for (int i = 0; i < 64; i++) {
float d = mapMesh(ro + rd * t, spin);
if (d < 0.002) { hit = true; break; }
t += d;
if (t > 9.0) break;
}
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p, spin);
// Transform into object space so meshlet IDs stay rigidly attached to the mesh
vec3 objP = p;
objP.xz = rot2(spin * 0.42) * objP.xz;
objP.yz = rot2(0.32 + 0.15 * sin(spin * 0.5)) * objP.yz;
vec3 centerObj;
float seam;
vec3 mCol;
evalMeshlet(objP, scale, centerObj, seam, mCol);
// Compute meshlet bounding normal-cone test against a side-mounted "main camera" frustum
// so the viewer can see which meshlets are front-facing vs backface-culled by the cone test!
vec3 virtualView = normalize(vec3(0.75 * cos(spin * 0.25), 0.22, 0.72));
// Transform cluster center back to approximate world normal direction
vec3 cWorld = centerObj;
cWorld.yz = rot2(-(0.32 + 0.15 * sin(spin * 0.5))) * cWorld.yz;
cWorld.xz = rot2(-spin * 0.42) * cWorld.xz;
vec3 coneAxis = calcNormal(cWorld, spin);
float coneDot = dot(coneAxis, virtualView);
// Meshlet normal cone cutoff (-sin(halfAngle))
float coneCulled = smoothstep(0.18, -0.05, coneDot) * cullDemo;
vec3 l1 = normalize(vec3(0.65, 0.85, 0.55));
float diff = max(dot(n, l1), 0.0);
vec3 hVec = normalize(l1 - rd);
float spec = pow(max(dot(n, hVec), 0.0), 32.0) * 0.38;
float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0) * 0.30;
// Active surviving meshlet shading
vec3 activeCol = mCol * (0.28 + 0.80 * diff) + vec3(spec) + vec3(0.45, 0.68, 1.0) * rim;
float seamEdge = smoothstep(0.085, 0.015, seam);
activeCol = mix(activeCol, vec3(0.04, 0.05, 0.08), seamEdge * 0.78 * min(wireAmt, 1.2));
// Normal-cone culled meshlet appearance: translucent hatched crimson wireframe
float hatch = smoothstep(0.4, 0.8, sin((uv.x + uv.y) * 90.0));
vec3 culledCol = mix(vec3(0.14, 0.05, 0.08), vec3(0.95, 0.22, 0.36), max(seamEdge * 0.9, hatch * 0.22));
culledCol += vec3(0.95, 0.25, 0.42) * rim * 0.65;
col = mix(activeCol, culledCol, coneCulled);
}
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| meshlets-live | Tesla T4 1920x1080 | 35.6× baseline (heavy) · 1.12 ms / 1.14 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| meshlets-live | NVIDIA L4 1920x1080 | 30.1× baseline (heavy) · 0.476 ms / 0.506 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| meshlets-live | NVIDIA A100-SXM4-40GB 1920x1080 | 21.9× baseline (heavy) · 0.630 ms / 0.675 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Meshlet foliage with compute-rasterized atomic spores: A split-path renderer for dense botanical worlds: macroscopic trunks and leaves flow through GPU-driven meshlets, while millions of sub-pixel drifting spores, pollen grains, and distant needle points bypass hardware triangle setup altogether via lock-free 64-bit compute atomics occluded against the meshlet depth buffer.
- Meshlet kelp forests through underwater PSF scattering: Dense swaying kelp forests rendered at millions of triangles without CPU draw-call overhead, then veiled in physically grounded underwater forward scattering. Caustic shafts light the blades while a depth-varying small-angle point-spread filter softens distant fronds into authentic oceanic haze instead of flat exponential fog.
- Hierarchical-Z occlusion culling: Per-meshlet bounding spheres are tested against the depth pyramid to skip hidden clusters before rasterization.
Sources
- primaryzeux (2016). zeux/meshoptimizer. Mesh optimization library that makes meshes smaller and faster to renderGitHub API · license MIT · 2026-11-29