Example - Volumetric Cheese


With its real-time Boolean operations, OpenVDB is ideal for creating complex shapes that can be animated. Here we'll use Primitive shapes to create a Swiss cheese object from a simple block. You can either create your own cheese block or load our provided scene:

Swiss Cheese Demo Swiss Cheese Demo

You can load the "from scratch" that provides the setup, the "finished" scene that contains the holes seen in the picture above or just load the cheese object. If you do that, read on and if not skip ahead to later in the tutorial.


  1. The cheese object in the archive is a simple polygonal model created by welding the corners of one side of a box. It was then chamfered, subdivided and subpatched, but otherwise untouched.


  2. It is sent to Layout, where it can be converted into an OpenVDB levelset volumetric object. To do so, add a Null called, perhaps, Volcheese and open the Object Properties for it. In the Object Replacement dropdown choose OpenVDB Evaluator then click  Properties. This will open a Node Editor where we will convert the polygons (subpatches) we have created into voxels.


  3. In the Node Editor, open the OpenVDB group on the left. Add the Mesh to Volume node and double click it to open the node window. We want to choose our polygonal cheese as the Target Mesh, change the Type from Fog Volume to Level Set and check Fill Interior. Close the Mesh To Volume window and hook its Grid output node to the destination Grid input.


  4. Now we have our volumetric object we can either move the polygonal version out of the way or hide it. Hiding it is achieved by going into the scene editor and choosing Hidden for the OpenGL level and unchecking the render column too. However, we can also see that our resolution isn't very good. The cheese has a pixelly look about it. Setting the Voxel Size to 0.02 in our Mesh to Volume node will improve that, but we are going to be adding lots of voxels so it would be better to set this once for everything. To do so, add a Constant > Scalar node, set it to 0.02 and take its output into the Voxel Size input on the Mesh to Volume node.


  5. Now we can start making our holes. Add a new null, call it Hole and make it a Primitive Shape, the default Sphere works perfectly for our needs. Parent it to the Volcheese object to make sure the hole moves with the cheese if you want to rearrange the cheese later. Position it on our Level Set object where you'd like the first hole to appear. Switch back to the Volcheese object and click Properties for the OpenVDB Evaluator to open the Node Editor again. Choose Shape to Volume, double click the node, choose your first Hole for the Source Primitive and check Fill Interior. Lastly, set the Space choice to Parent.


  6. Now we can cut the cheese (stop giggling at the back!). Once our Hole object is placed as we like, we can choose CSG from the OpenVDB group, which will bring in a node that we can use to cut the Hole object from the Volcheese. Double click the CSG node to change its operation to Subtract and hook the MeshToVolume node's Grid output to the Grid 1 input, and the Shape To Volume's grid output to the Grid 2 input. Lastly, take the CSG node's Grid output and hook it to the OpenVDB destination node's Grid input. If the hole doesn't appear right away for you, step the frame number forward and back


  7. The hole cut is still a little jaggy, so we can smooth things out by adding a Filter node just before the Destination. This Filter should be set to Gaussian and you can just put it between the CSG node and the Destination. It will round everything off a little to make sure there are no hard edges.


  8. All that remains now is to copy the Hole you created, move it to where you want to make a new hole, then copy the Shape to Volume node and assign it to your new hole, hook up the Scalar and add it to the New Grid input on the CSG node.


  9. Add as many holes in different sizes, shapes and rotations as you like. Our example at the top of the page also has some nodal displacement on the volcheese object, along with a cheesy yellow color.