{
 "id": "nanite-virtualized-geometry",
 "title": "Nanite virtualized geometry",
 "aliases": [
  "Nanite",
  "virtualized geometry",
  "cluster LOD"
 ],
 "domain": "performance",
 "subdomain": "virtualized geometry",
 "stage": "performance",
 "realtime": "realtime",
 "platforms": [
  "unreal",
  "desktop-gpu"
 ],
 "year_introduced": 2021,
 "inputs": [
  "mesh"
 ],
 "outputs": [
  "gbuffer",
  "depth"
 ],
 "style": "both",
 "dynamic": "both",
 "summary": "Unreal Engine's system that builds a hierarchy of triangle clusters per mesh and selects them per frame by screen-space error, giving effectively continuous LOD with a hybrid hardware and software rasterizer.",
 "how_it_works": "Offline, the mesh is split into clusters and repeatedly simplified: groups of clusters are merged, simplified while locking their boundary, and split again, building a DAG of levels. Each group stores its error, so neighbours always agree on border vertices and no cracks appear.\n\nAt runtime a GPU traversal picks the cut through the DAG where projected error falls under about a pixel, culls clusters against frustum and a depth pyramid, and streams pages on demand. Large triangles use hardware raster; pixel-sized ones go to a compute rasterizer writing a visibility buffer, resolved to materials later.",
 "when_to_use": "Choose it for static, very high-polygon assets where artists should not author LODs. Prefer `meshlets` with a simpler discrete LOD chain or `octahedral-impostors` when targeting WebGL or mobile. Prefer ordinary skinned LOD for deforming characters, which the original system does not handle well.",
 "cost": {
  "class": "heavy",
  "notes": "Large fixed cost for streaming, culling and visibility-buffer resolve; scales with pixels rather than triangles."
 },
 "failure_modes": [
  "Poor support for skinning, tessellation and heavy deformation in early versions",
  "Masked or foliage materials cause overdraw and shader cost in the visibility pass",
  "Large storage and streaming demands",
  "Not portable outside engines that implement the whole stack"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://advances.realtimerendering.com/s2021/index.html",
   "type": "web",
   "title": "Global Illumination Based on Surfels",
   "authors": [
    "Henrik Halen",
    "Andreas Brinck",
    "Kyle Hayward",
    "Xiangshun Bei"
   ],
   "year": null,
   "venue": "SIGGRAPH 2021 Advances in Real-Time Rendering",
   "url": "https://advances.realtimerendering.com/s2021/index.html",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261107170833/https://advances.realtimerendering.com/s2021/index.html",
     "timestamp": "20261107170833"
    },
    "page_title": null,
    "host": "advances.realtimerendering.com",
    "title_confirmed_by_page": false,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://advances.realtimerendering.com/s2021/index.html → 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": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "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": null,
   "__bib": "halenglobal"
  },
  {
   "role": "implementation",
   "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"
  }
 ],
 "presets": [
  {
   "id": "nanite-virtualized-geometry-live",
   "title": "Nanite virtualized geometry — screen-space error DAG cluster hierarchy vs shaded micro-polygons",
   "runtime": "glsl-fragment",
   "params": {
    "P_PIXEL_ERROR": 1,
    "P_CLUSTER_SCALE": 8,
    "P_RELIEF_DETAIL": 1,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_PIXEL_ERROR = 1.0; // P Error Threshold [0.35, 2.5, 0.05]\nconst float P_CLUSTER_SCALE = 8.0; // P Cluster Density [4.0, 16.0, 0.5]\nconst float P_RELIEF_DETAIL = 1.0; // P Micro-Relief [0.0, 2.0, 0.05]\nconst float P_SPLIT = 0.48; // P Shaded / Cluster Split [0.0, 1.0, 0.02]\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// High-detail sculpted baroque manifold (ornate fluted torus + central obelisk)\nfloat mapSculpt(vec3 p, float relief) {\n  vec3 q = p - vec3(0.0, 0.02, 0.0);\n  q.xz = rot2(iTime * 0.32) * q.xz;\n  q.xy = rot2(0.38) * q.xy;\n\n  float theta = atan(q.z, q.x);\n  vec2 tq = vec2(length(q.xz) - 0.72, q.y);\n  float phi = atan(tq.y, tq.x);\n  float flutes = 0.032 * sin(phi * 10.0 + theta * 4.0) + 0.014 * cos(theta * 16.0 - phi * 6.0);\n  float dTorus = length(tq) - (0.28 + flutes * relief);\n\n  // Inner carved faceted core\n  vec3 c = q;\n  float dCore = length(c) - (0.30 + 0.022 * sin(c.x * 22.0) * cos(c.y * 22.0) * sin(c.z * 22.0) * relief);\n\n  // Pedestal floor with micro-grooves\n  float dFloor = p.y + 0.88 - 0.008 * sin(p.x * 18.0) * cos(p.z * 18.0) * relief;\n\n  return min(min(dTorus, dCore) * 0.78, dFloor);\n}\n\nvec3 calcNormal(vec3 p, float relief) {\n  vec2 e = vec2(0.002, 0.0);\n  return normalize(vec3(\n    mapSculpt(p + e.xyy, relief) - mapSculpt(p - e.xyy, relief),\n    mapSculpt(p + e.yxy, relief) - mapSculpt(p - e.yxy, relief),\n    mapSculpt(p + e.yyx, relief) - mapSculpt(p - e.yyx, relief)\n  ));\n}\n\n// 3D Voronoi cluster partitioning simulating Nanite 128-triangle cluster DAG at given LOD scale\nvec4 evalClusterDAG(vec3 p, float scale) {\n  vec3 sp = p * scale;\n  vec3 n = floor(sp);\n  vec3 f = fract(sp);\n  float d1 = 8.0;\n  float d2 = 8.0;\n  vec3 bestId = 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          bestId = n + g;\n        } else if (d < d2) {\n          d2 = d;\n        }\n      }\n    }\n  }\n  float seam = sqrt(d2) - sqrt(d1);\n  vec3 colId = hash33(bestId * 1.7 + 13.1);\n  return vec4(colId, seam);\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 screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  float errThr = clamp(P_PIXEL_ERROR, 0.3, 3.0);\n  float clScale = clamp(P_CLUSTER_SCALE, 3.0, 18.0);\n  float relief = clamp(P_RELIEF_DETAIL, 0.0, 2.2);\n\n  float camZ = 2.65 + 0.45 * sin(iTime * 0.45);\n  vec3 ro = vec3(0.0, 0.25, camZ);\n  vec3 rd = normalize(vec3(uv, -1.52));\n\n  vec3 col = mix(vec3(0.04, 0.05, 0.08), vec3(0.10, 0.12, 0.17), smoothstep(-0.5, 0.6, uv.y));\n\n  float t = 0.0;\n  bool hit = false;\n  for (int i = 0; i < 64; i++) {\n    float d = mapSculpt(ro + rd * t, relief);\n    if (d < 0.002) { hit = true; break; }\n    t += d;\n    if (t > 12.0) break;\n  }\n\n  if (hit) {\n    vec3 p = ro + rd * t;\n    vec3 n = calcNormal(p, relief);\n\n    // Transform hit point into object space so clusters stick tightly to rotating geometry\n    vec3 objP = p - vec3(0.0, 0.02, 0.0);\n    if (p.y > -0.85) {\n      objP.xz = rot2(iTime * 0.32) * objP.xz;\n      objP.xy = rot2(0.38) * objP.xy;\n    }\n\n    // Screen-space projected error determines discrete DAG LOD level (0 = finest, 3 = coarsest)\n    float dagLod = clamp(floor(log2(max(t * errThr * 0.55, 0.5))), 0.0, 3.0);\n    float effScale = clScale * pow(0.55, dagLod);\n\n    vec3 l1 = normalize(vec3(0.65, 0.85, 0.55));\n    vec3 l2 = normalize(vec3(-0.7, 0.2, 0.5));\n    float diff1 = max(dot(n, l1), 0.0);\n    float diff2 = max(dot(n, l2), 0.0);\n    vec3 hVec = normalize(l1 - rd);\n    float spec = pow(max(dot(n, hVec), 0.0), 42.0) * 0.42;\n    float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0) * 0.25;\n\n    // Shaded sculpted marble / bronze material (left side)\n    vec3 stoneAlb = mix(vec3(0.76, 0.72, 0.66), vec3(0.52, 0.46, 0.40), smoothstep(-0.88, -0.82, -p.y));\n    vec3 shaded = stoneAlb * (0.22 + 0.88 * diff1 + 0.24 * diff2) + vec3(spec) + vec3(0.45, 0.62, 0.92) * rim;\n\n    // Nanite Cluster DAG visualization (right side): distinct pastel cluster IDs + micro-triangle grain\n    vec4 cl = evalClusterDAG(objP, effScale);\n    vec3 clusterHue = 0.28 + 0.68 * cl.rgb;\n    float seamLine = smoothstep(0.075, 0.015, cl.w);\n    // Micro-triangle tessellation hint inside each cluster\n    vec3 microP = fract(objP * effScale * 4.5);\n    float microTri = smoothstep(0.08, 0.01, min(min(microP.x, microP.y), abs(microP.x - microP.y)));\n    vec3 clusterView = clusterHue * (0.38 + 0.68 * diff1) + vec3(0.08) * microTri;\n    clusterView = mix(clusterView, vec3(0.04, 0.05, 0.08), seamLine * 0.72);\n    // Subtle LOD tier tint accent on rim\n    vec3 lodTint = mix(vec3(0.15, 0.95, 0.75), vec3(1.0, 0.38, 0.25), dagLod / 3.0);\n    clusterView += lodTint * rim * 0.65;\n\n    col = (screenX < split) ? shaded : clusterView;\n    float fog = exp(-max(t - 3.5, 0.0) * 0.14);\n    col = mix(vec3(0.06, 0.08, 0.12), col, fog);\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\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": "nanite-virtualized-geometry",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T19:04:35.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.5909,
      "std": 0.1798,
      "min": 0.2455,
      "max": 0.9087
     },
     "image": "/specimens/nanite-virtualized-geometry-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "meshlets",
  "mesh-shaders",
  "gpu-driven-rendering",
  "octahedral-impostors"
 ],
 "extends": [
  "meshlets",
  "visibility-buffer"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "hierarchical-z-occlusion-culling",
   "why": "Two-pass depth pyramid culling prunes cluster groups before software and hardware raster."
  }
 ],
 "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/nanite-virtualized-geometry.json"
 },
 "solves": [
  "scenes with film quality meshes run too slow",
  "popping when switching between lod levels",
  "draw calls and triangle counts limit detail",
  "want millions of triangles per mesh in real time"
 ],
 "authority": "Halen et al.",
 "url": "https://texelatlas.vercel.app/t/nanite-virtualized-geometry/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 63.95,
  "tier": "extreme",
  "p50_ms": 2.0081,
  "p95_ms": 2.1043,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "nanite-virtualized-geometry-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 60.21,
   "tier": "extreme",
   "p50_ms": 0.9513,
   "p95_ms": 0.9554,
   "speedup_x": 2.11,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 40.53,
   "tier": "heavy",
   "p50_ms": 1.1674,
   "p95_ms": 1.1755,
   "speedup_x": 1.72,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}