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-102319 Basic useRegistry import support #621

Merged
merged 11 commits into from
Jul 20, 2020

Conversation

JGamache-autodesk
Copy link
Collaborator

@JGamache-autodesk JGamache-autodesk commented Jul 3, 2020

Add the useRegistry import mode which uses an info:id-based registry to process individual UsdShade nodes.
Implemented basic import of UsdPreviewSurface and UsdUVTexture nodes to plugin pxrUsdPreviewSurface materials.
Split monolithic materialWriter file into proper C++ hierarchy.

Note 1: does not convert to Maya native materials (yet).
Note 2: does not solve the issue of having multiple importers for a single info:id (for commonly used names like "standard_surface")

Add the useRegistry import mode which uses an info:id-based registry to
process individual UsdShade nodes.
Implemented basic import of UsdPreviewSurface and UsdUVTexture nodes to
plugin pxrUsdPreviewSurface materials.
Split monolithic materialWriter file into proper C++ hierarchy.

Note: does not convert to Maya native materials (yet).
@@ -129,7 +129,7 @@ MStatus
MayaUsdProxyShapePlugin::finalize(MFnPlugin& plugin)
{
// If more than one plugin still has us registered, do nothing.
if (_registrationCount-- > 1) {
if (!_registrationCount || _registrationCount-- > 1) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Request from previous review: fix negative registration counts.

Copy link
Contributor

Choose a reason for hiding this comment

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

if (_registrationCount == 0 || ...) might be more clear here.

instancerWriter.cpp
jointWriter.cpp
lightReader.cpp
lightWriter.cpp
locatorWriter.cpp
materialReader.cpp
materialWriter.cpp
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As requested in a previous review: split the monolithic materialWriter.cpp file per dependency node.

class UsdTimeCode;

/// Shader writer for exporting Maya's material shading nodes to USD.
class PxrUsdTranslators_MaterialWriter : public UsdMayaShaderWriter
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Utility base class for often-used functions.

Choose a reason for hiding this comment

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

Very good idea, just please add documentation to these often-used functions.

return false;
}

// File
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Does the exact reverse of usdFileTextureWriter.

MFnDependencyNode depFn;
if (!(UsdMayaTranslatorUtil::CreateShaderNode(
MString(prim.GetName().GetText()),
PxrMayaUsdPreviewSurfaceTokens->MayaTypeName.GetText(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Importing back to pxrUsdPreviewSurface plugin material at this point int time.
Importing to Maya native materials to happen in the next PR.

if (mayaAttrName == PxrMayaUsdPreviewSurfaceTokens->DiffuseColorAttrName
|| mayaAttrName == PxrMayaUsdPreviewSurfaceTokens->EmissiveColorAttrName
|| mayaAttrName == PxrMayaUsdPreviewSurfaceTokens->SpecularColorAttrName) {
// These values are exported unscaled, so they also reimport unscaled:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will have to check to see if we want them scaled on export.

return false;
}

// Connect manually (fileTexturePlacementConnect is not available in batch):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Code from MEL script fileTexturePlacementConnect copied here since the script is not sourced in batch.

@kxl-adsk kxl-adsk added the import-export Related to Import and/or Export label Jul 6, 2020
class UsdTimeCode;

/// Shader writer for exporting Maya's material shading nodes to USD.
class PxrUsdTranslators_MaterialWriter : public UsdMayaShaderWriter

Choose a reason for hiding this comment

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

Very good idea, just please add documentation to these often-used functions.

Copy link
Contributor

@mattyjams mattyjams left a comment

Choose a reason for hiding this comment

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

This is looking pretty good to me! Thanks for all the great work here @JGamache-autodesk!

I left a bunch of comments and suggestions, but not really much that I think would gate merging this. It's a great start to continue building on, and I think we'll just have to work our way through some of the issues we've been discussing as they come to light.

It might have been nice to have the export changes separated out into their own commits/PR, but it's all been reviewed at this point, so maybe moot now.

Copy link
Contributor

@mattyjams mattyjams left a comment

Choose a reason for hiding this comment

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

Looks good to me! Excited to dig into this and continue to flesh this all out. Thanks @JGamache-autodesk!

@@ -82,7 +82,8 @@ def testPxrUsdPreviewSurfaceRoundtrip(self):
cmds.connectAttr(file_node + ".outColor",
material_node + ".diffuseColor", f=True)

txfile = "PxrUsdPreviewSurfaceExportTest/Brazilian_rosewood_pxr128.png"
txfile = "/".join(["UsdExportImportRoundtripPreviewSurface",
Copy link
Contributor

Choose a reason for hiding this comment

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

os.path.sep here instead of "/", or just use os.path.join() instead?

MStatus status;
MFnDependencyNode depFn;
if (!(UsdMayaTranslatorUtil::CreateShaderNode(
MString(prim.GetName().GetText()),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's less about trying to ensure that the node names are unique, and more important that the translation is as consistent as possible across multiple roundtrips. When there are potentially existing overs on the prims being exported, it would be easy for those to fall off if a name collision on import caused the node name to change, which then affects the prim path when re-exported.

And yeah, I think material deduplication would be an interesting feature to pursue if we can detect that the "source" materials in USD are all the same material (e.g. bindings from multiple gprims across references that all resolve to what is ultimately a single material).

Comment on lines +6 to +14
usdBlinnWriter.cpp
usdFileTextureWriter.cpp
usdLambertWriter.cpp
usdMaterialWriter.cpp
usdPhongWriter.cpp
usdPhongEWriter.cpp
usdReflectWriter.cpp
usdStandardSurfaceWriter.cpp
usdUVTextureReader.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. I'm not quite sure I'm following yet how the selection of an export "dialect" impacts what ultimately gets authored in USD, and how/if there's an overlap there with UsdShade's concept of renderContext. There ongoing discussion here, so I guess I wouldn't worry too much about the naming for now.

@kxl-adsk kxl-adsk merged commit f937f9c into dev Jul 20, 2020
@kxl-adsk kxl-adsk deleted the t_gamaj/MAYA-102319/basic_import branch July 20, 2020 20:55
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants