forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 23
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
1.38 Explicit nodegraph inputs and nodegraph input connections #1053
Merged
bernardkwok
merged 43 commits into
adsk_contrib/dev
from
adsk_contrib/nodegraph_nodegraph
Dec 17, 2020
+390
−53
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
6ff89e0
Initial check-in + test.
bernardkwok 3983d41
Add testing and validation.
bernardkwok 4fe36e5
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok e2260d5
Fix invalid test document found via new interface validation.
bernardkwok a92ad8a
Add test for :
bernardkwok 2e25652
multi-output node -> nodegraph update.
bernardkwok 92546db
Fix test.
bernardkwok a68aac2
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok 134fb2d
Add call to connect nodegraphs to each other same as node for Runtime.
bernardkwok c5fd321
Fix codacy warning.
bernardkwok 0189c3c
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok 7ca7460
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok 3f95de6
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok 459c16c
Simplify image codec test
jstone-lucasfilm 2cc92db
Additional parameter updates for 1.38
jstone-lucasfilm 68e97c0
Remove Parameter class
jstone-lucasfilm 6b68b55
Remove ShaderRef classes
jstone-lucasfilm dcc2826
Material element class
jstone-lucasfilm 340d957
Additional material unit tests
jstone-lucasfilm 9c5dc54
Initial look unit tests
jstone-lucasfilm bfa2a8c
Add shared library build
jstone-lucasfilm 16693d6
Update development build to 1.37.4
jstone-lucasfilm f5eccbc
OpenGL improvements for software rendering
jstone-lucasfilm da83fa9
Add material baking to GitHub Actions CI
jstone-lucasfilm 1b381a4
Improved robustness in MaterialXRenderGlsl
jstone-lucasfilm 9258b8d
Make strings local to module
jstone-lucasfilm 97da53f
Additional improvements to MaterialXRenderGlsl
jstone-lucasfilm 2e8e67a
82d3d170
jstone-lucasfilm 6a887a4
Improved color space handling in MaterialXRenderGlsl
jstone-lucasfilm 9026165
Disable software render tests in v1.38
jstone-lucasfilm 8087988
Patch.
bernardkwok ad320a3
Patch.
bernardkwok 8ad4e98
Patch texture baker.
bernardkwok cf45883
Fix test.
bernardkwok 710c654
Baker patch.
bernardkwok b7a1ff2
Fix crash in viewer.
bernardkwok 46600e8
Wasm dormant.
bernardkwok acde996
Merge branch 'adsk_contrib/ILM_merge_Dec_14_2020' into adsk_contrib/n…
bernardkwok da21e8f
Merge branch 'adsk_contrib/ILM_merge_Dec_14_2020' into adsk_contrib/n…
bernardkwok 91d6b54
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok d4e5dcd
Review fixes.
bernardkwok a160b32
Review updates.
bernardkwok 12c481f
Remove merge leftover.
bernardkwok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
resources/Materials/TestSuite/stdlib/nodegraph_inputs/cascade_nodegraphs.mtlx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.37"> | ||
<nodegraph name="upstream3" xpos="10" ypos="153" > | ||
<input name="file" type="filename" uniform="true" value="resources/Images/cloth.png" /> | ||
<input name="file1" type="filename" uniform="true" value="resources/Images/grid.png" /> | ||
<image name="upstream_image" type="color3" xpos="10" ypos="8.86024"> | ||
<input name="file" type="filename" uniform="true" interfacename="file" value="resources/Images/cloth.png" /> | ||
<input name="frameoffset" type="integer" uniform="true" value="0" /> | ||
</image> | ||
<image name="upstream_image1" type="color3" xpos="19.1695" ypos="421"> | ||
<input name="file" type="filename" uniform="true" interfacename="file1" value="resources/Images/grid.png" /> | ||
<input name="frameoffset" type="integer" uniform="true" value="0" /> | ||
</image> | ||
<output name="out" type="color3" nodename="upstream_image" /> | ||
<output name="out1" type="color3" nodename="upstream_image1" /> | ||
</nodegraph> | ||
|
||
|
||
<nodegraph name="upstream2" xpos="315" ypos="82" > | ||
<input name="upstream2_in1" type="color3" nodegraph="upstream3" output="out" value="0, 1, 0" /> | ||
<input name="upstream2_in2" type="color3" nodegraph="upstream3" output="out1" value="0, 1, 0" /> | ||
<multiply name="multiply_by_image" type="color3" xpos="333.028" ypos="-27.8587"> | ||
<input name="in1" type="color3" interfacename="upstream2_in1" value="0, 1, 0" /> | ||
<input name="in2" type="color3" nodename="image" /> | ||
</multiply> | ||
<multiply name="make_red" type="color3" xpos="361.069" ypos="248.883"> | ||
<input name="in1" type="color3" interfacename="upstream2_in2" value="0, 1, 0" /> | ||
<input name="in2" type="color3" value="1, 0.1, 0.1" /> | ||
</multiply> | ||
<image name="image" type="color3" xpos="-30.4805" ypos="-249.603"> | ||
<input name="file" type="filename" uniform="true" value="resources/Images/grid.png" /> | ||
</image> | ||
<output name="upstream2_out1" type="color3" nodename="multiply_by_image" /> | ||
<output name="upstream2_out2" type="color3" nodename="make_red" /> | ||
</nodegraph> | ||
|
||
<nodegraph name="upstream1" xpos="620" ypos="10" > | ||
<input name="upstream1_in1" type="color3" nodegraph="upstream2" output="upstream2_out1" value="0, 1, 0" /> | ||
<input name="upstream1_in2" type="color3" nodegraph="upstream2" output="upstream2_out2" value="0, 1, 0" /> | ||
<multiply name="make_yellow" type="color3" xpos="-77.0636" ypos="-139.845"> | ||
<input name="in1" type="color3" interfacename="upstream1_in1" value="0, 1, 0" /> | ||
<input name="in2" type="color3" value="1, 1, 0" /> | ||
</multiply> | ||
<multiply name="remove_red" type="color3" xpos="-75.6416" ypos="242.103"> | ||
<input name="in1" type="color3" interfacename="upstream1_in2" value="0, 1, 0" /> | ||
<input name="in2" type="color3" value="0, 1, 1" /> | ||
</multiply> | ||
<output name="upstream1_out1" type="color3" nodename="make_yellow" /> | ||
<output name="upstream1_out2" type="color3" nodename="remove_red" /> | ||
</nodegraph> | ||
|
||
<output name="top_upstream1_out1" type="color3" nodename="upstream1" output="upstream1_out1"/> | ||
<output name="top_upstream1_out2" type="color3" nodename="upstream1" output="upstream1_out2"/> | ||
|
||
<standard_surface name="standard_surface" type="surfaceshader" version="1.0.1" xpos="949.876" ypos="-189.576"> | ||
<input name="base_color" type="color3" nodegraph="upstream1" output="upstream1_out1" /> | ||
</standard_surface> | ||
<standard_surface name="standard_surface1" type="surfaceshader" version="1.0.1" xpos="940.476" ypos="307.63"> | ||
<input name="base_color" type="color3" nodegraph="upstream1" output="upstream1_out2" /> | ||
</standard_surface> | ||
<surfacematerial name="surfacematerial" type="material" xpos="1303.4" ypos="-234.282"> | ||
<input name="surfaceshader" type="surfaceshader" nodename="standard_surface" /> | ||
<input name="displacementshader" type="displacementshader" value="" /> | ||
</surfacematerial> | ||
<surfacematerial name="surfacematerial1" type="material" xpos="1325.2" ypos="245.001"> | ||
<input name="surfaceshader" type="surfaceshader" nodename="standard_surface1" /> | ||
<input name="displacementshader" type="displacementshader" value="" /> | ||
</surfacematerial> | ||
</materialx> |
124 changes: 124 additions & 0 deletions
124
resources/Materials/TestSuite/stdlib/nodegraph_inputs/nodegraph_nodegraph.mtlx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.37"> | ||
<!-- Nodegraph to nodegraph connections --> | ||
<nodegraph name="upstream_graph" > | ||
<input name="file" type="filename" value="resources/Images/grid.png" /> | ||
<input name="file2" type="filename" value="resources/Images/cloth.png" /> | ||
<image name="image" type="color3"> | ||
<input name="file" type="filename" interfacename="file" value="resources/Images/grid.png" /> | ||
</image> | ||
<image name="image2" type="color3"> | ||
<input name="file" type="filename" interfacename="file2" value="resources/Images/cloth.png" /> | ||
</image> | ||
<output name="graph_out_image" type="color3" nodename="image" /> | ||
<output name="graph_out_image2" type="color3" nodename="image2" /> | ||
</nodegraph> | ||
<nodegraph name="graph_graph" > | ||
<input name="input" type="color3" nodegraph="upstream_graph" output="graph_out_image" value="1, 0, 0" /> | ||
<input name="input2" type="color3" nodegraph="upstream_graph" output="graph_out_image2" value="1, 0, 0" /> | ||
<multiply name="multiply" type="color3"> | ||
<input name="in1" type="color3" interfacename="input" value="1, 0, 0" /> | ||
<input name="in2" type="color3" value="0.4, 0.4, 0.4" /> | ||
</multiply> | ||
<multiply name="multiply2" type="color3"> | ||
<input name="in1" type="color3" interfacename="input2" value="1, 0, 0" /> | ||
<input name="in2" type="color3" value="0.4, 0.4, 0.4" /> | ||
</multiply> | ||
<output name="graph_graph_out" type="color3" nodename="multiply" /> | ||
<output name="graph_graph_out2" type="color3" nodename="multiply2" /> | ||
</nodegraph> | ||
<nodegraph name="surf_graph_graph" > | ||
<input name="input" type="color3" nodegraph="graph_graph" output="graph_graph_out" value="1, 1, 1" /> | ||
<input name="input2" type="color3" nodegraph="graph_graph" output="graph_graph_out2" value="1, 1, 1" /> | ||
<standard_surface name="default_shader" type="surfaceshader"> | ||
<input name="base_color" type="color3" interfacename="input" value="1, 1, 1" /> | ||
</standard_surface> | ||
<standard_surface name="default_shader2" type="surfaceshader"> | ||
<input name="base_color" type="color3" interfacename="input2" value="1, 1, 1" /> | ||
</standard_surface> | ||
<output name="surf_graph_graph_out" type="surfaceshader" nodename="default_shader" /> | ||
<output name="surf_graph_graph_out2" type="surfaceshader" nodename="default_shader2" /> | ||
</nodegraph> | ||
|
||
<!-- Connect node instance with multiple outputs to nodegraph --> | ||
<nodedef name="ND_upstream_graph" node="upstream_graph_def" version="1.0" isdefaultversion="true" nodegroup="procedural2d"> | ||
<input name="nd_file" type="filename" uniform="true" value="resources/Images/grid.png" /> | ||
<input name="nd_file2" type="filename" uniform="true" value="resources/Images/cloth.png" /> | ||
<output name="nd_graph_out_image" type="color3" value="0, 0, 0" /> | ||
<output name="nd_graph_out_image2" type="color3" value="0, 0, 0" /> | ||
</nodedef> | ||
<nodegraph name="NG_upstream_graph" nodedef="ND_upstream_graph" > | ||
<input name="nd_file" type="filename" uniform="true" value="resources/Images/grid.png" /> | ||
<input name="nd_file2" type="filename" uniform="true" value="resources/Images/cloth.png" /> | ||
<image name="image" type="color3" xpos="-79" ypos="-448.596"> | ||
<input name="file" type="filename" uniform="true" interfacename="nd_file" value="resources/Images/grid.png" /> | ||
</image> | ||
<image name="image2" type="color3"> | ||
<input name="file" type="filename" uniform="true" interfacename="nd_file2" value="resources/Images/cloth.png" /> | ||
</image> | ||
<output name="nd_graph_out_image" type="color3" nodename="image" /> | ||
<output name="nd_graph_out_image2" type="color3" nodename="image2" /> | ||
</nodegraph> | ||
<upstream_graph_def name="upstream_graph_instance" type="multioutput"> | ||
<output name="nd_graph_out_image" type="color3" /> | ||
<output name="nd_graph_out_image2" type="color3" /> | ||
</upstream_graph_def> | ||
<nodegraph name="nd_graph_graph" > | ||
<input name="nd_input" type="color3" nodename="upstream_graph_instance" output="nd_graph_out_image" value="1, 0, 0" /> | ||
<input name="nd_input2" type="color3" nodename="upstream_graph_instance" output="nd_graph_out_image2" value="1, 0, 0" /> | ||
<multiply name="multiply" type="color3"> | ||
<input name="in1" type="color3" interfacename="nd_input" value="1, 0, 0" /> | ||
<input name="in2" type="color3" value="0.4, 0.4, 0.4" /> | ||
</multiply> | ||
<multiply name="multiply2" type="color3"> | ||
<input name="in1" type="color3" interfacename="nd_input2" value="1, 0, 0" /> | ||
<input name="in2" type="color3" value="0.4, 0.4, 0.4" /> | ||
</multiply> | ||
<output name="nd_graph_graph_out" type="color3" nodename="multiply" /> | ||
<output name="nd_graph_graph_out2" type="color3" nodename="multiply2" /> | ||
</nodegraph> | ||
<nodegraph name="ng_surf_graph_graph" > | ||
<input name="nd_input" type="color3" nodename="upstream_graph_instance" output="nd_graph_out_image" value="1, 1, 1" /> | ||
<input name="nd_input2" type="color3" nodename="upstream_graph_instance" output="nd_graph_out_image2" value="1, 1, 1" /> | ||
<standard_surface name="default_shader" type="surfaceshader"> | ||
<input name="base_color" type="color3" interfacename="nd_input" value="1, 1, 1" /> | ||
</standard_surface> | ||
<standard_surface name="default_shader2" type="surfaceshader"> | ||
<input name="base_color" type="color3" interfacename="nd_input2" value="1, 1, 1" /> | ||
</standard_surface> | ||
<output name="nd_surf_graph_graph_out" type="surfaceshader" nodename="default_shader" /> | ||
<output name="nd_surf_graph_graph_out2" type="surfaceshader" nodename="default_shader2" /> | ||
</nodegraph> | ||
|
||
<!-- Nodegraph to nodegraph to top level shader and utility node --> | ||
<standard_surface name="default_shader_top" type="surfaceshader"> | ||
<input name="base_color" type="color3" nodegraph="graph_graph" output="graph_graph_out" /> | ||
</standard_surface> | ||
<output name="surf_graph_graph_out_top" type="surfaceshader" nodename="default_shader_top" /> | ||
<multiply name="multiply_top" type="color3"> | ||
<input name="in1" type="color3" nodegraph="graph_graph" output="graph_graph_out" /> | ||
<input name="in2" type="color3" value="0.4, 0.4, 0.4" /> | ||
</multiply> | ||
<output name="graph_graph_out_top" type="color3" nodename="multiply_top" /> | ||
|
||
<!-- Nodegraph to node connection --> | ||
<image name="upstream_image" type="color3"> | ||
<input name="file" type="filename" interfacename="file" value="resources/Images/cloth.png" /> | ||
</image> | ||
<nodegraph name="graph_to_node" > | ||
<input name="input" type="color3" nodename="upstream_image" value="0, 1, 0" /> | ||
<multiply name="multiply" type="color3"> | ||
<input name="in1" type="color3" interfacename="input" value="0, 1, 0" /> | ||
<input name="in2" type="color3" value="0.4, 0.4, 0.4" /> | ||
</multiply> | ||
<output name="node_graph_out" type="color3" nodename="multiply" /> | ||
</nodegraph> | ||
<nodegraph name="surf_graph_node" > | ||
<input name="input" type="color3" nodegraph="graph_to_node" value="1, 1, 1" /> | ||
<standard_surface name="default_shader" type="surfaceshader"> | ||
<input name="base_color" type="color3" interfacename="input" value="1, 1, 1" /> | ||
</standard_surface> | ||
<output name="surf_graph_node_out" type="surfaceshader" nodename="default_shader" /> | ||
</nodegraph> | ||
|
||
</materialx> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,20 +238,33 @@ OutputPtr Input::getConnectedOutput() const | |
// Look for output on a node | ||
else if (hasNodeName()) | ||
{ | ||
ConstGraphElementPtr graph = getAncestorOfType<GraphElement>(); | ||
NodePtr node = graph ? graph->getNode(getNodeName()) : nullptr; | ||
if (node) | ||
const string& nodeName = getNodeName(); | ||
ConstElementPtr startingElement = getParent(); | ||
if (startingElement) | ||
{ | ||
std::vector<OutputPtr> outputs = node->getOutputs(); | ||
if (!outputs.empty()) | ||
// Look for a node reference above the nodegraph if input is a direct child. | ||
if (startingElement->isA<NodeGraph>()) | ||
{ | ||
if (outputString.empty()) | ||
{ | ||
result = outputs[0]; | ||
} | ||
else | ||
startingElement = startingElement->getParent(); | ||
} | ||
if (startingElement) | ||
{ | ||
ConstGraphElementPtr graph = startingElement->getAncestorOfType<GraphElement>(); | ||
NodePtr node = graph ? graph->getNode(nodeName) : nullptr; | ||
if (node) | ||
{ | ||
result = node->getOutput(outputString); | ||
std::vector<OutputPtr> outputs = node->getOutputs(); | ||
if (!outputs.empty()) | ||
{ | ||
if (outputString.empty()) | ||
{ | ||
result = outputs[0]; | ||
} | ||
else | ||
{ | ||
result = node->getOutput(outputString); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -264,8 +277,29 @@ OutputPtr Input::getConnectedOutput() const | |
return result; | ||
} | ||
|
||
InputPtr Input::getConnectedInterface() const | ||
{ | ||
const string& interfaceName = getInterfaceName(); | ||
if (!interfaceName.empty()) | ||
{ | ||
ConstNodeGraphPtr graph = getAncestorOfType<NodeGraph>(); | ||
if (graph) | ||
{ | ||
return graph->getInput(interfaceName); | ||
} | ||
} | ||
return nullptr; | ||
} | ||
|
||
NodePtr Input::getConnectedNode() const | ||
{ | ||
// Traverse through interface names to nodegraph input | ||
InputPtr graphInput = getConnectedInterface(); | ||
if (graphInput && (graphInput->hasNodeName() || graphInput->hasNodeGraphString())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this input has an interfacename, then traverse through to that input to find any upstream connection. |
||
{ | ||
return graphInput->getConnectedNode(); | ||
} | ||
|
||
OutputPtr output = getConnectedOutput(); | ||
if (output) | ||
{ | ||
|
@@ -275,11 +309,24 @@ NodePtr Input::getConnectedNode() const | |
} | ||
if (hasNodeName()) | ||
{ | ||
ConstGraphElementPtr graph = getAncestorOfType<GraphElement>(); | ||
NodePtr node = graph ? graph->getNode(getNodeName()) : nullptr; | ||
if (node) | ||
const string& nodeName = getNodeName(); | ||
ConstElementPtr startingElement = getParent(); | ||
if (startingElement) | ||
{ | ||
return node; | ||
// Look for a node reference above the nodegraph if input is a direct child. | ||
if (startingElement->isA<NodeGraph>()) | ||
{ | ||
startingElement = startingElement->getParent(); | ||
} | ||
if (startingElement) | ||
{ | ||
ConstGraphElementPtr graph = startingElement->getAncestorOfType<GraphElement>(); | ||
NodePtr node = graph ? graph->getNode(nodeName) : nullptr; | ||
if (node) | ||
{ | ||
return node; | ||
} | ||
} | ||
} | ||
} | ||
return PortElement::getConnectedNode(); | ||
|
@@ -303,6 +350,11 @@ bool Input::validate(string* message) const | |
{ | ||
validateRequire(getDefaultGeomProp() != nullptr, res, message, "Invalid defaultgeomprop string"); | ||
} | ||
InputPtr interfaceInput = getConnectedInterface(); | ||
if (interfaceInput) | ||
{ | ||
return interfaceInput->validate() && res; | ||
} | ||
return PortElement::validate(message) && res; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This invalid case of an interfacename w/o a proper input is now caught.