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

1.38 Explicit nodegraph inputs and nodegraph input connections #1053

Merged
merged 43 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6ff89e0
Initial check-in + test.
bernardkwok Dec 3, 2020
3983d41
Add testing and validation.
bernardkwok Dec 3, 2020
4fe36e5
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok Dec 4, 2020
e2260d5
Fix invalid test document found via new interface validation.
bernardkwok Dec 4, 2020
a92ad8a
Add test for :
bernardkwok Dec 4, 2020
2e25652
multi-output node -> nodegraph update.
bernardkwok Dec 7, 2020
92546db
Fix test.
bernardkwok Dec 7, 2020
a68aac2
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok Dec 8, 2020
134fb2d
Add call to connect nodegraphs to each other same as node for Runtime.
bernardkwok Dec 8, 2020
c5fd321
Fix codacy warning.
bernardkwok Dec 8, 2020
0189c3c
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok Dec 8, 2020
7ca7460
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok Dec 10, 2020
3f95de6
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok Dec 14, 2020
459c16c
Simplify image codec test
jstone-lucasfilm Nov 25, 2020
2cc92db
Additional parameter updates for 1.38
jstone-lucasfilm Nov 25, 2020
68e97c0
Remove Parameter class
jstone-lucasfilm Nov 26, 2020
6b68b55
Remove ShaderRef classes
jstone-lucasfilm Nov 27, 2020
dcc2826
Material element class
jstone-lucasfilm Nov 28, 2020
340d957
Additional material unit tests
jstone-lucasfilm Nov 28, 2020
9c5dc54
Initial look unit tests
jstone-lucasfilm Nov 29, 2020
bfa2a8c
Add shared library build
jstone-lucasfilm Dec 3, 2020
16693d6
Update development build to 1.37.4
jstone-lucasfilm Dec 7, 2020
f5eccbc
OpenGL improvements for software rendering
jstone-lucasfilm Dec 7, 2020
da83fa9
Add material baking to GitHub Actions CI
jstone-lucasfilm Dec 7, 2020
1b381a4
Improved robustness in MaterialXRenderGlsl
jstone-lucasfilm Dec 9, 2020
9258b8d
Make strings local to module
jstone-lucasfilm Dec 11, 2020
97da53f
Additional improvements to MaterialXRenderGlsl
jstone-lucasfilm Dec 11, 2020
2e8e67a
82d3d170
jstone-lucasfilm Dec 11, 2020
6a887a4
Improved color space handling in MaterialXRenderGlsl
jstone-lucasfilm Dec 12, 2020
9026165
Disable software render tests in v1.38
jstone-lucasfilm Dec 13, 2020
8087988
Patch.
bernardkwok Dec 14, 2020
ad320a3
Patch.
bernardkwok Dec 14, 2020
8ad4e98
Patch texture baker.
bernardkwok Dec 14, 2020
cf45883
Fix test.
bernardkwok Dec 14, 2020
710c654
Baker patch.
bernardkwok Dec 14, 2020
b7a1ff2
Fix crash in viewer.
bernardkwok Dec 15, 2020
46600e8
Wasm dormant.
bernardkwok Dec 15, 2020
acde996
Merge branch 'adsk_contrib/ILM_merge_Dec_14_2020' into adsk_contrib/n…
bernardkwok Dec 15, 2020
da21e8f
Merge branch 'adsk_contrib/ILM_merge_Dec_14_2020' into adsk_contrib/n…
bernardkwok Dec 15, 2020
91d6b54
Merge branch 'adsk_contrib/dev' into adsk_contrib/nodegraph_nodegraph
bernardkwok Dec 15, 2020
d4e5dcd
Review fixes.
bernardkwok Dec 15, 2020
a160b32
Review updates.
bernardkwok Dec 15, 2020
12c481f
Remove merge leftover.
bernardkwok Dec 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Change Log

<<<<<<< HEAD

Choose a reason for hiding this comment

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

Merge leftover

## [1.38] - Development

### v1.38_adsk_development2 : WIP
Expand Down
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>
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>
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<materialx version="1.37">
<nodegraph name="parameter_as_input" fileprefix="resources/Images/">
<constant name="constant" type="color3">
<input name="value" type="color3" interfacename="value1" value="1, 0, 0" />
<input name="value" type="color3" value="1, 0, 0" />
Copy link
Author

@bernardkwok bernardkwok Dec 9, 2020

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.

</constant>
<constant name="constant1" type="color3">
<input name="value" type="color3" interfacename="value" value="0, 1, 0" />
<input name="value" type="color3" value="0, 1, 0" />
</constant>
<ramp4 name="ramp4" type="color3">
<input name="valuetl" type="color3" nodename="ramp5" />
Expand All @@ -15,8 +15,8 @@
</ramp4>
<ramp4 name="ramp5" type="color3">
<input name="valuetl" type="color3" nodename="image" />
<input name="valuetr" type="color3" interfacename="valuetr" value="0, 1, 1" />
<input name="valuebl" type="color3" interfacename="valuebl" value="0, 0, 0" />
<input name="valuetr" type="color3" value="0, 1, 1" />
<input name="valuebl" type="color3" value="0, 0, 0" />
<input name="valuebr" type="color3" nodename="image" />
</ramp4>
<image name="image" type="color3">
Expand All @@ -33,12 +33,12 @@
<splitlr name="splitlr" type="color3">
<input name="valuel" type="color3" nodename="image" />
<input name="valuer" type="color3" nodename="constant" />
<input name="center" type="float" interfacename="center" value="0.4" />
<input name="center" type="float" value="0.4" />
</splitlr>
<splittb name="splittb" type="color3">
<input name="valuet" type="color3" nodename="splitlr" />
<input name="valueb" type="color3" nodename="noise2d" />
<input name="center" type="float" interfacename="center" value="0.4" />
<input name="center" type="float" value="0.4" />
</splittb>
<noise2d name="noise2d" type="color3">
<input name="pivot" type="float" nodename="noise2d1" />
Expand All @@ -63,14 +63,14 @@
<input name="default" type="integer" value="0" uniform="true" />
</geompropvalue>
<constant name="constant2" type="string">
<input name="value" type="string" interfacename="my_tangent_name" value="mytangents" />
<input name="value" type="string" value="mytangents" />
</constant>
<invert name="invert" type="color3">
<input name="in" type="color3" nodename="splittb" />
<input name="amount" type="color3" nodename="noise2d" />
</invert>
<constant name="constant3" type="filename">
<input name="value" type="filename" interfacename="file" value="grid.png" />
<input name="value" type="filename" value="grid.png" />
</constant>
<output name="out" type="color3" nodename="ramp4" />
<output name="out1" type="color3" nodename="splittb" />
Expand Down
82 changes: 67 additions & 15 deletions source/MaterialXCore/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
}
Expand All @@ -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()))
Copy link
Author

Choose a reason for hiding this comment

The 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)
{
Expand All @@ -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();
Expand All @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions source/MaterialXCore/Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ class Input : public PortElement
/// @name Traversal
/// @{

/// Return the input on the parent graph corresponding to the interface name
/// for the element.
InputPtr getConnectedInterface() const;

/// Return the output, if any, to which this element is connected.
OutputPtr getConnectedOutput() const;

Expand Down
Loading