Skip to content

Commit 83db613

Browse files
authored
Add multioutput type check in getShaderNodes (#2760)
This fixes #2529 This issue stems from validation that the Shader node’s output type matches the Material node’s input type. It doesn't note a multioutput node as a matching type and returns an empty shaderNodes vector to the Graph Editor. It never creates a Material due to not receiving shaderNodes, leading to the empty Render View in the Editor. This then leads to a lack of renderable elements in the Viewer. This change will check available activeOutputs for multiOutput nodes to ensure at least one active output is compatible with the input of the Material node (for example, surfaceshader to surfaceshader). It will maintain the previous behavior otherwise.
1 parent adef8cd commit 83db613

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

source/MaterialXCore/Material.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ vector<NodePtr> getShaderNodes(NodePtr materialNode, const string& nodeType, con
2020
NodePtr shaderNode = input->getConnectedNode();
2121
if (shaderNode && !shaderNodeSet.count(shaderNode))
2222
{
23-
if (!nodeType.empty() && shaderNode->getType() != nodeType)
23+
bool inputMatchesOutputType = !nodeType.empty() && shaderNode->getType() == nodeType;
24+
25+
if (shaderNode->isMultiOutputType())
26+
{
27+
const vector<OutputPtr>& activeOutputs = shaderNode->getActiveOutputs();
28+
bool multiOutputMatches = std::any_of(activeOutputs.begin(), activeOutputs.end(), [&nodeType](const OutputPtr& output)
29+
{
30+
return output->getType() == nodeType;
31+
});
32+
inputMatchesOutputType = multiOutputMatches || inputMatchesOutputType;
33+
}
34+
35+
if (!inputMatchesOutputType)
2436
{
2537
continue;
2638
}

0 commit comments

Comments
 (0)