{
 "id": "meshlets",
 "title": "Meshlets (cluster rendering)",
 "aliases": [
  "clusters",
  "mesh clusters"
 ],
 "domain": "performance",
 "subdomain": "cluster rendering",
 "stage": "performance",
 "realtime": "realtime",
 "platforms": [
  "webgpu",
  "desktop-gpu",
  "unreal"
 ],
 "year_introduced": 2018,
 "inputs": [
  "mesh"
 ],
 "outputs": [
  "mesh"
 ],
 "style": "both",
 "dynamic": "both",
 "summary": "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.",
 "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.\n\nAt 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_use": "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.",
 "cost": {
  "class": "cheap",
  "notes": "Culling cost scales with meshlet count, not triangles; extra memory for bounds and micro indices."
 },
 "failure_modes": [
  "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "gh:zeux/meshoptimizer",
   "type": "code",
   "title": "zeux/meshoptimizer",
   "description": "Mesh optimization library that makes meshes smaller and faster to render",
   "authors": [
    "zeux"
   ],
   "year": 2016,
   "venue": "GitHub",
   "url": "https://github.com/zeux/meshoptimizer",
   "ids": {
    "repo": "zeux/meshoptimizer"
   },
   "license": "MIT",
   "extra": {
    "stars": 8972,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-29T00:55:16Z",
    "language": "C++",
    "homepage": "https://meshoptimizer.org/",
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zeux/meshoptimizer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zeux/meshoptimizer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zeux/meshoptimizer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zeux/meshoptimizer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zeux/meshoptimizer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zeux/meshoptimizer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "zeux2016zeux"
  },
  {
   "role": "tutorial",
   "key": "url:https://zeux.io/2023/01/16/meshlet-size-tradeoffs",
   "type": "tutorial",
   "title": "Meshlet size tradeoffs",
   "authors": [
    "Arseny Kapoulkine"
   ],
   "year": null,
   "venue": "zeux.io",
   "url": "https://zeux.io/2023/01/16/meshlet-size-tradeoffs",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20260901002804/https://zeux.io/2023/01/16/meshlet-size-tradeoffs/",
     "timestamp": "20260901002804"
    },
    "page_title": "Meshlet size tradeoffs",
    "host": "zeux.io",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://zeux.io/2023/01/16/meshlet-size-tradeoffs → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://zeux.io/2023/01/16/meshlet-size-tradeoffs → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://zeux.io/2023/01/16/meshlet-size-tradeoffs → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "kapoulkinemeshlet"
  }
 ],
 "presets": [
  {
   "id": "meshlets-nvidia-64-126",
   "title": "meshoptimizer meshlet build limits",
   "runtime": "json-params",
   "params": {
    "max_vertices": 64,
    "max_triangles": 126,
    "cone_weight": 0
   },
   "basis": "0",
   "license_note": "Values from the meshoptimizer README for NVIDIA GPUs (MIT license); raise cone_weight toward 0.25 if cone culling is used.",
   "execution_fidelity": "parameter-only",
   "proof": {
    "kind": "parameter",
    "label": "parameter preset",
    "ok": true,
    "proof": null
   }
  },
  {
   "id": "meshlets-live",
   "title": "Meshlets — 3D cluster partitioning & normal-cone backface culling visualization",
   "runtime": "glsl-fragment",
   "params": {
    "P_CLUSTER_SIZE": 6,
    "P_CONE_CULL": 0.75,
    "P_WIRE_ALPHA": 0.75,
    "P_ROT_SPEED": 1
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_CLUSTER_SIZE = 6.0; // P Meshlet Scale [3.0, 12.0, 0.25]\nconst float P_CONE_CULL = 0.75; // P Normal-Cone Cull [0.0, 1.0, 0.02]\nconst float P_WIRE_ALPHA = 0.75; // P Cluster Seams [0.0, 1.5, 0.05]\nconst float P_ROT_SPEED = 1.0; // P Orbit Speed [0.0, 2.5, 0.05]\n\nmat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }\n\nvec3 hash33(vec3 p) {\n  p = fract(p * vec3(0.1031, 0.1030, 0.0973));\n  p += dot(p, p.yxz + 33.33);\n  return fract((p.xxy + p.yxx) * p.zyx);\n}\n\n// Sculpted organic-mechanical knot for meshlet clustering\nfloat mapMesh(vec3 p, float spin) {\n  vec3 q = p;\n  q.xz = rot2(spin * 0.42) * q.xz;\n  q.yz = rot2(0.32 + 0.15 * sin(spin * 0.5)) * q.yz;\n  float ang = atan(q.z, q.x);\n  float rMaj = 0.72 + 0.10 * cos(ang * 3.0);\n  vec2 tq = vec2(length(q.xz) - rMaj, q.y + 0.10 * sin(ang * 3.0));\n  float dT = length(tq) - 0.30;\n  float dS = length(q) - 0.34;\n  // Smooth union between core and trefoil ring\n  float k = 0.16;\n  float h = clamp(0.5 + 0.5 * (dS - dT) / k, 0.0, 1.0);\n  return (mix(dS, dT, h) - k * h * (1.0 - h)) * 0.85;\n}\n\nvec3 calcNormal(vec3 p, float spin) {\n  vec2 e = vec2(0.0025, 0.0);\n  return normalize(vec3(\n    mapMesh(p + e.xyy, spin) - mapMesh(p - e.xyy, spin),\n    mapMesh(p + e.yxy, spin) - mapMesh(p - e.yxy, spin),\n    mapMesh(p + e.yyx, spin) - mapMesh(p - e.yyx, spin)\n  ));\n}\n\n// 3D Voronoi meshlet assignment returning (clusterCenterObjSpace, seamDist, clusterHash)\nvoid evalMeshlet(vec3 objP, float scale, out vec3 centerObj, out float seam, out vec3 mCol) {\n  vec3 sp = objP * scale;\n  vec3 n = floor(sp);\n  vec3 f = fract(sp);\n  float d1 = 8.0, d2 = 8.0;\n  vec3 bestCell = vec3(0.0);\n  vec3 bestSite = vec3(0.0);\n  for (int z = -1; z <= 1; z++) {\n    for (int y = -1; y <= 1; y++) {\n      for (int x = -1; x <= 1; x++) {\n        vec3 g = vec3(float(x), float(y), float(z));\n        vec3 o = hash33(n + g);\n        vec3 r = g + o - f;\n        float d = dot(r, r);\n        if (d < d1) {\n          d2 = d1;\n          d1 = d;\n          bestCell = n + g;\n          bestSite = (n + g + o) / scale;\n        } else if (d < d2) {\n          d2 = d;\n        }\n      }\n    }\n  }\n  centerObj = bestSite;\n  seam = sqrt(d2) - sqrt(d1);\n  vec3 h = hash33(bestCell * 1.9 + 7.3);\n  // Crisp categorical meshlet palette\n  mCol = 0.24 + 0.72 * h;\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float spin = iTime * max(P_ROT_SPEED, 0.0);\n  float scale = clamp(P_CLUSTER_SIZE, 2.5, 14.0);\n  float cullDemo = clamp(P_CONE_CULL, 0.0, 1.0);\n  float wireAmt = clamp(P_WIRE_ALPHA, 0.0, 1.5);\n\n  vec3 ro = vec3(0.0, 0.15, 2.55);\n  vec3 rd = normalize(vec3(uv, -1.5));\n\n  vec3 col = mix(vec3(0.035, 0.045, 0.07), vec3(0.095, 0.115, 0.16), smoothstep(-0.55, 0.55, uv.y));\n  vec2 bgG = abs(fract(uv * 10.0 - 0.5) - 0.5);\n  col += vec3(0.02, 0.03, 0.045) * smoothstep(0.03, 0.0, min(bgG.x, bgG.y));\n\n  float t = 0.0;\n  bool hit = false;\n  for (int i = 0; i < 64; i++) {\n    float d = mapMesh(ro + rd * t, spin);\n    if (d < 0.002) { hit = true; break; }\n    t += d;\n    if (t > 9.0) break;\n  }\n\n  if (hit) {\n    vec3 p = ro + rd * t;\n    vec3 n = calcNormal(p, spin);\n\n    // Transform into object space so meshlet IDs stay rigidly attached to the mesh\n    vec3 objP = p;\n    objP.xz = rot2(spin * 0.42) * objP.xz;\n    objP.yz = rot2(0.32 + 0.15 * sin(spin * 0.5)) * objP.yz;\n\n    vec3 centerObj;\n    float seam;\n    vec3 mCol;\n    evalMeshlet(objP, scale, centerObj, seam, mCol);\n\n    // Compute meshlet bounding normal-cone test against a side-mounted \"main camera\" frustum\n    // so the viewer can see which meshlets are front-facing vs backface-culled by the cone test!\n    vec3 virtualView = normalize(vec3(0.75 * cos(spin * 0.25), 0.22, 0.72));\n    // Transform cluster center back to approximate world normal direction\n    vec3 cWorld = centerObj;\n    cWorld.yz = rot2(-(0.32 + 0.15 * sin(spin * 0.5))) * cWorld.yz;\n    cWorld.xz = rot2(-spin * 0.42) * cWorld.xz;\n    vec3 coneAxis = calcNormal(cWorld, spin);\n    float coneDot = dot(coneAxis, virtualView);\n    // Meshlet normal cone cutoff (-sin(halfAngle))\n    float coneCulled = smoothstep(0.18, -0.05, coneDot) * cullDemo;\n\n    vec3 l1 = normalize(vec3(0.65, 0.85, 0.55));\n    float diff = max(dot(n, l1), 0.0);\n    vec3 hVec = normalize(l1 - rd);\n    float spec = pow(max(dot(n, hVec), 0.0), 32.0) * 0.38;\n    float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0) * 0.30;\n\n    // Active surviving meshlet shading\n    vec3 activeCol = mCol * (0.28 + 0.80 * diff) + vec3(spec) + vec3(0.45, 0.68, 1.0) * rim;\n    float seamEdge = smoothstep(0.085, 0.015, seam);\n    activeCol = mix(activeCol, vec3(0.04, 0.05, 0.08), seamEdge * 0.78 * min(wireAmt, 1.2));\n\n    // Normal-cone culled meshlet appearance: translucent hatched crimson wireframe\n    float hatch = smoothstep(0.4, 0.8, sin((uv.x + uv.y) * 90.0));\n    vec3 culledCol = mix(vec3(0.14, 0.05, 0.08), vec3(0.95, 0.22, 0.36), max(seamEdge * 0.9, hatch * 0.22));\n    culledCol += vec3(0.95, 0.25, 0.42) * rim * 0.65;\n\n    col = mix(activeCol, culledCol, coneCulled);\n  }\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "meshlets",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T19:04:34.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6011,
      "std": 0.1791,
      "min": 0.2251,
      "max": 0.9199
     },
     "image": "/specimens/meshlets-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "mesh-shaders",
  "nanite-virtualized-geometry",
  "meshoptimizer"
 ],
 "extends": [
  "gpu-driven-rendering"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "hierarchical-z-occlusion-culling",
   "why": "Per-meshlet bounding spheres are tested against the depth pyramid to skip hidden clusters before rasterization."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/performance/meshlets.json"
 },
 "solves": [
  "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"
 ],
 "authority": "zeux, 2016",
 "url": "https://texelatlas.vercel.app/t/meshlets/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 35.62,
  "tier": "heavy",
  "p50_ms": 1.1186,
  "p95_ms": 1.1418,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "meshlets-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 30.14,
   "tier": "heavy",
   "p50_ms": 0.4762,
   "p95_ms": 0.5057,
   "speedup_x": 2.35,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 21.87,
   "tier": "heavy",
   "p50_ms": 0.6299,
   "p95_ms": 0.675,
   "speedup_x": 1.78,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}