Ooo, first proper USD jargon, exciting!
Variants are a pretty simple idea. You've probably created Houdini setups with a switch node to allow you to swap between 2 branches of sops, or a high and low quality, or sim vs non simmed etc. Maybe you exposed that switch as part of some HDA controls cos you're amazing.
A variant is the same, but defined in the USD file format, not in the DCC. This is where USD starts to diverge from other 3D file formats; bgeo, alembic, fbx etc don't have the concept of switches or toggles within their file format, USD does.
Lops exposes variants like this:
Basically setting up a switch right? This setup lets you swap between an untextured and textured pig, the setup is pretty much as it looks:
- Make 2 copies of the reference node for the pig, pull them to one side
- Copy the material library, wire it under the second reference, drag in the reference node from the scene graph tree to the geometry path parameter to assign it
- Create a Add Variants to New Primitive node, wire the untextured reference and the material library to the second input
Done! Notice that in the Scene Graph Tree there's now text in the 'variants' column.
To toggle the displayed variant you can either:
- Append a set variant node. The variant set will be already selected. Choose the variant you want from the 'variant name' parameter.
- r.click on the variant in the scene graph tree, model -> choose from the reference node or the material in the menu. This will create a set variant node and fill it out for you.
You might've noticed that there's a 'model:' prefix on the variant. This is because you can have multiple variants on the one object. It's a bit tricky to understand how multiple variants interact, but ultimately you can chain multiple add variant nodes together, each with their own 'variant set' name, and they'll be presented as a list of menus:
You might've also noticed that the default naming of the nodes and variant choices are awful. By default lops uses the names of the network nodes, the fastest way to tidy this up is to use some nicely named nulls, the name of the add variant node, and a cheeky $OS call, to tidy all this up:
And how that looks in the Scene Graph Tree. Much nicer.
More USD terminology
As we're getting deeper, it's time to start talking more native USD. One of the key concepts is primitives, or prims. While Houdini prims are things like polygons, sphere prims, packed prims, because USD is mostly concerned with scene hierarchies, it calls items within the Scene Graph Tree prims. So a reference node is a prim. A xform is a prim. A material is a prim, a shading node, a camera, a light etc. Anything that appears in the Scene Graph Tree is a prim. Cool? Cool.