maya-usd icon indicating copy to clipboard operation
maya-usd copied to clipboard

Add ArResolverContext Support When Loading Stages

Open ColinKennedy opened this issue 3 years ago • 7 comments

Is your feature request related to a problem? Please describe. A big portion of what makes USD great is indirection - the ability to redirect a URI from scheme:foo.usda to instead go to scheme:bar.usda completely in-memory, using ArResolverContext. Having that feature in Houdini has been a huge boon for our pipeline and we'd like the same functionality in Maya. Without that feature, we're limited in the pipeline workflows that we can provide to artists.

Describe the solution you'd like When creating / generating a mayaUsdProxyShape, a Maya attribute could be used to provide extra context(s) used to manipulate the stage. Keeping in mind that the intent of this feature is to better support custom resolvers, I'd recommend implementing this feature via ArResolver::CreateContextFromStrings, where you can provide a list of scheme + text pairs to combine into a single context. And in Maya, an attribute where a rows of contexts can be added / removed at will.

Describe alternatives you've considered The best we can do right now, without this feature, is to resolve a stage (with contexts applied) in-memory and "bake" the results of the context indirection to a Layer and then try to load that via the mayaUsdProxyShape node. However upon testing, it looks like you cannot load anonymous layers that way. When I tried to write the anonymous layer's identifier into mayaUsdProxyShape but it doesn't appear to respect it and blows away any previous changes.

Anyway, that was an attempted hack and we don't want to be working like this, anyway. We'd rather provide the context up-front, using ArResolver::CreateContextFromStrings or ArResolver::CreateContextFromString

Additional Context It looks like contexts are already partially supported, to some extent, using ArResolver::CreateDefaultContextForAsset

(Existing maya-usd implementation: https://github.com/Autodesk/maya-usd/blob/c610a03ff7b333b4c04fac4333076896023289f2/lib/mayaUsd/nodes/proxyShapeBase.cpp#L849-L860)

That helps but there's caveats to that method, vs CreateContextFromStrings / CreateContextFromStrings. A more extensible solution would be to provide scheme + text directly, rather than doing an I/O round-trip. I can elaborate on this in the comments, if wanted.

ColinKennedy avatar Oct 14 '22 18:10 ColinKennedy