---
id: "nanovdb"
title: "NanoVDB"
aliases: [GPU VDB]
domain: "volumes"
stage: "volume"
realtime: "realtime"
platforms: [cuda, desktop-gpu, webgpu, cpu]
year_introduced: 2021
inputs: [volume-density, sdf]
outputs: [volume-density, sdf]
style: "both"
dynamic: "static"
cost: "medium"
authority: "Museth, 2021"
url: "https://texelatlas.vercel.app/t/nanovdb/"
sources_verified_at: "2026-11-29"
---
# NanoVDB (Museth, 2021)

> A compact, read-only, pointer-free serialisation of an OpenVDB grid that can be copied to a GPU buffer and sampled from CUDA, GLSL, HLSL or OpenCL with the same hierarchical access.

## Reach for it when

- need to render large sparse volumes on the gpu
- openvdb can't be sampled in a shader
- dense 3d textures use too much memory for smoke caches
- want gpu access to a production volume grid

## How it works

OpenVDB's tree uses pointers and dynamic allocation, which GPUs cannot handle well. NanoVDB lays the same 4-level hierarchy (root, two internal levels, leaf) in a single linear memory blob, replacing pointers with byte offsets. The tree is read-only, so all structure is fixed at conversion time; leaf nodes hold bit masks of active voxels along with min and max values per node. The header stores a transform, a bounding box and a magic number for validation. A shader or kernel gets a root pointer, and an accessor walks offsets to a voxel; a cache of the last-visited nodes makes coherent traversals fast. The same header-only C++ code compiles for CPU, CUDA and other languages through a shared C-like API, and ray-grid intersection with a hierarchical DDA is included.

## When to use it

Choose it to ray-march or path-trace large sparse volumes (clouds, smoke caches, level sets) on the GPU without densifying them.

Prefer [OpenVDB](https://texelatlas.vercel.app/t/openvdb.md) for editing and simulation where topology changes. Prefer a dense 3D texture when the volume is small. Prefer [Ray-marched Participating Media](https://texelatlas.vercel.app/t/volume-ray-marching.md) on a plain texture in a WebGL page, since NanoVDB support in browsers is limited and typically needs a custom port.

## Cost

medium — Memory is the active-voxel footprint; sampling costs a few dependent reads without a cache and fewer with an accessor.
Measured GPU Weight: 349.64× baseline (extreme) — 11.5032 ms median / 11.7392 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 331.64× baseline (extreme) — 5.2731 ms median (2.18× faster on L4).
Ampere A100 scaling: 273.01× baseline (extreme) — 7.8628 ms median (1.46× faster on A100).

## Failure modes

- Read-only: any topology change requires re-conversion on the CPU
- Pointer-chasing in a deep tree gives divergent memory reads when neighbouring rays are incoherent
- Buffer alignment and endian assumptions break when the blob is mapped to non-native languages
- Precision loss if grids are quantised to 4, 8 or 16 bits to save memory
- Browser and WebGPU support is not first-party, so porting the accessor is needed

## Engine support

- blender: builtin — `Cycles GPU Volume rendering converts OpenVDB grids to NanoVDB via intern/cycles/scene/image_vdb.cpp` (evidence: https://github.com/blender/blender/blob/main/intern/cycles/scene/image_vdb.cpp, checked 2026-12-01)
- unreal: builtin — `Import OpenVDB (.vdb) as a Sparse Volume Texture and render via Heterogeneous Volumes` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/sparse-volume-textures-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: volume-density, sdf
- Outputs: volume-density, sdf
- Platforms: cuda, desktop-gpu, webgpu, cpu

## Presets

### NanoVDB — GPU pointer-free sparse 8^3 leaf-tile bitmask & DDA skipping (left) vs volumetric raymarching (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_DENSITY": 1.55,
  "P_STEP_SKIP": 1,
  "P_ORBIT_SPEED": 0.38,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_DENSITY = 1.55; // P Volume Density [0.5, 3.0, 0.1]
const float P_STEP_SKIP = 1.00; // P Leaf Tile Vis [0.2, 1.6, 0.05]
const float P_ORBIT_SPEED = 0.38; // P Orbit Speed [0.0, 1.4, 0.05]
const float P_SPLIT = 0.48; // P Leaf Bricks / Volume [0.0, 1.0, 0.02]

float hash31(vec3 p) {
  p = fract(p * vec3(127.1, 311.7, 74.7));
  p += dot(p, p.yzx + 19.19);
  return fract((p.x + p.y) * p.z);
}

float noise3(vec3 p) {
  vec3 i = floor(p);
  vec3 f = fract(p);
  f = f * f * (3.0 - 2.0 * f);
  return mix(
    mix(mix(hash31(i), hash31(i + vec3(1.0, 0.0, 0.0)), f.x),
        mix(hash31(i + vec3(0.0, 1.0, 0.0)), hash31(i + vec3(1.0, 1.0, 0.0)), f.x), f.y),
    mix(mix(hash31(i + vec3(0.0, 0.0, 1.0)), hash31(i + vec3(1.0, 0.0, 1.0)), f.x),
        mix(hash31(i + vec3(0.0, 1.0, 1.0)), hash31(i + vec3(1.0, 1.0, 1.0)), f.x), f.y),
    f.z
  );
}

float fbm3(vec3 p) {
  float v = 0.0, a = 0.5;
  for (int i = 0; i < 3; i++) {
    v += a * noise3(p);
    p *= 2.05;
    a *= 0.5;
  }
  return v;
}

// Sparse knotted curl plume SDF bounding support (only ~18% of bounding box is active!)
float evalSparseDensity(vec3 p) {
  vec2 q = vec2(length(p.xz) - 0.52, p.y - 0.16 * sin(atan(p.z, p.x) * 2.0 + iTime * 0.6));
  float dTorus = length(q) - 0.28;
  if (dTorus > 0.24) return 0.0;
  float n = fbm3(p * 3.8 + vec3(0.0, -iTime * 0.45, 0.0));
  return clamp((0.22 - dTorus) * 3.2 + (n - 0.52) * 1.15, 0.0, 1.0) * smoothstep(0.24, 0.02, dTorus);
}

vec2 intersectAABB(vec3 ro, vec3 rd, vec3 b) {
  vec3 invR = 1.0 / (rd + vec3(1e-6));
  vec3 t0 = (-b - ro) * invR;
  vec3 t1 = (b - ro) * invR;
  vec3 tMin = min(t0, t1);
  vec3 tMax = max(t0, t1);
  float tN = max(max(tMin.x, tMin.y), tMin.z);
  float tF = min(min(tMax.x, tMax.y), tMax.z);
  return vec2(tN, tF);
}

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 sx = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool showVolume = sx >= split;

  float densScale = clamp(P_DENSITY, 0.3, 3.5);
  float tileVis = clamp(P_STEP_SKIP, 0.1, 2.0);
  float orb = iTime * max(P_ORBIT_SPEED, 0.0) + 0.4;

  vec3 ro = vec3(2.15 * sin(orb), 0.72, 2.15 * cos(orb));
  vec3 fw = normalize(-ro);
  vec3 ri = normalize(cross(fw, vec3(0.0, 1.0, 0.0)));
  vec3 up = cross(ri, fw);
  vec3 rd = normalize(fw * 1.46 + ri * uv.x + up * uv.y);

  vec3 col = mix(vec3(0.03, 0.045, 0.075), vec3(0.09, 0.13, 0.21), smoothstep(-0.4, 0.6, rd.y));
  vec3 boxRad = vec3(0.95, 0.65, 0.95);
  vec2 hit = intersectAABB(ro, rd, boxRad);

  if (hit.y > max(hit.x, 0.0)) {
    float t0 = max(hit.x, 0.05);
    float t1 = hit.y;
    vec3 sunDir = normalize(vec3(0.65, 0.78, 0.42));

    if (!showVolume) {
      // Left: NanoVDB hierarchical sparse 8^3 leaf-tile DDA occupancy visualization
      float gridRes = 5.0; // coarse leaf-brick grid inside bounding domain
      float trans = 1.0;
      vec3 acc = vec3(0.0);
      const int STEPS = 44;
      float dt = (t1 - t0) / float(STEPS);
      for (int i = 0; i < STEPS; i++) {
        vec3 mp = ro + rd * (t0 + (float(i) + 0.5) * dt);
        vec3 cellId = floor(mp * gridRes);
        vec3 cellCenter = (cellId + 0.5) / gridRes;
        // Bitmask occupancy check at NanoVDB leaf tile center
        float tileDens = evalSparseDensity(cellCenter);
        if (tileDens > 0.02) {
          vec3 f = abs(fract(mp * gridRes) - 0.5);
          float edge = smoothstep(0.055, 0.015, min(min(0.5 - f.x, 0.5 - f.y), 0.5 - f.z));
          vec3 tileCol = mix(vec3(0.12, 0.62, 0.95), vec3(0.98, 0.58, 0.16), tileDens);
          float a = clamp((0.18 + 0.75 * edge) * tileVis * dt * 4.5, 0.0, 0.95);
          acc += trans * (tileCol * (0.45 + 1.15 * edge)) * a;
          trans *= (1.0 - a);
          if (trans < 0.04) break;
        }
      }
      // Subtle outer root-node bounding box frame
      vec3 ep = abs(abs(ro + rd * t0) - boxRad);
      float rootWire = smoothstep(0.022, 0.005, min(max(ep.x, ep.y), min(max(ep.y, ep.z), max(ep.z, ep.x))));
      col = col * trans + acc + vec3(0.35, 0.85, 1.0) * rootWire * 0.55;
    } else {
      // Right: Full NanoVDB pointer-free GPU volumetric raymarching with Henyey-Greenstein scattering
      float trans = 1.0;
      vec3 volAcc = vec3(0.0);
      const int STEPS = 42;
      float dt = (t1 - t0) / float(STEPS);
      float hg = 0.25 + 0.75 * pow(max(dot(rd, sunDir), 0.0), 4.0);
      for (int i = 0; i < STEPS; i++) {
        vec3 mp = ro + rd * (t0 + (float(i) + 0.5) * dt);
        float d = evalSparseDensity(mp);
        if (d > 0.01) {
          // 4-step shadow march along sun direction
          float shAcc = 0.0;
          for (int s = 1; s <= 4; s++) {
            shAcc += evalSparseDensity(mp + sunDir * (float(s) * 0.11));
          }
          float lTrans = exp(-shAcc * densScale * 0.65);
          vec3 scatterCol = mix(vec3(0.18, 0.34, 0.56), vec3(1.55, 1.18, 0.76), lTrans) * (0.55 + 0.75 * hg);
          float ext = d * densScale * 3.4;
          float stepT = exp(-ext * dt);
          volAcc += trans * scatterCol * (1.0 - stepT);
          trans *= stepT;
          if (trans < 0.02) break;
        }
      }
      col = col * trans + volAcc;
    }
  }

  float sep = smoothstep(0.0035, 0.0008, abs(sx - 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.

## Lineage

- extends [OpenVDB](https://texelatlas.vercel.app/t/openvdb.md)

## Combines with

- [Ray-marched Participating Media](https://texelatlas.vercel.app/t/volume-ray-marching.md): Ray-grid traversal with DDA skips empty nodes while stepping through density.
- [OpenVDB](https://texelatlas.vercel.app/t/openvdb.md): Provides the source grids to be converted and uploaded.

## Combination ideas

- [Scanned objects as SDF primitives](https://texelatlas.vercel.app/ideas/captured-sdf-sculpting/)

## Sources

1. [primary] Ken Museth (2021) NanoVDB: A GPU-Friendly and Portable VDB Data Structure For Real-Time Rendering And Simulation. ACM SIGGRAPH 2021 Talks. https://doi.org/10.1145/3450623.3464653 (verified via crossref on 2026-11-29)
2. [implementation] AcademySoftwareFoundation (2013) AcademySoftwareFoundation/openvdb. https://github.com/AcademySoftwareFoundation/openvdb License: Apache-2.0. (verified via github on 2026-11-29)

## Cite this entry

Texel. "NanoVDB." https://texelatlas.vercel.app/t/nanovdb/ (accessed 2026-12-01).
