VDB files are commonly used for storing volumetric density grids, such as clouds or smoke. Blender, Embergen, Houdini are a few sources of such data. More recently there is a sparse specification, called NanoVDB, storing sparse voxel octrees (SVOs) that is a more optimized representation for GPU rendering.

I'm outlining steps for Ubuntu, but these libraries are supported on Windows as well with a bit more setup.

  1. build / install OpenVDB check here for cmake instructions

  2. open your terminal and install libtbb

    sudo apt install libtbb-dev
  3. OpenExr is a dependency of OpenVDB, so this should already be built w/your version of OpenVDB

  4. Here are the interesting excerpts from the OpenVDB library that you need to convert between VDB and NanoVDB:

    ...
    #include "nanovdb/util/OpenToNanoVDB.h"
    #include "nanovdb/util/IO.h"
    ...
        openvdb::initialize();
        openvdb::io::File file(argv[1]);
        file.open();
    
        openvdb::GridBase::Ptr baseGrid;
        for (openvdb::io::File::NameIterator nameIter = file.beginName();
           nameIter != file.endName(); ++nameIter) {
           // TODO: deal with other channels if you have them
           if (nameIter.gridName() == "density") {
               baseGrid = file.readGrid(nameIter.gridName());
           }
        }
        file.close();
            
        openvdb::FloatGrid::Ptr srcGrid = openvdb::gridPtrCast<openvdb::FloatGrid>(baseGrid);
        auto handle = nanovdb::openToNanoVDB(*srcGrid);
    
        // Write the NanoVDB grid to file
        nanovdb::io::writeGrid(argv[2], handle);
    ...

Find the complete source for my basic CLI example converting an input vdb file to a nanovdb file at https://github.com/bmahlbrand/openvdb2nanovdb-util

...

All rights reserved Benjamin Ahlbrand 2022