NanoVDB
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.
Also known as GPU VDB
In the family Atmosphere, water & volumes, sparse volumes
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | No built-in NanoVDB loader or sparse grid ray-marcher. |
| Godot 4.7 | None found | |
| Unity | None found | |
| Unreal 5.7 | Built in | Import OpenVDB (.vdb) as a Sparse Volume Texture and render via Heterogeneous Volumes docs |
| Blender 5.2 | Built in | Cycles GPU Volume rendering converts OpenVDB grids to NanoVDB via intern/cycles/scene/image_vdb.cpp docs |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
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
Choose it to ray-march or path-trace large sparse volumes (clouds, smoke caches, level sets) on the GPU without densifying them.
Prefer OpenVDB for editing and simulation where topology changes. Prefer a dense 3D texture when the volume is small. Prefer Ray-marched Participating Media on a plain texture in a WebGL page, since NanoVDB support in browsers is limited and typically needs a custom port.
Field marks
- 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
Presets
NanoVDB — GPU pointer-free sparse 8^3 leaf-tile bitmask & DDA skipping (left) vs volumetric raymarching (right)
{
"P_DENSITY": 1.55,
"P_STEP_SKIP": 1,
"P_ORBIT_SPEED": 0.38,
"P_SPLIT": 0.48
}Show GLSL (144 lines)
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.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| nanovdb-live | Tesla T4 1920x1080 | 350× baseline (extreme) · 11.5 ms / 11.7 ms | opengl-timer-query · 16 frames · GPU Weight Atlas · Colab T4 sweep |
| nanovdb-live | NVIDIA L4 1920x1080 | 332× baseline (extreme) · 5.27 ms / 5.35 ms · 2.2× faster on L4 | opengl-timer-query · Cross-architecture validation |
| nanovdb-live | NVIDIA A100-SXM4-40GB 1920x1080 | 273× baseline (extreme) · 7.86 ms / 8.01 ms · 1.5× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): cited by Instant NGP (Multiresolution Hash Encoding), Radiance Cascades.
Crosses
- Scanned objects as SDF primitives: Real objects captured as distance fields become primitives in a shader modeller: smooth-blend a scanned statue into procedural rock, carve it with booleans, bend or repeat it, and ray-march the result in real time.
- Ray-marched Participating Media: Ray-grid traversal with DDA skips empty nodes while stepping through density.
- OpenVDB: Provides the source grids to be converted and uploaded.
Sources
- primaryKen Museth (2021). NanoVDB: A GPU-Friendly and Portable VDB Data Structure For Real-Time Rendering And Simulation. ACM SIGGRAPH 2021 Talks.Verified via crossref · 2026-11-29doi:10.1145/3450623.3464653
- implementationAcademySoftwareFoundation (2013). AcademySoftwareFoundation/openvdb. OpenVDB - Sparse volume data structure and toolsGitHub API · license Apache-2.0 · 2026-11-29