Search - User list
Full Version: Correct way to create variants based on activation?
Root » Solaris and Karma » Correct way to create variants based on activation?
localstarlight
I have a USD of a boat, with two different options for masts in it. I want to create a variant for each. I thought maybe I could run an initial prune node (using deactivate) to get rid of one of them (so this could be the default). And then create a branch with using configure primitive nodes to turn off the default one and activate the other one, and then feed that into an add variant node.

However, when I try this, and then use set variant, it doesn't do anything. This is my first time actually using Solaris without following a tutorial so it's clear there's some basic USD stuff I don't quite understand yet.

What would be the correct way to go about building variants that are essentially different iterations of different components being activated or not?
jparker
If you're intending the boat to become an asset in a larger scene, I recommend setting it up using the Component Builder framework. You can use a pre-existing USD as an input file in the "Component Geometry" node, then in different branches you can activate / deactivate the masts and plug them into component geometry nodes.

If you're new to Solaris but have some Houdini experience I recommend Peter Arcara's tutorials here:
https://www.sidefx.com/tutorials/usd-asset-building-with-solaris/ [www.sidefx.com]
tylerart
I have run into the same issue. It appears that a prim can have it's activation turned off in a variant, but not on. If I create a cube and a sphere, and turn the sphere active attribute off and save it as .usd, the sphere data saves properly.

def Xform "asset"
{
    def Cube "cube1"
    {
        float3[] extent = [(-1, -1, -1), (1, 1, 1)]
        double size = 2
        matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) )
        uniform token[] xformOpOrder = ["xformOp:transform"]
    }

    def Sphere "sphere1" (
        active = false
    )
    {
        float3[] extent = [(-1, -1, -1), (1, 1, 1)]
        double radius = 1
        matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) )
        uniform token[] xformOpOrder = ["xformOp:transform"]
    }
}

Notice "active = false" under "def Sphere". Now, I create a variant set with a variant, set the active on the sphere to true, and set the active to the cube to false.

over "asset" (
    prepend variantSets = "geo"
)
{
    variantSet "geo" = {
        "sphere_on" {
            over "cube1" (
                active = false
            )
            {
            }

            over "sphere1" (
                active = true
            )
            {
            }

        }
    }
}

The cube turns off, but the sphere doesn't turn on. Even when I'm setting these opinions up on another layer, I'm still not seeing the sphere turn on. This appears to be a USD-thing, as usdView also shows the variant having both elements off.

Does this make sense to anyone? The code seems like it should be overriding the active = false. I could remove the active = false on the sphere creation, have both the cube and sphere active by default, then create 2 variants, only setting active = false. This ultimately means that any asset that has a variant requires a variant to always be set, and removing the variant with "clear from active layer" would break the asset prims. Is there a solution to this?
tylerart
Ok, I think I figured out that I have to reference the asset file directly into my stage, I can't just pipe into a new reference node with a new layer. Once I've referenced the file directly, it seems to work fine. I'm guessing there's a flag somewhere that I need to set, just not sure what I'm missing.

An additional thought - If you have a scope with prims inside them, and deactivate the scope, you can't re-activate the scope again to bring those prims back, despite the data being in the usd file. It seems that the data below the scope is no longer accessible?
goldleaf
tylerart
Ok, I think I figured out that I have to reference the asset file directly into my stage, I can't just pipe into a new reference node with a new layer. Once I've referenced the file directly, it seems to work fine. I'm guessing there's a flag somewhere that I need to set, just not sure what I'm missing.

I'm not sure if this is the original thread/question, but your issue is related to composition strength ordering LIVERPS: the variant set opinions (i.e. "V") are weaker than the direct layer opinions (i.e. "L"). When you defined the sphere, you authored an active opinion. When you referenced the asset into a scene, that weakened the activation opinion on sphere1 down to an "R", and therefore the "V" opinion won out.

Also worth mentioning, USD does not allow animating Activation or Variant Sets selections. Sometimes Solaris gives the illusion that it can, because you can animate a LOP node, and it recooks and sets activation as the time changes. But when you write out your animation to disk, you'll only see the last value authored. Whereas with visibility, you would see multiple time-samples animating the objects on/off.

tylerart
An additional thought - If you have a scope with prims inside them, and deactivate the scope, you can't re-activate the scope again to bring those prims back, despite the data being in the usd file. It seems that the data below the scope is no longer accessible?

Setting active on the prim should compose the children prims into the stage. I think the only time the children of inactive prims are fully and completely removed, is when you flatten the stage. Otherwise, the data is still there, but just not loaded into memory.

Hope this helps!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB