Here’s a Unity-friendly GVDB wrapper example packaged as a tarball. The solution includes a native C++ plugin (stand‑in for the NVIDIA GVDB library), a managed C# wrapper, a MonoBehaviour for loading/initialising volumes and copying them into GPU memory via compute shaders, and a simple compute shader that writes voxel data into a 3D texture. The README explains how to build and integrate the plugin into Unity and how to replace the stub with the real GVDB SDK.
In the provided implementation:
-
The C++ layer exposes functions to create/destroy a volume, set and get voxel values, fill a volume and copy its contents back to managed memory. In a real integration, these would wrap VolumeGVDB methods such as Configure, AddChannel, ActivateRegion, FinishTopology and UpdateAtlas【244013050170112†L223-L249】. NVIDIA designed GVDB’s compute API to deliver high‑resolution, sparse voxel data with minimal memory footprint【452582142663675†L110-L115】, while its rendering API exposes CUDA/OptiX pathways for custom kernels【452582142663675†L110-L115】.
-
The C# wrapper (in GVDBPlugin.cs) uses P/Invoke to call into the native library and marshals data between managed and unmanaged memory. It provides helper methods to get a volume’s dimensions and copy voxel data into a managed array.
-
GVDBVolume.cs demonstrates how to generate procedural data, transfer it to a compute buffer and use a compute shader to populate a RenderTexture. Unity scripts can then sample this 3D texture for rendering or further processing.
-
A compute shader (GVDBCopy.compute) copies linear voxel data into a 3D RWTexture, serving as a template for more complex sampling or write operations.
GVDB’s sparse structure stores data only at occupied voxels and includes housekeeping modules (e.g., scene and camera management) that update when window size or focal length change【619227008446641†L65-L68】. NVIDIA reports that GVDB’s GPU‑accelerated approach can provide up to 10× speedups over CPU methods【452582142663675†L137-L139】 while reducing memory usage【452582142663675†L132-L142】—advantages that motivated this wrapper design.
You can download the complete project as a tarball below and follow the README for build instructions. Replace the stub functions with calls into the actual GVDB library to unlock its full capabilities.
{{file:file-7ZVbpdiGMqZMMhJDEUbDzG}}