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-121735: Add UV tangents directly in MaterialX #2113

Merged
merged 2 commits into from
Feb 22, 2022

Conversation

JGamache-autodesk
Copy link
Collaborator

  • Removes the arbitrary tangent code previously used with MaterialX
    native code that can generate U-aligned tangents in the presence of a
    texcoord stream.

  • Added stripped-down MaterialX graphs that provide compatible rendering
    of Lambert, Blinn, and Phong surfaces. The symmetric import export of
    these materials is lossless.

- Removes the arbitrary tangent code previously used with MaterialX
  native code that can generate U-aligned tangents in the presence of a
  texcoord stream.

- Added stripped-down MaterialX graphs that provide compatible rendering
  of Lambert, Blinn, and Phong surfaces. The symmetric import export of
  these materials is lossless.
@JGamache-autodesk JGamache-autodesk added import-export Related to Import and/or Export vp2renderdelegate Related to VP2RenderDelegate labels Feb 17, 2022
@williamkrick williamkrick requested a review from vlasovi February 17, 2022 15:54
@@ -387,18 +412,152 @@ MStatus _SetFAParameter(
// name for UV at index zero.
void _AddMissingTexcoordReaders(mx::DocumentPtr& mtlxDoc)
{
// We expect only one node graph, but fixing them all is not an issue:
for (mx::NodeGraphPtr nodeGraph : mtlxDoc->getNodeGraphs()) {
if (nodeGraph->hasSourceUri()) {
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 whitespace since we are not looping on all NodeGraphs.

}

// USD does not provide tangents, so we need to build them from UV coordinates when possible:
void _AddMissingTangents(mx::DocumentPtr& mtlxDoc)
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 code to add tangent generators into the incoming graph.

cmds.file(force=True, new=True)
cmds.move(6, -6, 6, 'persp')
cmds.rotate(60, 0, 45, 'persp')
self._StartTest('MayaSurfaces')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

File includes a poly cube with standard surface MaterialX shading to show that the faces with Z-pointing normals render correctly now.

// Grab the first st reader we can find. This will be the default one used for
// tangents unless we find something better.
stReader = node;
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand why we can continue here. The first node def that matches will get the continue, the later if another nodeDef matches we execute the rest of the loop and maybe have a different behavior. I don't understand it in depth enough to know if it is a problem or not, it just looks a bit strange.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can continue here because we know that a geompropvalue node never has a tangent input. Note that we do not continue in the next branch because normalmap nodes have tangent input.

williamkrick
williamkrick previously approved these changes Feb 17, 2022
Copy link
Collaborator

@vlasovi vlasovi 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.

@JGamache-autodesk JGamache-autodesk added the ready-for-merge Development process is finished, PR is ready for merge label Feb 21, 2022
@seando-adsk seando-adsk merged commit 09a4347 into dev Feb 22, 2022
@seando-adsk seando-adsk deleted the t_gamaj/MAYA-121735/fix_tangent_inputs branch February 22, 2022 14:53
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.

5 participants