How to Create Puzzle Mattes in Houdini
Creating puzzle mattes in Houdini using the Karma renderer in Solaris can streamline your compositing workflow, similar to Object IDs or Matte passes in other renderers like Octane or Redshift. This guide will guide you through setting up consistent render AOVs using RGB channels in the Solaris workflow. Look, it’s not THAT hard okay, I promise.
But if you do prefer to watch this rather than read, here is the video:
What even is a Puzzle Matte?
A puzzle matte allows you to separate different objects or groups of objects into distinct colour channels (typically red, green, and blue) in a single render pass. This provides a powerful way to isolate and manipulate elements in your compositing software, giving you fine-grained control over your final image.
Now don’t get me started on why you would want this over a Cryptomatte. They both have their benefits, but I just love a good puzzle matte though.
Setting up Puzzle Mattes in Solaris
1. Scene Preparation
Start with your scene in Houdini. For this example, we'll use a scene with text, puzzle pieces, and a background, and we want to separate these into different channels.
2. Creating Primvars with a Wrangle SOP
In Solaris, "primvars" are the equivalent of attributes. You'll use a Wrangle SOP to create and assign these primvars to your geometry.
Add a Wrangle SOP: Place a Wrangle SOP in your network (after your geometry, please).
Create the Primvar: In the Wrangle's Vex expression, you'll first create the primvar. This defines the name and type of your puzzle matte. The
usd_addprimvar
function is used for this.usd_addprimvar(0, "/", "PuzzleMatteName", "colour");
0
: Refers to the first input of the Wrangle."/"
: Represents the root path, meaning it applies to everything coming through."PuzzleMatteName"
: This is the name of your puzzle matte. You can customise this (e.g.,PuzzleMatte01
)."colour"
: Specifies the data type of the primvar.
Assign the Primvar to Geometry: Next, you'll use
usd_setprimvar
to assign specific colours to different parts of your geometry. You'll typically do this for each element you want to isolate.usd_setprimvar(0, "/YourGeoPathHere", "PuzzleMatteName", {1, 0, 0});
0
: Again, refers to the stage handle."/YourGeoPathHere"
: This is the path to your specific geometry in the scene graph. You can drag the node for your geometry (e.g., "text", "puzzle_instance", "floor" ) from the scene graph into the Wrangle's expression editor to get the correct path."PuzzleMatteName"
: This must match the name you defined inusd_addprimvar
.{1, 0, 0}
: This is a vector representing the RGB colour.Red Channel:
{1, 0, 0}
Green Channel:
{0, 1, 0}
Blue Channel:
{0, 0, 1}
You'll repeat the
usd_setprimvar
line for each object you want to assign a colour to, changing the path and the colour value accordingly. For example:For your text (red channel):
usd_setprimvar(0, "/geo/text", "PuzzleMatte01", {1, 0, 0});
For your puzzle pieces (green channel):
usd_setprimvar(0, "/geo/puzzle_instance", "PuzzleMatte01", {0, 1, 0});
For your background (blue channel):
usd_setprimvar(0, "/geo/floor", "PuzzleMatte01", {0, 0, 1});
3. Configuring Karma Render Settings
Once your primvars are set up, you need to tell Karma to render them as extra passes.
Open Render Settings: Go to the Karma Render Settings node.
Image Output: Navigate to the "Image Output" tab.
Extra Render Vars (AOVs): Scroll down to "Extra Render Vars" and click "Create".
Configure the AOV:
Name: Give your AOV a descriptive name (e.g.,
puzzle_matte_01
). This is what will appear in your render passes.Format: Set this to "Colour 3".
Data Type: Set this to "Colour 3".
Source Type: Choose "Primvar".
Source Name: This is crucial – it must exactly match the
PuzzleMatteName
you defined in your Wrangle SOP (e.g.,PuzzleMatte01
).
After these steps, when you view your render, you should see your puzzle_matte_01
pass with your text, puzzle pieces, and background colored red, green, and blue, respectively.
Workflow for SOP Context
Sometimes, creating these attributes at the SOP (Surface Operator) level is easier, especially if you have complex geometry or many distinct parts you want to target.
Attribute Create SOP: In the SOP context, use an Attribute Create SOP.
Name: Name the attribute the same as your desired primvar (e.g.,
puzzle_matte_02
).Class: Set the class to "Point" or "Primitive".
Type: Set this to "Float".
Size: Set the size to 3 for an RGB colour.
Value: Input your RGB colour values (e.g.,
{1, 0, 0}
for red).
When you bring this geometry into Solaris using a SOP Import node, the attribute you created in the SOP context will be automatically converted to a primvar. You'll then follow the same steps in the Karma Render Settings to create an extra render variable, ensuring the "Source Name" matches the attribute name you used in the SOP context (e.g., puzzle_matte_02
).
Rendering and Compositing
These puzzle mattes will be included as separate channels in your EXR render output. In your compositing software (like Nuke or After Effects), you can easily access and use these individual red, green, and blue channels as masks to isolate and adjust different elements of your render.
Now go get puzzling!