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 11 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
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,133 @@
<?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>
<!--
<output name="blah1" type="color3" nodename="upstream_graph_instance" output="nd_graph_out_image"/>
<output name="blah2" type="color3" nodename="upstream_graph_instance" output="nd_graph_out_image2"/>
<standard_surface name="default_shader" type="surfaceshader">
<input name="base_color" type="color3" nodename="upstream_graph_instance" output="nd_graph_out_image" />
<input name="specular_color" type="color3" nodename="upstream_graph_instance" output="nd_graph_out_image2" />
</standard_surface>
<output name="surf_graph_node_out" type="surfaceshader" nodename="default_shader" />
-->

<!-- 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
45 changes: 43 additions & 2 deletions source/MaterialXCore/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,15 @@ OutputPtr Input::getConnectedOutput() const
// Look for output on a node
else if (hasNodeName())
{
const string& nodeName = getNodeName();
ConstGraphElementPtr graph = getAncestorOfType<GraphElement>();
NodePtr node = graph ? graph->getNode(getNodeName()) : nullptr;
NodePtr node = graph ? graph->getNode(nodeName) : nullptr;
Copy link
Author

Choose a reason for hiding this comment

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

For a given nodegraph input check at the parent nodegraph level for a connection.

Choose a reason for hiding this comment

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

I think there is a risk of ambiguity here, if a node outside the graph has the same name as a node inside the graph. It's a possible setup since they have two different naming scopes.

So if a nodegraph input connects to a node "foo1" outside the graph (nodename="foo1"), but there is also a node inside the graph named "foo1", the node inside the graph will be used, since both scopes are checked and inside nodes takes precedence. This would naturally be invalid since a node inside the graph is not connectable to a nodegraph input.

I think we have to handle graph inputs and node inputs separately in this traversal, since graph inputs can only connect to elements outside the graph scope, and node inputs can only connected to elements in the same scope as the node.

Copy link
Author

@bernardkwok bernardkwok Dec 11, 2020

Choose a reason for hiding this comment

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

I was trying to make this as reusable as possible. I'll need to take a closer look but getAncestorOfType<>() on an input in a graph is what being handled here which requires traversing twice as the first returned value is the graph itself and not it's parent.

Basically, the rule for node vs nodegraph does not differ -- look for the referenced item on the parent.

Choose a reason for hiding this comment

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

I'm mainly thinking of name collisions with nodes inside vs outside the graph scope. As in this example:

<constant name="foo1" type="color3">
    <parameter name="value" type="color3" value="1, 0, 0"/>
</constant>
<nodegraph name="graph1" >
    <input name="in1" type="color3" nodename="foo1" />
    <input name="in2" type="color3" value="0, 1, 0" />
    <constant name="foo1" type="float">
        <parameter name="value" type="float" value="0.5"/>
    </constant>
    <mix name="mix1" type="color3">
      <input name="bg" type="color3" interfacename="in1" />
      <input name="fg" type="color3" interfacename="in1" />
      <input name="mix" type="float" nodename="foo1" />
    </mix>
    <output name="out" type="color3" nodename="mix1" />
</nodegraph>

If the internal scope is always searched first, in this case the internal node "foo1" would be returned as being connected to the input "in1", when in fact it is the external node "foo1" that is connected.

A test case like this could be added to make sure this is handled correctly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@bernardkwok @niklasharrysson As discussed in a separate thread, I think it would be valuable to merge the latest work from the v1.38 branch of MaterialX before proceeding too far with these new improvements, as there's a good deal of code that's been removed from Interface.cpp.

Copy link
Author

Choose a reason for hiding this comment

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

I've done the merge so this logic still needs to be resolved :).
@niklasharrysson, looking at the same level will give the wrong result for "in1". So I guess the branching logic would need to be:
if (input is a child of a nodegraph)
{
look for referenced node/graph from parent of nodegraph.
}
else
{
look for referenced node/graph from parent of node.
}

This basically means to always look up 2 levels from the input (if they exist).

We don't have the concept of a input which is not a child of a node or nodegraph (i.e. at the Document level) so this does not need to be considered.

if (!node && graph)
{
ConstElementPtr parent = graph->getParent();
graph = parent->getAncestorOfType<GraphElement>();
node = graph ? graph->getNode(nodeName) : nullptr;
}
if (node)
{
std::vector<OutputPtr> outputs = node->getOutputs();
Expand All @@ -355,8 +362,29 @@ OutputPtr Input::getConnectedOutput() const
return result;
}

InputPtr Input::getInterface() const
bernardkwok marked this conversation as resolved.
Show resolved Hide resolved
{
const string& interfaceName = getInterfaceName();
if (!interfaceName.empty())
{
ConstNodeGraphPtr graph = getAncestorOfType<NodeGraph>();
if (graph && !graph->hasNodeDefString())
{
return graph->getInput(interfaceName);
}
}
return nullptr;
}

NodePtr Input::getConnectedNode() const
{
// Traverse through interface names to nodegraph input
InputPtr graphInput = getInterface();
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 @@ -366,8 +394,16 @@ NodePtr Input::getConnectedNode() const
}
if (hasNodeName())
{
// Check on current parent, and graph parent if any
const string& nodeName = getNodeName();
ConstGraphElementPtr graph = getAncestorOfType<GraphElement>();
NodePtr node = graph ? graph->getNode(getNodeName()) : nullptr;
NodePtr node = graph ? graph->getNode(nodeName) : nullptr;
Copy link
Author

Choose a reason for hiding this comment

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

For a given nodegraph input check at the parent nodegraph level for a connection.

if (!node && graph)
{
ConstElementPtr parent = graph->getParent();
graph = parent->getAncestorOfType<GraphElement>();
node = graph ? graph->getNode(nodeName) : nullptr;
}
if (node)
{
return node;
Expand Down Expand Up @@ -432,6 +468,11 @@ bool Input::validate(string* message) const
{
validateRequire(getDefaultGeomProp() != nullptr, res, message, "Invalid defaultgeomprop string");
}
InputPtr interfaceInput = getInterface();
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 @@ -268,6 +268,10 @@ class Input : public PortElement
/// @name Traversal
/// @{

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

/// Return the Edge with the given index that lies directly upstream from
/// this element in the dataflow graph.
Edge getUpstreamEdge(ConstMaterialPtr material = nullptr,
Expand Down
Loading