Converting a stage from Z-up axis to Y-up axis, lessons in referencing / sublayering

Hi All!

I’m trying to standardize a process for taking thumbnail images of USD scenes. Once hiccup I’ve run into is when the scene has a different up axis. I’d like to standardize this process to always adjust the incoming scene to be Y-up. It seems to me there is a simple way of using references or sublayers with an Xform to do this but I can’t find it. Here is what I’ve tried and where I’m at right now:

  1. Idea: Sublayering: I’ve tried sublayering the Z-up file in a new USD file, and adding a defaultPrim which performs the rotation I want
  • Result: this ends up rotating the stage itself to open correctly (Y-up) but the geometry stays in it’s original orientation
  1. Idea: Creating a root Xform to wrap all top layer prims: I’ve taken all top level prims and put them in a new Root Xform prim that performs the rotation
  • Result: the geometry ends up correct in this case however all my material references become broken because my material binding paths are all broken. The USD files I’m currently working through come from Blender which exports all the materials in a _materials node at the top level, so I’m also putting this _materials node under Root so my bindings look like rel material:binding = </_materials/myMaterial> but the path is wrong and should be rel material:binding = </Root/_materials/myMaterial>
  1. Idea: Exclude top level materials from the root node: I tried to do the same as Idea 2. but exclude the _materials node, thinking that then all my bindings would still be correct.
  • Result: This did not work and I get this error when opening up my stage in usdview: Warning: ...</Root/myGeometry.material:binding>: The relationship target </_materials/myMaterial> from </myGeometry.material:binding> in layer @Z-up.usdz@ refers to a path outside the scope of the reference from </Root/myGeometry>. Ignoring. (getting targets for relationship </Root/myGeometry.material:binding> on stage @y_up.usda@)
  1. Idea: Do the same thing as 2, but find all the material references and fix them (prepend Root to them):
  • Result: This approach is working but feels inefficient and wrong because _materials won’t always be at the top level, but searching for all of those also seems like overkill

Am I missing some usage / syntax of referencing or sublayering that would fit nicely here?

Thanks for any help!

You could avoid the whole sublayer/reference thing. Just loop over all the Xformable root prims and make an over which prepends the axis transform.

Yeah, assuming you don’t actually want to edit the original asset, then subLayering or referencing should give you equivalent results, as long as you do what @jerry.huxtable advises, in the new root layer… you may need to be a bit more careful in the sublayering approach, though, because it is possible that some root level prim is directly referenced into/under some composition in one of the other trees in the layer. In our pipeline we might do that inside an asset, but only for non-geoemtry prims, and the intent is still that only the asset’s defaultPrim will be pulled into higher-level compositions. But because USD doesn’t impose any hard-and-fast laws about scene composition, it could happen.

And unfortunately there isn’t any exposed “prepend” operation for xformOpOrder, so you’ll need to fetch and mutate the value directly yourself.

Thank you both for the replies!

It’s helpful to know I wasn’t missing some silver bullet, and these suggestions make sense.

The thread here (Slack) has also been helpful to raise awareness and explain why the form of the files I’m looking at could be improved.

Appreciate the help!