Skip to content

Commit 710d5b6

Browse files
Fix Graph Editor crash with multioutput nodes (#2397)
When connecting multiple output nodes to surface shaders, `Graph::addLink` was not specifying the output being connected. As a consequence, the shader would end up using the first output on the upstream node which could cause shader compilation errors and exceptions if the input and output types did not match. This change ensures that the output is specified on the input pin.
1 parent c78cb5b commit 710d5b6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

source/MaterialXGraphEditor/Graph.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2652,7 +2652,16 @@ void Graph::addLink(ed::PinId startPinId, ed::PinId endPinId)
26522652
}
26532653
else
26542654
{
2655-
pin->_input->setConnectedNode(uiUpNode->getNode());
2655+
mx::NodePtr upstreamNode = uiUpNode->getNode();
2656+
if (upstreamNode)
2657+
{
2658+
mx::OutputPtr output = upstreamNode->getOutput(outputPin->_name);
2659+
if (!output)
2660+
{
2661+
output = upstreamNode->addOutput(outputPin->_name, pin->_input->getType());
2662+
}
2663+
pin->_input->setConnectedOutput(output);
2664+
}
26562665
}
26572666
}
26582667
}

0 commit comments

Comments
 (0)