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-114979 MAYA-114731 Fix correctness issues #1937

Merged
merged 3 commits into from
Jan 3, 2022

Conversation

JGamache-autodesk
Copy link
Collaborator

This fixes #1834 for the last correctness problems mentioned

  • Use a separate varnameStr for MaterialX since the type is not compatible with the varname used in UsdPreviewSurface
  • Shared place2dTexture nodes are now shared on MaterialX export
  • NodeGraph is used instead of Scope to isolate shaders by type in multi-material export
  • NodeGraph boundaries are not skipped anymore by shader connections
  • Cleaned-up code producing empty NodeGraphs

This fixes #1834 for the last correctness problems mentioned

- Use a separate varnameStr for MaterialX since the type is not
  compatible with the varname used in UsdPreviewSurface
- Shared place2dTexture nodes are now shared on MaterialX export
- NodeGraph is used instead of Scope to isolate shaders by type in
  multi-material export
- NodeGraph boundaries are not skipped anymore by shader connections
- Cleaned-up code producing empty NodeGraphs
@@ -135,6 +129,15 @@ MtlxUsd_PreviewSurfaceWriter::MtlxUsd_PreviewSurfaceWriter(

// All connections go directly to the node graph:
if (attrPlug.isConnected()) {
if (!nodegraphSchema) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just-in-time creation to reduce number of empty NodeGraph generated.

}
SdfPath primvarReaderPath = _GetPlace2DTexturePath(depNodeFn);

if (!GetUsdStage()->GetPrimAtPath(primvarReaderPath)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly indentation since we now detect shared place2dTexture nodes. Similar to what was done in usdFileTextureWriter.cpp in the first PR of the series.

// easy specialization based on UV mappings to geometries:
UsdPrim materialPrim = primvarReaderSchema.GetPrim().GetParent();
UsdShadeMaterial materialSchema(materialPrim);
while (!materialSchema && materialPrim) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we make sure to properly connect the NodeGraph.

materialSchema = UsdShadeMaterial(GetUsdStage()->GetPrimAtPath(materialPath));
UsdPrim materialPrim = primvarReaderShaderSchema.GetPrim().GetParent();
UsdShadeMaterial materialSchema(materialPrim);
while (!materialSchema && materialPrim) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connect all intermediate NodeGraphs.

// Connect the output of the primvar reader to the texture coordinate
// input of the UV texture.
texSchema.CreateInput(TrMtlxTokens->texcoord, SdfValueTypeNames->Float2)
.ConnectToSource(primvarReaderOutput);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 206-212 could be taken out of the if/else block instead of having a duplication of code.

@JGamache-autodesk JGamache-autodesk added the ready-for-merge Development process is finished, PR is ready for merge label Jan 3, 2022
@seando-adsk seando-adsk merged commit 745a814 into dev Jan 3, 2022
@seando-adsk seando-adsk deleted the t_gamaj/MAYA-114979/fix_multi_material_nesting branch January 3, 2022 20:06
@spiffmon
Copy link
Contributor

spiffmon commented Jan 4, 2022

Fantastic - thank you so much!

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MAYA-114979] UsdPreviewSurface export has several correctness problems
5 participants