Skip to content
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

Merged

Conversation

JGamache-autodesk
Copy link
Collaborator

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

- 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.
@JGamache-autodesk JGamache-autodesk added import-export Related to Import and/or Export vp2renderdelegate Related to VP2RenderDelegate labels Mar 24, 2022
@@ -63,10 +63,7 @@ TfToken UsdMayaShaderReader::GetMayaNameForUsdAttrName(const TfToken& usdAttrNam
return TfToken();
}

bool UsdMayaShaderReader::TraverseUnconnectableInput(const TfToken& usdAttrName) const
Copy link
Collaborator Author

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)
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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">
Copy link
Collaborator Author

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;
Copy link
Collaborator Author

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());
Copy link
Collaborator Author

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;
Copy link
Collaborator Author

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);
Copy link
Collaborator Author

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);
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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.

boudrey
boudrey previously approved these changes Mar 25, 2022
Base automatically changed from t_gamaj/MAYA-121534/expose_lookdevkit_color_correct to dev April 6, 2022 14:09
@seando-adsk
Copy link
Collaborator

@JGamache-autodesk There are conflicts to fix. Will you be able to or would you need us to do it?

@JGamache-autodesk JGamache-autodesk added the ready-for-merge Development process is finished, PR is ready for merge label Apr 6, 2022
@JGamache-autodesk
Copy link
Collaborator Author

Fixed the conflicts. Ready to merge as soon as preflight succeeds.

@seando-adsk seando-adsk merged commit bc49205 into dev Apr 6, 2022
@seando-adsk seando-adsk deleted the t_gamaj/MAYA-121534/mtlx_subcomponent_cnx_export_import branch April 6, 2022 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
import-export Related to Import and/or Export ready-for-merge Development process is finished, PR is ready for merge vp2renderdelegate Related to VP2RenderDelegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants