Referenced primitives broken after saving an asset as usd

   1439   1   2
User Avatar
Member
23 posts
Joined: Sept. 2021
Offline
Hi

we're setting up an asset that has lights on it. We want to use variants for this so variant A should be no lights, variant b should be with lights. Further this asset has a lot of lights so we used the point instancer node (Method set to Reference) to create them.
This works all fine in the scene. However when we save the file (Savestyle set to Flatten All Layers)and then use a Reference to bring back the usd file the light References are broken - it works however with a sublayer. But the way our scenes are set up we need it to work with a reference.

What are we doing wrong?

Attached is a small test scene to show the problem.

Attachments:
toSFX_pointInstancer.hip (259.1 KB)

User Avatar
Staff
4438 posts
Joined: July 2005
Offline
This was an interesting one. I think there is a change we can make to the Add Variant LOP to prevent this situation going wrong like this, but first the explanation. It's a little easier to talk about this if the "reference" LOP references the lights onto a prim called /foo instead of /abc, so you may want to set reference1's Primitive Path to /foo, and setvariant1's Primitives to /foo/xyz in your file. If you look at one of the lights in setvariant1 (say "/foo/xyz/addpointinstancer1/Instance0"), and look at the metadata tab of the scene graph details pane, you can see that this prim has a reference to "/abc/xyz/addpointinstancer1/Prototypes/lights/light1" (critically it is "/abc/...", not "/foo/..."). This means that the target of the reference is the prototype prim _on the referenced layer_, not on the fully composed stage. The decision to switch to the "on" variant is being made on the sublayer that is referencing the file. So while composing within the reference, the attempt to look at "/abc/xyz/addpointinstancer1/..." fails, because within the context of the referenced in file, the light prim doesn't exist, because the variant is set to "off".

If you set the default variant to "on" _within_ the file written to disk that is referenced in, then the attempt to internally reference "/abc/xyz/addpointinstancer1/..." works fine because within the referenced file that prim is composed into existence.

When you sublayer in the file from disk rather than reference it, everything works because the internal reference to "/abc/xyz/addpointinstancer1/..." is happening in the context of the composed sublayer stack where the variant opinion is authored, so the target prim _does_ exist, ragardless of the variant selection made within the file on disk.

The solution to this, I think, is for the Add Variant LOP to update internal references as it creates the variant, pointing them to a prim within the specific variant making the reference. So instead of referencing "/abc/xyz/addpointinstancer1/Prototypes/lights/light1", it would reference "/abc{light=on}xyz/addpointinstancer1/Prototypes/lights/light1". This way it can find the target of the reference even if in the composition context of the refrence the variant selection may be different (light=off).

There may be complications with such an approach that I'm not able to see right now, but I think this should be possible...
  • Quick Links