Houdini tip | Houdini native SDF volume into VDB conversion

Recently I found an interesting problem while trying to convert Houdini dense (native) SDF volume into a VDB SDF volume. My primary motivation was to save space – to discard voxels, which were too far away from surface. This is one of the main reasons why VDBs are usually superior to dense volumes. Note that in this post I will not go too much into details about volumes, but will post some links at the end of the article which explain the basics.
correct

So the idea is that I want to have active voxels only in the close proximity to surface.
I will be visualizing a slice of active voxels generated by VDB Visualize Tree node. Surface is at the interface of red and white points.

This is the result that you will get if you have a polygonal mesh and you convert it to SDF with VDB From Polygons node. It works fine as expected.

But let’s generate SDF first with dense volume with Isooffset node and then convert it to VDB with Convert VDB node. The result is a VDB SDF volume, but if we visualize active voxels, it looks like this.

bad

As you can see we did not save any space, because the VDB volume has active voxels in the whole domain, not just close to the surface.

As it turns out we need to do a small pre-processing step to have narrow-band SDF VDB volume. Convert VDB node does not want to discard voxels which have correct / varying values. However if we clamp voxel values in a certain range, then VDB will discard the incorrect (clamped) voxels. We know that in SDF representation of surface our surface is in the region of voxels that have value of zero. So if we calmp our values from let’s say -0.5 to 0.5, we will have correct values in voxels which have distance to surface of 0.5 units or less and the rest will be clamped to our clamping value.

unclampedclamped

Here are images visualizing values of voxels. Surface is represented by interface of yellow and blue colors. In the first image you can see a smooth gradient of colors, which represent distance to the surface. In the second one values are clamped, and you can see that gradient stops at some point.

To do so create a volume wrangle with this code:

node_parm

With this node we can set band of active voxels by world space distance, or by number of voxels. After doing it, Convert VDB will keep only the correct voxels. Also make sure to disable Activate Inside Voxels option in Convert VDB node.

corrected

You can find project file here.

And you can find more information about volumes in those sites: docs, cgwiki, applied houdini tutorial series.

That was all for this post,
thanks for reading 🙂

Advertisements
Houdini tip | Houdini native SDF volume into VDB conversion