webgpu-nanovdb

See PicoVDB for WebGPU optimised format of NanoVDB.

WebGPU NanoVDB

A WGSL shader library for accessing NanoVDB sparse volumetric data in WebGPU compute shaders.

WebGPU NanoVDB

Live Demo →

Overview

This repository provides pnanovdb.wgsl - a port of the PNanoVDB C API to WGSL for use in WebGPU compute shaders.

Usage

// Include the library in your compute shader
// (concatenate pnanovdb.wgsl with your shader code)

@group(0) @binding(2) var<storage> nanovdb_buffer: array<u32>;

@compute @workgroup_size(8, 8)
fn main() {
    // Create buffer handle
    let buf = pnanovdb_buf_t(0, arrayLength(&nanovdb_buffer));
    
    // Access grid data
    let grid = pnanovdb_grid_handle_t(0u);
    let tree = pnanovdb_grid_get_tree(grid);
    let root = pnanovdb_tree_get_root(buf, tree);
    
    // Sample voxel data
    var accessor: pnanovdb_readaccessor_t;
    pnanovdb_readaccessor_init(&accessor, root);
    let value = pnanovdb_readaccessor_get_float(buf, &accessor, coord);
}

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

Built on technologies from the Academy Software Foundation.