Mesh shaders
A compute-style geometry pipeline where task and mesh stages replace input assembly and vertex processing, letting each workgroup emit its own small batch of primitives after culling.
Also known as task shaders, amplification shaders
In the family Performance, LOD & compression, pipeline stages
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Not applicable | three.js targets WebGL/WebGPU; neither API exposes mesh shaders (see meshlets for the compute-based approach). |
| Babylon.js 9.38.0 | None found | Neither WebGL2 nor standard WebGPU exposes mesh shader stages to Babylon.js. |
| Godot 4.7 | None found | |
| Unity | None found | |
| Unreal 5.7 | Built in | Nanite virtualized meshlet rasterizer & RHI mesh shader pipeline docs |
| Blender 5.2 | None found | |
| WebGPU W3C | Not applicable | WebGPU has no mesh or task shader stages; emulate with compute plus indirect draws. |
| Metal | Built in | MTLMeshRenderPipelineDescriptor (objectFunction, meshFunction) docs |
How it works
A task (amplification) shader runs one thread per candidate meshlet, performs frustum, cone and occlusion tests, and launches mesh workgroups only for visible ones. Each mesh shader workgroup loads its meshlet's vertices and micro indices from buffers, transforms them cooperatively, and writes vertex and primitive outputs straight to the rasterizer, bypassing fixed-function index fetch.
The model removes the vertex cache dependency and lets the shader generate geometry procedurally or decompress it on the fly. Output limits per workgroup are small, so meshlets are built to fit them.
When to choose it
Reach for it when
- vertex pipeline wastes work on culled geometry
- want per-cluster culling inside the draw
- huge meshlet scenes need flexible geometry stage
- replace input assembly for gpu-driven geometry
Choose it on hardware with native support when you already have Meshlets (cluster rendering) and want per-cluster culling without a separate compute pass. Prefer classic indirect draws from GPU-driven rendering on older GPUs or WebGL2, or where the extension is missing. Prefer Nanite virtualized geometry style software raster for triangles smaller than a pixel.
Field marks
- Not portable: unavailable on older GPUs and absent from WebGL2
- Wrong meshlet sizing underutilizes a vendor's hardware
- Debugging and tooling support is weaker than for vertex pipelines
- Tiny triangles still rasterize inefficiently in hardware
Presets
Mesh Shaders — meshlet clusters & normal-cone backface culling (left) vs shaded mesh (right)
{
"P_CLUSTER_DENS": 4.5,
"P_CONE_THRESH": 0.22,
"P_ROT_SPEED": 0.8,
"P_SPLIT": 0.5
}Show GLSL (144 lines)
const float P_CLUSTER_DENS = 4.5; // P Meshlet Density [2.5, 8.0, 0.25]
const float P_CONE_THRESH = 0.22; // P Cone Cull Bias [0.0, 0.65, 0.02]
const float P_ROT_SPEED = 0.80; // P Spin Speed [0.0, 2.2, 0.05]
const float P_SPLIT = 0.50; // P Meshlets / Lit Split [0.0, 1.0, 0.02]
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 high-detail organic torus + grooved core showcasing dense triangle meshlets
float mapMesh(vec3 p, float spin) {
vec3 q = p;
q.xz = rot2(spin * 0.65) * q.xz;
q.xy = rot2(spin * 0.35 + 0.35) * q.xy;
vec2 t = vec2(length(q.xz) - 0.56, q.y);
float dTor = length(t) - 0.26 - 0.035 * sin(atan(q.z, q.x) * 6.0 + atan(q.y, t.x) * 3.0);
float dCore = length(q) - 0.34;
return min(dTor, dCore);
}
vec3 calcNormal(vec3 p, float spin) {
vec2 e = vec2(0.0022, 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 partition in object space returning (borderDist, cellID)
vec4 evalMeshlet(vec3 objP, float dens) {
vec3 gp = objP * dens;
vec3 cell = floor(gp);
vec3 f = fract(gp);
float d1 = 1e5;
float d2 = 1e5;
vec3 bestId = vec3(0.0);
vec3 bestCenter = vec3(0.0);
for (int dz = -1; dz <= 1; dz++) {
for (int dy = -1; dy <= 1; dy++) {
for (int dx = -1; dx <= 1; dx++) {
vec3 nb = vec3(float(dx), float(dy), float(dz));
vec3 cid = cell + nb;
vec3 rnd = hash33(cid);
vec3 pt = nb + 0.15 + 0.70 * rnd;
float d = length(f - pt);
if (d < d1) {
d2 = d1;
d1 = d;
bestId = cid;
bestCenter = (cid + 0.15 + 0.70 * rnd) / dens;
} else if (d < d2) {
d2 = d;
}
}
}
}
return vec4(d2 - d1, bestId);
}
vec3 meshletPalette(vec3 id) {
vec3 h = hash33(id + 7.13);
float ang = h.x * 6.2831853;
return 0.52 + 0.42 * cos(ang + vec3(0.0, 2.094, 4.188));
}
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 screenX = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
bool isLit = screenX >= split;
float dens = clamp(P_CLUSTER_DENS, 2.0, 9.0);
float coneBias = clamp(P_CONE_THRESH, 0.0, 0.70);
float spin = iTime * max(P_ROT_SPEED, 0.0);
vec3 ro = vec3(0.0, 0.04, 2.38);
vec3 rd = normalize(vec3(uv, -1.55));
vec3 col = mix(vec3(0.026, 0.036, 0.058), vec3(0.068, 0.088, 0.135), smoothstep(-0.55, 0.55, uv.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 * 0.85;
if (t > 7.0) break;
}
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p, spin);
// Transform hit point back to object space so meshlets stick rigidly to the mesh
vec3 objP = p;
objP.xz = rot2(spin * 0.65) * objP.xz;
objP.xy = rot2(spin * 0.35 + 0.35) * objP.xy;
vec4 mInfo = evalMeshlet(objP, dens);
float seam = smoothstep(0.065, 0.014, mInfo.x);
vec3 mCol = meshletPalette(mInfo.yzw);
// Sub-meshlet triangle wireframe (64-tri cluster tessellation pattern)
vec3 tf = abs(fract(objP * dens * 4.5 - 0.5) - 0.5);
float triWire = smoothstep(0.055, 0.012, min(min(tf.x, tf.y), tf.z));
// Task-shader normal-cone backface culling test: dot(viewDir, coneAxis) < sin(coneAngle)
float ndv = max(dot(n, -rd), 0.0);
float nearSilhouette = smoothstep(coneBias + 0.12, coneBias, ndv);
vec3 l1 = normalize(vec3(0.58, 0.82, 0.55));
vec3 l2 = normalize(vec3(-0.70, -0.25, 0.45));
float diff = max(dot(n, l1), 0.0) * 0.85 + max(dot(n, l2), 0.0) * 0.25;
float spec = pow(max(dot(n, normalize(l1 - rd)), 0.0), 48.0);
if (!isLit) {
// Left: Task/Mesh shader cluster view showing color-coded 64-tri meshlets & grazing cone-cull margin
col = mCol * (0.34 + 0.76 * diff) + vec3(0.85) * spec * 0.25;
col = mix(col, vec3(0.04, 0.06, 0.10), triWire * 0.28);
col = mix(col, vec3(0.96, 0.98, 1.0), seam * 0.85);
// Tint grazing meshlets approaching the backface-cone culling horizon in bright crimson
col = mix(col, vec3(0.98, 0.20, 0.24), nearSilhouette * 0.65);
} else {
// Right: Final lit brushed alloy surface with subtle meshlet boundary gleam
vec3 alloy = vec3(0.68, 0.74, 0.82);
col = alloy * (0.22 + 0.88 * diff) + vec3(0.98, 0.94, 0.88) * spec * 0.65;
col += mCol * seam * 0.16;
}
}
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.97, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| mesh-shaders-live | Tesla T4 1920x1080 | 39.4× baseline (heavy) · 1.22 ms / 1.27 ms | opengl-timer-query · 36 frames · GPU Weight Atlas · Colab T4 sweep |
| mesh-shaders-live | NVIDIA L4 1920x1080 | 31.1× baseline (heavy) · 0.495 ms / 0.512 ms · 2.5× faster on L4 | opengl-timer-query · Cross-architecture validation |
| mesh-shaders-live | NVIDIA A100-SXM4-40GB 1920x1080 | 22.9× baseline (heavy) · 0.659 ms / 0.687 ms · 1.9× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Mesh-shader amplified geometry clipmaps with zero CPU draw calls: Concentric terrain clipmap rings generated and frustum-culled directly inside GPU task and mesh shaders eliminate CPU footprint updates, index-buffer stitching tables, and T-junction seam skirts across continental draw distances.
- Meshlets (cluster rendering): Meshlet buffers with bounds and micro indices are what task and mesh stages read.
Sources
- primaryChristoph Kubisch. Introduction to Turing Mesh Shaders. developer.nvidia.com.Verified via live page · 2026-11-29
- implementationzeux (2016). zeux/meshoptimizer. Mesh optimization library that makes meshes smaller and faster to renderGitHub API · license MIT · 2026-11-29