Autodesk / Autodesk/maya-usd

Add ArResolverContext Support When Loading Stages

Open
#2,655 10 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Wolfram Language
Stars
905
Forks
223
Avg merge
2d 9h
Merged PRs (30d)
17

Description

**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](https://graphics.pixar.com/usd/release/api/class_ar_resolver.html#a37d32052831939332ecbff965ef94caf), 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](https://graphics.pixar.com/usd/release/api/class_ar_resolver.html#a37d32052831939332ecbff965ef94caf) or [ArResolver::CreateContextFromString](https://graphics.pixar.com/usd/release/api/class_ar_resolver.html#a6f01bf8462bf0ec118187e200df7e362)

**Additional Context**
It looks like contexts are already partially supported, to some extent, using [ArResolver::CreateDefaultContextForAsset](https://graphics.pixar.com/usd/release/api/class_ar_resolver.html#a0a174a99676ff983a183d391973c7ebe)

(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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in lib/mayaUsd/nodes/proxyShapeBase.cpp around lines 849-860, where the existing default resolver context support is implemented. Read the USD ArResolver context APIs linked in the issue and trace how a mayaUsdProxyShape stage is created or loaded. Done means Maya can accept removable scheme/text context rows and apply the combined context up front when loading the stage.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.