Houdini Volume Gradients are Like Surface Normals

I’d seen volume gradients used in a few places and not really understood them. Houdini help says: “the gradient is a vector pointing in the direction of increasing volume values.” Hmm. Nothing if not laconic.

Equally gnomic, but more helpful, u/ZeScarecrow on r/houdini says: “think about volume gradient vectors as surface normals.”

u/frigge expands: “if you store a solid object as an SDF in a voxel grid, the gradient of that grid will be exactly the surface normal (at the surface of the object).”

So if you have a point on the surface of an SDF volume, and you want the same vector as that point’s surface normal i.e. the vector perpendicular to the surface at that point, just grab the volume gradient at that location.

This is very helpful if you want to erode or dilate an SDF volume or if you want to make points conform or ‘stick’ to its surface. In the Entagma video below, linked at 07:16, Manuel explains how to use the volume gradient to move a point from an arbitrary location in a voxel grid to its nearest location on the surface of an SDF volume.

The theory behind SDFs and volume gradients

If I’ve understood the theory bit correctly, since the values in the voxel cells of a signed distance field become higher the further those voxel cells are from the surface of the volume, the volume gradient at a point simply traces the steepest gradient of those values from that point, i.e. the path which has those values rise fastest. For any point on the surface, the gradient will shoot out perpendicular to the surface, much like a normal. For a point not on the surface, you can trace a perpendicular path back to that surface (and hence a nearest point) simply by inverting that vector.

Another example: volume gradients were useful when creating the custom erode function for this melting ice sculpture.

Noised erosion function, using volume gradients

Using a Volume VOP, shown below, the volume gradient is inverted so we get a vector pointing inward from the surface of the volume. Then a three dimensional noise is added to the the vector so that the erosion proceeds in an irregular and art directable manner.

Volume VOP node diagram – click to enlarge

Finally, because I wanted the top of the sculpture to melt faster than its base, which is what my reference videos seemed to show, I damped the magnitude of the erosion – in all dimensions – as the y-value decreased. The VOP creating the erosion vector was then just situated in a SOP solver, shown below, that advected the volume on each time step.

SOP solver for eroding volume each frame

Leave a comment

Your email address will not be published. Required fields are marked *