The Complete Houdini: Retopology and Baking (8/x) (Patreon)
Content
When working with sculpted geometry it’s common to need to create custom, low-poly topology and to “bake” the high resolution details from the sculpt down to a texture. There are many workflows for accomplishing this in other apps, but it’s perhaps not so well-known that Houdini can do it all too. Let’s look at how!
Retopology
Houdini has an excellent node called TopoBuild. This is a flexible tool that lets us create new topology on top of an existing mesh. This task is a frequent step in the sculpting process. Say you’ve made a very high resolution model of a face in ZBrush. It has all the fine details you created, right down to the smallest pore, but it’s also very dense at tens of millions of polygons.
It's not practical to use this heavy mesh for much else besides a static render. It will be slow to load, take up lots of memory in the renderer, and be useless for animation. To solve this problem, we create low-poly versions of our models. ZBrush offers an automated ZRemesher tool for this task, and of course apps like Houdini and others have multiple ways of auto-generating low poly meshes.
The problem with this approach is that often you want a specific flow in the mesh: edges that align with important features, greater density in areas with finer details, etc. In order to get the desired flow the best option is to manually create topology.
Houdini’s TopoBuild works by accepting Template Geometry, then allowing us to draw and edit new interconnected polygons on its surface. It’s surprisingly easy to use and has lots of nice features.
For this article I’ll use a small model of some lips that I created in ZBrush. I added quick and dirty skin details using alphas from the very nice FlippedNormals Skin Kit (https://flippednormals.com/product/flippednormals-skin-kit-466). Our job is to take this high resolution model and create a low poly one with TopoBuild.
If we just auto-remeshed this we’d potentially lose the contour of the line that delineates the upper edge of the lips, the line between the lips, and a few other spots. When building the topology manually we can make sure to create continuous edges around these features, thereby maintaining their clarity even while significantly reducing the number of polys.
Start by importing a model using a File node and connect it to the second input of a TopoBuild node. Make sure the Template flag is enabled on the model.
Select the TopoBuild node and press Enter in the viewport to enable viewport interactivity. Start by creating four points to outline the first quad and pressing Enter to finalize it. (Pressing Escape exits out of whatever the current action is.)
We can click and drag points or edges to reposition them.
We can “extrude” edges into new, connected quads by clicking on an edge, releasing the mouse, the clicking again to place a new edge. This is a fast way to fill out entire sections. Points on the new edge will snap to existing points.
There is a Brush tool for moving points and a Relax tool to spread points more evenly.
Additionally, there are some great tools for aligning, straightening and circularizing polygons, plus adding edge loops. The keyboard shortcuts are all listed in the Hints overlay in the viewport.
After a bit of work I got some rough base topology that I was happy with.
I then subdivided it and added a new TopoBuild node, this time with the original high poly mesh connected to the Template input and the new base mesh connected to the Mesh Geometry input. This lets us continue to edit the newly subdivide mesh with TopoBuild tools and make sure the edits conform to the template.
I used the Smooth tool to distribute the polygons more evenly and nudged things around as needed.
To finalize the new mesh I added a Mirror node and Fused the center points together. Lastly, I added a Smooth node to, well, smooth the surface a bit, plus a Labs Auto UV since we’ll need UVs to bake our texture in the next step. Done!
Baking
We’ve got a new low poly mesh that meets our requirements, but it’s also missing all our nice details. The next step in this process is to bake the difference between the high resolution original mesh and the new low poly one into a texture. We can use this texture as a displacement map in our final render. We get the best of both worlds: a very light base mesh that takes up almost no memory and a separate height map that we can use to dial in details in our render.
To accomplish this in Houdini we’ll use Labs Maps Baker. This tool can bake a lot of different types of maps, including curvature, ambient occlusion and more. We’ll focus on height for this project.
Simply connect our base mesh to one input and the high resolution original mesh to the other. I added a Subdivide node to the base mesh to smooth it out. You might get some edge artifacts in the resulting texture otherwise.
Next, enable height map generation, choose the file name and resolution and Max Trace Distance.
This latter setting is important as too small of a distance will “clip” the texture. Max Trace Distance sets how far the baker searches above or below the surface of the mesh. If our high resolution mesh has points that are 1 unit above our base mesh and our trace is set to only 0.5 unit, then we’ll be missing a lot of important information. You can visualize the trace distance using the associated check box and set the Template flag on the high resolution mesh to gauge if there are any overlaps.
As an example of what happens if the trace distance is too low, here’s a sphere with some noise applied and baked to a height map. On the left, the trace was set to 0.005, on the right, 0.06. The right is correct and captures all the details, while the left is clipped with any height value over 0.005 being truncated to 0.005.
Back to our lips model! After everything is set up, click the Render button and we’ve now got our height map saved to disk.
Results
We can bring our height map into any renderer to see how it looks. I’ll use Solaris here to set up a quick test scene. Import the low resolution model and assign a material to it. Plug the new height map into the displacement section of the material and dial in the values as desired. Perfect! All our skin detail is there even though the new underlying model has absolutely none.
As a result of our TopoBuild work we reduced the original model from 211,968 polys to an incredible 1,760!