Fix UDIM path resolution for scene index plugins #3494
+83
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change(s)
Implement a specialization of UsdImagingDataSourceAttribute
that properly resolves UDIM relative paths.
Note that I have not created a unit test, or run the unit tests yet. I'm posting this PR early because there is an obvious issue that I want to discuss, namely the correct "location" for this code change. This change, as is, will affect all SdfAssetPath attributes read from USD and accessed by hydra. It is not clear to me if this is a good thing or a bad thing.
If it's a bad thing, I can take this UsdImagingDataSourceAttribute sepcialization and move it to dataSourceMaterial.cpp instead. Then in _UsdImagingDataSourceShadingNodeParameters::Get, I can conditionally create this data source for SdfAssetPath attributes instead of calling UsdImagingDataSourceAttributeNew to get the "standard" SdfAssetPath handler.
Alternatively, UsdImagingDataSourceAssetPathAttribute could be defined and implemented in dataSourceAttribute.h/cpp, but the standard factory would still return a vanilla UsdImagingDataSourceAttribute. But in dataSourceMaterial.cpp I could introduce the condition to use UsdImagingDataSourceAssetPathAttribute for SdfAssetPath attributes. This has the nice feature that if any other scene index code wants to support UDIM translation, the specialized subclass can be shared.
I personally think the universality might be a good thing as if some renderer supports UDIMs on a procedural or other custom prim type, they won't have to jump through hoops or create a custom data source to handle that case. The downside is every time hydra accesses an SdfAssetPath attribute, we will scan that string looking for "". To me this seems like a small price, but happy to accept Pixar's judgement on this and alter this PR as needed.
Fixes Issue(s)
#3492
Checklist
[ X ] I have created this PR based on the dev branch
[ X ] I have followed the coding conventions
[ ] I have added unit tests that exercise this functionality (Reference:
testing guidelines)
[ ] I have verified that all unit tests pass with the proposed changes
[ X ] I have submitted a signed Contributor License Agreement (Reference:
Contributor License Agreement instructions)