-
Notifications
You must be signed in to change notification settings - Fork 203
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
Conversation
- 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.
@@ -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()) { |
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.
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) |
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 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') |
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.
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; |
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.
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.
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.
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.
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.
Looks good to me.
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.