-
Notifications
You must be signed in to change notification settings - Fork 202
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
MAYA-121534 Mtlx subcomponent connections export #2211
MAYA-121534 Mtlx subcomponent connections export #2211
Conversation
- Adds only one new node: clamp -> ND_clamp_vector3 - Adds support for automatically adding conversions between vector and color types since Maya allows these kind of connections transparently. - Adds a lot of infrastructure to support exporting and importing connections at subcomponent level to and from USD/MaterialX. Builds on to of PR #2207, which must be merged before this one.
@@ -63,10 +63,7 @@ TfToken UsdMayaShaderReader::GetMayaNameForUsdAttrName(const TfToken& usdAttrNam | |||
return TfToken(); | |||
} | |||
|
|||
bool UsdMayaShaderReader::TraverseUnconnectableInput(const TfToken& usdAttrName) const |
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.
Removing const. Allows calling _GetArgs which is not.
@@ -90,58 +87,13 @@ UsdMayaShaderReader::ContextSupport UsdMayaSymmetricShaderReader::CanImport( | |||
return ContextSupport::Unsupported; | |||
} | |||
|
|||
static UsdMayaShadingNodeType | |||
_ComputeShadingNodeTypeForMayaTypeName(const TfToken& mayaNodeTypeName) |
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.
Moved to translatorUtil.cpp to be shared with Mtlx code.
@@ -27,6 +27,7 @@ list(APPEND LIGHT_IMPLEMENTATIONS | |||
list(APPEND NODE_DECLARATIONS | |||
libraries/maya_surfaces.mtlx | |||
libraries/maya_utilities.mtlx | |||
libraries/maya_utilities_ng.mtlx |
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.
Split the NodeGraphs out to a separate file, hence the _ng
suffix.
</nodegraph> | ||
|
||
<!-- Nodegraph only wraps the difference in interface --> | ||
<nodegraph name="MayaNG_clamp_vector3" nodedef="MayaND_clamp_vector3"> |
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.
New node. The Maya and MaterialX clamp nodes differ only in their interfaces. The NodeGraph allows using symmetric reader/writer code.
@@ -152,4 +140,79 @@ bool MtlxUsd_BaseReader::GetColorAndAlphaFromInput( | |||
return false; | |||
} | |||
|
|||
bool MtlxUsd_BaseReader::TraverseUnconnectableInput(const TfToken& usdAttrName) | |||
{ | |||
TfToken usdPortName; |
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.
Considers a constructor node to be part of the set of MaterialX nodes that define a Maya node.
@@ -460,6 +499,24 @@ UsdAttribute MtlxUsd_BaseWriter::AddNormalMapping(UsdAttribute normalInput) | |||
return mapInput; | |||
} | |||
|
|||
UsdAttribute MtlxUsd_BaseWriter::PreserveNodegraphBoundaries(UsdAttribute input) | |||
{ | |||
UsdShadeNodeGraph nodeGraph(GetNodeGraph()); |
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.
Top-level shader nodes like lambert and phong require connecting to ancillary nodes via a node graph boundary port. This check and adds such a port if required.
@@ -87,7 +91,7 @@ class MtlxUsd_ConverterReader : public UsdMayaShaderReader | |||
if (shaderId.GetString().rfind("ND_luminance_", 0) != std::string::npos) { | |||
// Luminance is an alpha output. | |||
_setAlphaIsLuminance = true; | |||
_refinedOutputToken = TrMayaTokens->outAlpha; | |||
_childIndex = 3; |
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.
Changes are to remove hardcoded Maya outColor subcomponent names and use a more gereric child index instead.
@@ -157,6 +157,21 @@ bool MtlxUsd_ImageReader::Read(UsdMayaPrimReaderContext& context) | |||
UsdMayaReadUtil::SetMayaAttr(mayaAttr, VtValue(colorVal), /*unlinearizeColors*/ false); | |||
} | |||
|
|||
// Filter type: | |||
mayaAttr = depFn.findPlug(TrMayaTokens->filterType.GetText(), true, &status); |
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.
Was exported in PR #2207 , but not re-imported.
} | ||
|
||
context.RegisterNewMayaNode(prim.GetPath().GetString(), mayaObject); | ||
RegisterConstructorNodes(context, mayaObject); |
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.
This call is currently the only change compared to symmetricShaderReader.cpp, but I suspect handling multi-input nodes like ramp
will require more code to be added.
/// }; | ||
/// \endcode | ||
/// | ||
class MtlxUsd_SymmetricShaderWriter : public MtlxUsd_BaseWriter |
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.
Moved from mtlxSymmetricShaderWriter.h, which was removed. Might reappear as a separate header if we want to expose this specialization to Python, but we are in a completely different DLL, so that might require moving that code back to the mayaUsd library.
@JGamache-autodesk There are conflicts to fix. Will you be able to or would you need us to do it? |
Fixed the conflicts. Ready to merge as soon as preflight succeeds. |
Builds on to of PR #2207, which must be merged before this one.