Building MaterialX Tools in Houdini (Patreon)
Downloads
Content
The Karma renderer in Houdini is built around the open source MaterialX workflow. In general, MaterialX is powerful and easy to use, but there are a number of usability speed bumps compared to other renderers, one of the most noticeable being the lack of high level tools. MaterialX is designed to be modular with the idea that users will create node graphs to suit their needs.
For example, most other renderers have ramp and noise generation utilities that combine a lot of functionality into one tool. MaterialX has the building blocks to do this, but you have to assemble them yourself. This can often require a fair bit of technical knowledge.
I little while ago I created a few tools in Houdini to fill some of these MaterialX-related usability gaps. I focused on three areas: texture importing with color correction and UV transformation, ramps that include options for circular and diagonal layout, and a noise tool that combines the basic MaterialX noise nodes into one interface.
You can download the HDAs at the end of the article. Place them into your Houdini "otls" folder and you should be good to go. Only non-commercial sessions of Houdini are supported for now, but I'm working on making these available for commercial Houdini.
With all that out of the way, let's dive in!
BHGC MtlX Image Plus
My idea with BHGC MtlX Image Plus was to combine the MtlX Image node with color correction tools and add the ability to control the scale, translation and rotation of the image. Here's the complete VOP network:
1. MtlX Place2D to enable translation, rotation and scale.1a. MtlX Constants for each Place2D input.1b. MtlX Combine2 to pack up the constants to meet the input requirements for Place2D.1c. Import geometry UVs using MtlX Texcoord.2. The core of the tool, MtlX Image.3. Color correction nodes, starting with MtlX HSV Adjust.4 and 4a. MtlX Contrast, with Pivot and Amount split off to float constant inputs.5. MtlX Add to create an offset function.6. MtlX Invert.7. A final MtlX Switch to choose between the inverted and non-inverted version of the image.
To make a usable tool, each of these nodes requires the creation of a parameter interface for the VOP subnet. Every relevant parameter should be linked to a corresponding one with a user-friendly name. For example, for the Invert option I created a toggle widget, copied its value, and linked it to the "which" parameter on the switch node.
Here's the whole thing in action! As you can see, it was fairly easy to create a powerful texture import tool using MaterialX building blocks.
BHGC MtlX Noise Plus
MaterialX includes a few basic noise nodes which are fairly lackluster in comparison to the extensive collection of native Houdini noises. Still, they're enough for creating basic procedural roughness or displacement textures, masks, and more.
The VOP network for this tool is very simple. UV coordinates are brought in and used for the same transformation tools as Image Plus, there's a switch between the three noise types, and finally some grading tools. Create a top level parameter interface and done!
BHGC MtlX Ramp Plus
This is where things get a bit more tricky. The challenge here was setting up the math to create diagonal and circular ramps. You need to take the input UV coordinates and transform them according to established math formulas.
I was able to find the required formulas online, so what remained was to execute them using MaterialX's building blocks. Thankfully, MaterialX has a large library of math functions.
1. Bring in the geometry UVs.2. Circular ramp math.3. Linear ramp math.4. Diagonal ramp math.5. Switch between the three different ramp types.6. Core ramp node.7. Grading functions.
At the heart of all this I used the custom MtlX Color Ramp that comes with Houdini. It provides some much needed quality of life upgrades compared to the barebones native MaterialX ramp tools. Leading into it is a switch to change between linear, diagonal and circular UV transforms. The tool closes out with some grading controls.
Conclusion
MaterialX is a powerful system but it does require some technical knowledge to make the most of. I hope you find these three tools useful and also gained some knowledge to begin building your own!