Edit already existing variant

Hey all,

I am interacting with USD via the Houdini /stage context.

I have an asset that already has a variant set “outfits” defined.

It has different variants (“outfit01”, “outfit02”, “outfit03”, etc).

The variant set is saved on the “/root” primitive.

So far the different variants add new primitives (new outfit geometry).

In a second step I want to now add new materials and assign those to the new outfit primitives, potentially change some existing material assignments on other primitives.

I want to of course add that change to the respective existing variant. I don’t want to create a new variant set or new variants. If the user changes the ‘outfit01’ the geometry should change and the shaders.

I can’t really get it to work in Houdini.

A simplification of the setup looks like this:

Not that I deliberately didn’t put the shading stuff in the variants on the top, as this will happen in another houdini file in our pipeline.

From what I can tell I seem to basically overwrite the variants I created above with my setup. But how else would I solve this?

Hi @paulgolter, and welcome! You might get an answer here, but I think you might also want to post your question in SideFX’s forums?

Hey @spiff

Thanks, thats a good idea. Posted it there as well:

Hey Paul,

can you share the .hip file?

From what I can see from the picture there are two problems:

  • You are writing variant selections into the variants. You need to either put a layer break node after the setvariant5/6 nodes or set the variant before the variantblock_begin1 node.
  • Remove the assignmaterial1 node as it is writing to the layer directly and will always be stronger than the variants due to LIVRPS ordering.


Hey @LucaScheller

Good to hear from you :slight_smile:

Here is the hip file: (Needed to add .usd at the end otherwise I couldn’t upload it to this forum, just remove the .usd filename extension)

usd_variant_add_test .hipnc.usd (146.6 KB)

Hey so I was able to solve the problem.

I was indeed completely overriding the variants I defined previously by having the variantendblock directly in the main stream.

I needed to simply sublayer or merge it in to the mainstream to get the result that I want:

And the updatet hip file:
usd_variant_add_test_v002.hipnc.usd (126.2 KB)

I wasn’t able to remove the setvariant node because I would miss the primitive to assign the material to (as it is saved in the variant). But in order to no set the variant in the variant I needed to add another layer break node.

That way I have everything defined in my variant:

 variantSet "outfit" = {
        "outfit01" {
            over "geo"
                def Sphere "outfit_01" (
                    prepend apiSchemas = ["MaterialBindingAPI"]
                    float3[] extent = [(-1, -1, -1), (1, 1, 1)]
                    rel material:binding = </root/materials/outfit01>
                    double radius = 1
                    matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 1.9, 0, 1) )
                    uniform token[] xformOpOrder = ["xformOp:transform"]

            over "materials"
                def Material "outfit01"
                    token outputs:displacement.connect = </root/materials/outfit01/outfit01.outputs:displacement>
                    token outputs:surface.connect = </root/materials/outfit01/outfit01.outputs:surface>

                    def Shader "outfit01"
                        uniform token info:id = "UsdPreviewSurface"
                        color3f inputs:diffuseColor = (0.18, 0.763, 0)
                        token outputs:displacement
                        token outputs:surface



I’m fairly certain this is a Houdini bug, we had a similiar issue a while back with the addvariant node, looks like the bug re-appeared. I’d recommend reporting it to SideFX. Looks like they don’t merge the variants into the active layer, instead they just copy the content erasing anything pre-existing. You can also fix it by just starting a new layer before the addvariant node.

The begin variant edit performs a layer break already, so you can also do this:


1 Like

Hey @LucaScheller,

thanks that looks a bit cleaner! We are using 19.568, I will report it as a bug