---
id: "nanite-virtualized-geometry"
title: "Nanite virtualized geometry"
aliases: [Nanite, virtualized geometry, cluster LOD]
domain: "performance"
stage: "performance"
realtime: "realtime"
platforms: [unreal, desktop-gpu]
year_introduced: 2021
inputs: [mesh]
outputs: [gbuffer, depth]
style: "both"
dynamic: "both"
cost: "heavy"
authority: "Halen et al."
url: "https://texelatlas.vercel.app/t/nanite-virtualized-geometry/"
sources_verified_at: "2026-11-29"
---
# Nanite virtualized geometry (Halen et al.)

> 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.

## Reach for it when

- 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

## 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.

At 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 it

Choose it for static, very high-polygon assets where artists should not author LODs. Prefer [Meshlets (cluster rendering)](https://texelatlas.vercel.app/t/meshlets.md) with a simpler discrete LOD chain or [Octahedral impostors](https://texelatlas.vercel.app/t/octahedral-impostors.md) when targeting WebGL or mobile. Prefer ordinary skinned LOD for deforming characters, which the original system does not handle well.

## Cost

heavy — Large fixed cost for streaming, culling and visibility-buffer resolve; scales with pixels rather than triangles.
Measured GPU Weight: 63.95× baseline (extreme) — 2.0081 ms median / 2.1043 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 60.21× baseline (extreme) — 0.9513 ms median (2.11× faster on L4).
Ampere A100 scaling: 40.53× baseline (heavy) — 1.1674 ms median (1.72× faster on A100).

## 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

## Engine support

- unreal: builtin — `Static Mesh Editor > Details > Nanite Settings > Enable Nanite Support` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/nanite-virtualized-geometry-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: mesh
- Outputs: gbuffer, depth
- Platforms: unreal, desktop-gpu

## Presets

### Nanite virtualized geometry — screen-space error DAG cluster hierarchy vs shaded micro-polygons (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_PIXEL_ERROR": 1,
  "P_CLUSTER_SCALE": 8,
  "P_RELIEF_DETAIL": 1,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_PIXEL_ERROR = 1.0; // P Error Threshold [0.35, 2.5, 0.05]
const float P_CLUSTER_SCALE = 8.0; // P Cluster Density [4.0, 16.0, 0.5]
const float P_RELIEF_DETAIL = 1.0; // P Micro-Relief [0.0, 2.0, 0.05]
const float P_SPLIT = 0.48; // P Shaded / Cluster 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);
}

// High-detail sculpted baroque manifold (ornate fluted torus + central obelisk)
float mapSculpt(vec3 p, float relief) {
  vec3 q = p - vec3(0.0, 0.02, 0.0);
  q.xz = rot2(iTime * 0.32) * q.xz;
  q.xy = rot2(0.38) * q.xy;

  float theta = atan(q.z, q.x);
  vec2 tq = vec2(length(q.xz) - 0.72, q.y);
  float phi = atan(tq.y, tq.x);
  float flutes = 0.032 * sin(phi * 10.0 + theta * 4.0) + 0.014 * cos(theta * 16.0 - phi * 6.0);
  float dTorus = length(tq) - (0.28 + flutes * relief);

  // Inner carved faceted core
  vec3 c = q;
  float dCore = length(c) - (0.30 + 0.022 * sin(c.x * 22.0) * cos(c.y * 22.0) * sin(c.z * 22.0) * relief);

  // Pedestal floor with micro-grooves
  float dFloor = p.y + 0.88 - 0.008 * sin(p.x * 18.0) * cos(p.z * 18.0) * relief;

  return min(min(dTorus, dCore) * 0.78, dFloor);
}

vec3 calcNormal(vec3 p, float relief) {
  vec2 e = vec2(0.002, 0.0);
  return normalize(vec3(
    mapSculpt(p + e.xyy, relief) - mapSculpt(p - e.xyy, relief),
    mapSculpt(p + e.yxy, relief) - mapSculpt(p - e.yxy, relief),
    mapSculpt(p + e.yyx, relief) - mapSculpt(p - e.yyx, relief)
  ));
}

// 3D Voronoi cluster partitioning simulating Nanite 128-triangle cluster DAG at given LOD scale
vec4 evalClusterDAG(vec3 p, float scale) {
  vec3 sp = p * scale;
  vec3 n = floor(sp);
  vec3 f = fract(sp);
  float d1 = 8.0;
  float d2 = 8.0;
  vec3 bestId = 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;
          bestId = n + g;
        } else if (d < d2) {
          d2 = d;
        }
      }
    }
  }
  float seam = sqrt(d2) - sqrt(d1);
  vec3 colId = hash33(bestId * 1.7 + 13.1);
  return vec4(colId, seam);
}

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);
  float errThr = clamp(P_PIXEL_ERROR, 0.3, 3.0);
  float clScale = clamp(P_CLUSTER_SCALE, 3.0, 18.0);
  float relief = clamp(P_RELIEF_DETAIL, 0.0, 2.2);

  float camZ = 2.65 + 0.45 * sin(iTime * 0.45);
  vec3 ro = vec3(0.0, 0.25, camZ);
  vec3 rd = normalize(vec3(uv, -1.52));

  vec3 col = mix(vec3(0.04, 0.05, 0.08), vec3(0.10, 0.12, 0.17), smoothstep(-0.5, 0.6, uv.y));

  float t = 0.0;
  bool hit = false;
  for (int i = 0; i < 64; i++) {
    float d = mapSculpt(ro + rd * t, relief);
    if (d < 0.002) { hit = true; break; }
    t += d;
    if (t > 12.0) break;
  }

  if (hit) {
    vec3 p = ro + rd * t;
    vec3 n = calcNormal(p, relief);

    // Transform hit point into object space so clusters stick tightly to rotating geometry
    vec3 objP = p - vec3(0.0, 0.02, 0.0);
    if (p.y > -0.85) {
      objP.xz = rot2(iTime * 0.32) * objP.xz;
      objP.xy = rot2(0.38) * objP.xy;
    }

    // Screen-space projected error determines discrete DAG LOD level (0 = finest, 3 = coarsest)
    float dagLod = clamp(floor(log2(max(t * errThr * 0.55, 0.5))), 0.0, 3.0);
    float effScale = clScale * pow(0.55, dagLod);

    vec3 l1 = normalize(vec3(0.65, 0.85, 0.55));
    vec3 l2 = normalize(vec3(-0.7, 0.2, 0.5));
    float diff1 = max(dot(n, l1), 0.0);
    float diff2 = max(dot(n, l2), 0.0);
    vec3 hVec = normalize(l1 - rd);
    float spec = pow(max(dot(n, hVec), 0.0), 42.0) * 0.42;
    float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0) * 0.25;

    // Shaded sculpted marble / bronze material (left side)
    vec3 stoneAlb = mix(vec3(0.76, 0.72, 0.66), vec3(0.52, 0.46, 0.40), smoothstep(-0.88, -0.82, -p.y));
    vec3 shaded = stoneAlb * (0.22 + 0.88 * diff1 + 0.24 * diff2) + vec3(spec) + vec3(0.45, 0.62, 0.92) * rim;

    // Nanite Cluster DAG visualization (right side): distinct pastel cluster IDs + micro-triangle grain
    vec4 cl = evalClusterDAG(objP, effScale);
    vec3 clusterHue = 0.28 + 0.68 * cl.rgb;
    float seamLine = smoothstep(0.075, 0.015, cl.w);
    // Micro-triangle tessellation hint inside each cluster
    vec3 microP = fract(objP * effScale * 4.5);
    float microTri = smoothstep(0.08, 0.01, min(min(microP.x, microP.y), abs(microP.x - microP.y)));
    vec3 clusterView = clusterHue * (0.38 + 0.68 * diff1) + vec3(0.08) * microTri;
    clusterView = mix(clusterView, vec3(0.04, 0.05, 0.08), seamLine * 0.72);
    // Subtle LOD tier tint accent on rim
    vec3 lodTint = mix(vec3(0.15, 0.95, 0.75), vec3(1.0, 0.38, 0.25), dagLod / 3.0);
    clusterView += lodTint * rim * 0.65;

    col = (screenX < split) ? shaded : clusterView;
    float fog = exp(-max(t - 3.5, 0.0) * 0.14);
    col = mix(vec3(0.06, 0.08, 0.12), col, fog);
  }

  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: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).

## Lineage

- extends [Meshlets (cluster rendering)](https://texelatlas.vercel.app/t/meshlets.md)
- extends [Visibility buffer rendering](https://texelatlas.vercel.app/t/visibility-buffer.md)

## Combines with

- [Hierarchical-Z occlusion culling](https://texelatlas.vercel.app/t/hierarchical-z-occlusion-culling.md): Two-pass depth pyramid culling prunes cluster groups before software and hardware raster.

## Sources

1. [primary] Henrik Halen, Andreas Brinck, Kyle Hayward, Xiangshun Bei Global Illumination Based on Surfels. SIGGRAPH 2021 Advances in Real-Time Rendering. https://advances.realtimerendering.com/s2021/index.html (verified via http on 2026-11-29)
2. [implementation] zeux (2016) zeux/meshoptimizer. https://github.com/zeux/meshoptimizer License: MIT. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Nanite virtualized geometry." https://texelatlas.vercel.app/t/nanite-virtualized-geometry/ (accessed 2026-12-01).
