Skip to main content

Lightweight OpenVDB file I/O, mesh-to-SDF, and grid operations

Project description

TinyVDB, header-only C/C++ VDB library

TinyVDB is a collection of header-only C/C++ libraries for working with OpenVDB data. It provides lightweight VDB file I/O, mesh-to-SDF conversion, grid operations, and more — without depending on the full OpenVDB library.

TinyVDB is suitable for graphics applications, HPC visualization tools, physics simulation, and any project that needs lightweight VDB functionality.

Modules

Header Language Description
tinyvdb_io.h C11 OpenVDB file I/O with custom memory allocator support
tinyvdb_mesh.h C++11 Mesh-to-SDF, marching cubes, manifold preprocessing
tinyvdb_ops.h C++11 Grid operations: morphology, filtering, CSG, differential operators, advection, ray tracing, fracture

Features

I/O (tinyvdb_io.h)

  • Dependency-free C11 code (header-only, single file)
  • Custom memory allocator interface (arena/pool allocator friendly)
  • mmap-based file access with heap-buffer fallback
  • UTF-8 path support on all platforms (Windows WideChar + long path \\?\ prefix)
  • Cross-platform (Linux, macOS, Windows)
  • Big endian support (e.g., Power, SPARC)
  • Read and write OpenVDB files (version 220 to 225)
  • Multiple grid/tree topologies (not limited to Tree_float_5_4_3)
  • ZIP compression (via bundled miniz or system zlib)
  • BLOSC compression (built-in, using bundled LZ4 — no external blosc dependency)
  • Active mask compression (per-node flags 0-6)
  • Half-float (FP16) grid support

Mesh (tinyvdb_mesh.h)

  • Triangle mesh to signed distance field (dense 3D grid)
  • SDF to triangle mesh (marching cubes)
  • Manifold preprocessing (mesh to SDF to mesh round-trip)
  • Configurable sign determination (flood fill or sweep)

Grid operations (tinyvdb_ops.h)

  • Morphological dilation/erosion, open/close
  • Gaussian, mean, and Laplacian SDF filtering
  • CSG operations (union, intersection, difference)
  • Surface area and volume measurement
  • Differential operators (gradient, divergence, Laplacian, curl)
  • Finite difference stencils (central, forward, backward)
  • Semi-Lagrangian advection (RK2)
  • Poisson solver (preconditioned conjugate gradient)
  • Ray-SDF intersection (sphere tracing)
  • Volume to spheres (greedy adaptive sphere packing)
  • Particles to SDF (sphere stamping)
  • Level set fracture (cutter-based volume splitting)

Supported VDB versions

Version Feature
220 Selective compression
221 Float frustum bbox
222 Node mask compression, per-grid compression flags
223 BLOSC compression, point index grid
224 Multipass I/O
225 Half-float grid type

How to use

I/O library

Copy src/tinyvdb_io.h, src/miniz.c, src/miniz.h, src/lz4.c, and src/lz4.h to your project. BLOSC compression (LZ4) is built-in — no external dependency needed.

/* In exactly one .c or .cc file: */
#define TINYVDB_IO_IMPLEMENTATION
#include "tinyvdb_io.h"

Reading a VDB file

tvdb_file_t file;
tvdb_error_t err = {0};

tvdb_status_t st = tvdb_file_open(&file, "input.vdb", NULL, &err);
if (st != TVDB_OK) { /* handle error */ }

st = tvdb_read_all_grids(&file, &err);
if (st != TVDB_OK) { /* handle error */ }

for (size_t i = 0; i < tvdb_grid_count(&file); i++) {
    printf("Grid: %s  Type: %s\n",
           tvdb_grid_name(&file, i),
           tvdb_grid_type_name(&file, i));
}

tvdb_file_close(&file);

Writing a VDB file

/* After reading/modifying a file, write it back: */
tvdb_status_t st = tvdb_file_save(&file, "output.vdb",
                                  TVDB_COMPRESS_BLOSC | TVDB_COMPRESS_ACTIVE_MASK,
                                  /*use_mmap=*/0, &err);

Or write to a memory buffer:

uint8_t *data = NULL;
size_t data_size = 0;
tvdb_status_t st = tvdb_write_to_memory(&file,
                                        TVDB_COMPRESS_ZIP | TVDB_COMPRESS_ACTIVE_MASK,
                                        &data, &data_size, &err);
/* ... use data ... */
free(data);

Custom allocator

tvdb_allocator_t alloc = {
    .malloc_fn  = my_malloc,
    .realloc_fn = my_realloc,
    .free_fn    = my_free,
    .user_ctx   = my_arena
};

tvdb_file_open(&file, "input.vdb", &alloc, &err);

The allocator passes old_size to realloc_fn and size to free_fn, enabling arena/pool allocators that don't track allocation sizes internally.

Mesh library

// In exactly one .cc file:
#define TINYVDB_MESH_IMPLEMENTATION
#include "tinyvdb_mesh.h"
// Mesh to SDF
tvdb_mesh::DenseGrid grid;
tvdb_mesh::MeshToSDF(mesh, voxel_size, band_width, &grid);

// SDF to mesh (marching cubes)
tvdb_mesh::TriangleMesh output;
tvdb_mesh::SDFToMesh(grid, 0.0f, &output);

// Manifold preprocessing (mesh -> SDF -> mesh round-trip)
tvdb_mesh::MakeManifold(input, resolution, isovalue, &output);

Grid operations

// In exactly one .cc file:
#define TINYVDB_OPS_IMPLEMENTATION
#include "tinyvdb_ops.h"
// CSG union of two SDF grids
tvdb_ops::CSGUnion(grid_a, grid_b, &result);

// Gaussian smoothing
tvdb_ops::GaussianFilter(&grid, /*width=*/1, /*iterations=*/3);

// Ray-SDF intersection
tvdb_ops::RayHit hit;
if (tvdb_ops::RayCastSDF(grid, origin, dir, max_t, &hit)) {
    // hit.position, hit.normal, hit.t
}

Compile flags

Flag Description
TVDB_USE_SYSTEM_ZLIB Use system zlib instead of bundled miniz
TVDB_NO_MMAP Disable mmap, always read into heap buffer

CMake build

CMake build is provided for example/test builds.

Setup

$ git submodule update --init --recursive --depth 1

Build

$ mkdir build
$ cd build
$ cmake ..
$ make

CMake options

Option Default Description
TINYVDB_USE_SYSTEM_ZLIB OFF Use system zlib instead of bundled miniz
TINYVDB_BUILD_EXAMPLES ON Build the vdbdump example
TINYVDB_BUILD_VDBRENDER ON Build the vdbrender volume path tracer

vdbdump example

A command-line tool that reads a VDB file and prints its structure:

$ ./vdbdump input.vdb --verbose
File: input.vdb
  VDB version: 224  (lib 6.2)
  UUID: 1569c382-d056-4c66-aa3e-9b0ca351fe91
  Grids: 1

Grid[0]: "surface"
  Type: Tree_float_5_4_3
  Tree: 4 levels [Root, Internal(log2dim=5), Internal(log2dim=4), Leaf(log2dim=3)]
  Background: 0.3
  Root: 0 tiles, 8 children
  Nodes: 25 total (16 internal, 8 leaf)
  Active voxels: 2.08K
  Transform: UniformScale
    Voxel size: (0.1, 0.1, 0.1)
  Compression: blosc+active_mask (0x6)

Write a copy with --write or --write-mmap:

$ ./vdbdump input.vdb --write output.vdb
$ ./vdbdump input.vdb --write-mmap output_mmap.vdb

Notes

Terms

background is a uniform constant value used when there is no voxel data.

Node is composed of Root, Internal, and Leaf. Leaf contains actual voxel data.

Root and Internal nodes have Value or a pointer to a child node, where Value is a constant value for the node.

There are two bit masks, child mask and value mask, for each internal node.

License

TinyVDB is licensed under the Apache License, Version 2.0.

Copyright 2026 - Present Syoyo Fujita

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Third party licenses

Library License
OpenVDB (original I/O logic) Apache 2.0
LZ4 BSD 2-Clause
miniz MIT
tinyexr (vdbrender example) BSD 3-Clause

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tinyvdb-0.1.0.tar.gz (26.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tinyvdb-0.1.0-cp311-abi3-win_amd64.whl (218.8 kB view details)

Uploaded CPython 3.11+Windows x86-64

tinyvdb-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

tinyvdb-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

tinyvdb-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (541.2 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

tinyvdb-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (525.3 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

tinyvdb-0.1.0-cp311-abi3-macosx_11_0_arm64.whl (397.2 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

tinyvdb-0.1.0-cp311-abi3-macosx_10_9_x86_64.whl (481.1 kB view details)

Uploaded CPython 3.11+macOS 10.9+ x86-64

File details

Details for the file tinyvdb-0.1.0.tar.gz.

File metadata

  • Download URL: tinyvdb-0.1.0.tar.gz
  • Upload date:
  • Size: 26.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tinyvdb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d0612210dcf6afdb0a1beeade3aa0902cd7cc9fd6f3ec12055ad4aa5616acbb9
MD5 e3ba90141a40b0298067f14a116c173b
BLAKE2b-256 dbeda4db23518bd91ee9891bc6f77cc6000caa976ce56bd85372f3a36842b798

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.1.0.tar.gz:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.1.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: tinyvdb-0.1.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 218.8 kB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tinyvdb-0.1.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3c87e646a1f0b047ea59f342a37f4a5a8b262c910fc894b112653fcdf1fe3ccc
MD5 42324bc0d5e813cb50717ac7de780de9
BLAKE2b-256 96b3648d091bc6c2ef36afd2f85cc745fbb1bd72a0f9ebce0618a117d9432423

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.1.0-cp311-abi3-win_amd64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3f8544aeaac9aa1076ac00fe961b7200452d1df595fd01e21fd66676380ae17f
MD5 3d76abda68783b3a62a0869a557bf6d9
BLAKE2b-256 1e8703ef7cadc0158d2883b4659c1afd6012bec5d9ea9c7ca36aaf59dccc14a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 29225e6f0cf7f1bf297c79bb0cd358f43c98e3d2e8be11665850310d6594be29
MD5 9e11f3dcb085964e55df4aea2f76befa
BLAKE2b-256 543958a647c96dd49928a5623b33c58a9d9ac9a4035320e12cbf235d210e16be

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 852fd1672f2fa0de4c22e76c5641fd65427bbbdbd51740dfa3e4c0f3ba4e2504
MD5 0ba98e2a2971ae5fc71699590230b122
BLAKE2b-256 6b626063ca38a352614e2dd7aa4af4a3fc47cadd9eb1c73e4809ee5385b94579

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7ec1e58b6edb37db84b3f7a23174f32e492c29b847ed5c817cefa608b56df0e6
MD5 a4726b08c12db54789dfa2132b2f35dd
BLAKE2b-256 5d9708955d41f8e8c0a70ff14efb68227811dffc66a60e416c2f9807885d2c49

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.1.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7ceed2d687e37c80899224550830d7a8275da29c72563f6cb77e2d9a5351cc4c
MD5 a3a6ef52974babf7f15ee5d6cc08dda7
BLAKE2b-256 7d0735919532a171b4c618e82bb517ea3b52129a4a4b8951d3da0fb1bbd807f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.1.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.1.0-cp311-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.1.0-cp311-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c4f3281e467150fe0ad44b9edf4bed5297ec5ba5020f970fefd1dc152c7becf5
MD5 d8cd1338defef075610e44a9bbf389b0
BLAKE2b-256 0806d13d812cd78f6bd56aa413f64569833193c3c180ec329cba46b51ff2c224

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.1.0-cp311-abi3-macosx_10_9_x86_64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page