-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EMSUSD-280 import relative textures #3259
Changes from all commits
5f82786
0ea58bf
bb8a664
c7f1144
90150d3
985674a
2d0fd50
7527584
1046343
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
// limitations under the License. | ||
// | ||
#include "mtlxBaseReader.h" | ||
#include "shadingAsset.h" | ||
#include "shadingTokens.h" | ||
|
||
#include <mayaUsd/fileio/shaderReader.h> | ||
|
@@ -118,34 +119,8 @@ bool MtlxUsd_ImageReader::Read(UsdMayaPrimReaderContext& context) | |
} | ||
|
||
// File | ||
VtValue val; | ||
MPlug mayaAttr = depFn.findPlug(TrMayaTokens->fileTextureName.GetText(), true, &status); | ||
|
||
UsdShadeInput usdInput = shaderSchema.GetInput(TrMtlxTokens->file); | ||
if (status == MS::kSuccess && usdInput && usdInput.Get(&val) && val.IsHolding<SdfAssetPath>()) { | ||
std::string filePath = val.UncheckedGet<SdfAssetPath>().GetResolvedPath(); | ||
if (!filePath.empty() && !ArIsPackageRelativePath(filePath)) { | ||
// Maya has issues with relative paths, especially if deep inside a | ||
// nesting of referenced assets. Use absolute path instead if USD was | ||
// able to resolve. A better fix will require providing an asset | ||
// resolver to Maya that can resolve the file correctly using the | ||
// MPxFileResolver API. We also make sure the path is not expressed | ||
// as a relationship like texture paths inside USDZ assets. | ||
val = SdfAssetPath(filePath); | ||
} | ||
|
||
// NOTE: Will need UDIM support and potentially USDZ support. When that happens, consider | ||
// refactoring existing code from usdUVTextureReader.cpp as shared utilities. | ||
UsdMayaReadUtil::SetMayaAttr(mayaAttr, val); | ||
|
||
// colorSpace: | ||
if (usdInput.GetAttr().HasColorSpace()) { | ||
MString colorSpace = usdInput.GetAttr().GetColorSpace().GetText(); | ||
mayaAttr = depFn.findPlug(TrMayaTokens->colorSpace.GetText(), true, &status); | ||
if (status == MS::kSuccess) { | ||
mayaAttr.setString(colorSpace); | ||
} | ||
} | ||
if (!ResolveTextureAssetPath(prim, shaderSchema, depFn, _GetArgs().GetJobArguments())) { | ||
return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That error is not fatal. Please continue loading the other USD attributes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IDK what is best here and the other place that uses that function. I'll do what you suggest, we can revisit the best practice in the future. Note that in the original usdUVTextureReader, many error were considered fatal, so I'm just keeping the existing behavior. |
||
} | ||
|
||
// Default color | ||
|
@@ -158,8 +133,9 @@ bool MtlxUsd_ImageReader::Read(UsdMayaPrimReaderContext& context) | |
} | ||
|
||
// Filter type: | ||
mayaAttr = depFn.findPlug(TrMayaTokens->filterType.GetText(), true, &status); | ||
usdInput = shaderSchema.GetInput(TrMtlxTokens->filtertype); | ||
MPlug mayaAttr = depFn.findPlug(TrMayaTokens->filterType.GetText(), true, &status); | ||
UsdShadeInput usdInput = shaderSchema.GetInput(TrMtlxTokens->filtertype); | ||
VtValue val; | ||
if (status == MS::kSuccess && usdInput && usdInput.Get(&val) && val.IsHolding<std::string>()) { | ||
std::string filterType = val.UncheckedGet<std::string>(); | ||
if (filterType == TrMtlxTokens->closest.GetString()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the
makeProjectRelatedPath
method? Seems likemakeProjectRelatedPath
handles all the checkings and returns the related pathThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because this function wants to make a true relative path, but makeProjectRelativePath makes an absolute path, but relative to the absolute path of the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see