I noticed that people Modeler for Houdini Discord group were interested in SDF boolean operations, so I decided to create a simple example of SDF usage and share some of my notes.
There are two versions of the same example file:
VDB_SDF_Modeling.hiplc - The original file, but it contains nodes from Modeler 2023.4 plugin.
VDB_SDF_Modeling_Stashed.hiplc - A copy of the first file in which I replaced all operations from the Modeler 2023.4 plugin with Stash nodes.
If you do not have Modeler plugin, then download the second file and you will still get an idea of boolean operations using SDF volumes.
The file contains examples of using the following nodes and operations:
VDB from Polygons (to convert polygonal geometry to SDF volume).
VDB Smooth SDF (to smooth edges of geometry similar to the results from polygonal round bevel).
VDB Resample (to change voxel density to increase object detail).
VDB Combine (to apply boolean operations: SDF Union, SDF Difference, SDF Intersection).
VDB Reshape SDF (to expand or narrow voxel shapes, similar to the Peak operation).
VDB Convert (to convert SDF into polygonal geometry).
Volume Deform (to deform voxel shapes by using Lattice from Volume node in conjunction with Bend node to deform point grid which represents voxel grid).
Name and Attribute Edit String (to build hierarchy of LOP primitives while working in SOP)
Notes about using SDF nodes:
- Increase voxel density only when necessary. Generally, I used a voxel size of 0.02 when converting geometry through VDB to Polygons and could move shapes interactivly. However, in some cases, I needed narrower or smaller bevels and increased density to 0.01 voxel per unit in exchange to performance.
- After all operations, you can also increase voxel density through VDB Resample to get a denser and more detailed polygonal mesh from Convert VDB.
- Use different smoothing modes to maintain performance. Instead of increasing the number of smoothing iterations in VDB Smooth SDF, try to change the type of operation: Mean Value for normal smoothing, Gaussian for strong smoothing, Mean Curvature Flow for weak smoothing or smoothing small details.
- If you need to place one object inside another, for example a button in a housing, use VDB Reshape SDF to expand the SDF before boolean subtraction.
- I didn't find a way to store color in SDF and pass it through boolean operations, so after converting to polygons by Convert VDB I used Bounding Volume parameter in Group node to select the area that I want to color using SDF volume.
- Deform objects in voxels through Volume deform instead of deforming them in polygons. This is convenient because the bend deformer when used on polygons will not be able to bend the area where not enough geometry, but through Volume deform, you bend a point grid, so you can bend and deform even each pair of voxels.
Notes on modeling in SOPs within LOPs:
- To improve performance, prevent SOP from the constant transferring of data to LOPs. To do this, place Output node inside the SOP and connect the geometry to it only when you want to transfer it to the LOP, otherwise keep geometry disconnected.
- The same goes for working inside Component Geometry node: connect geometry to the default, proxy, and simproxy output nodes only when necessary, otherwise, the entire node tree will be recalculated with every change.
- Start building hierarchy of LOP primitives while still in SOPs. Hierarchy construction will occur from top to bottom, from leaf to root. At the very beginning (for leaves), add Name node that will create the corresponding attribute and enter the geometry name into it, for example, Mesh. Then add an Attribute Edit String node, specify that you want to edit Name attribute, and in Editor tab, set "*" (all existing names) in From parameter. To the To parameter add the name of the LOP primitive where you want to place the geometry, like "Primitive/*". Thus, the Name attribute will become "Primitive/Mesh". Further, continue to add Attribute Edit String nodes with the same parameters to assign more parents or to group primitives after merging. The last Attribute Edit String will have "/*" name set in To parameter and will close the path (for example, "/Gamepad/Triggers/Primitive1/Mesh").
I've used the video as reference for the model.