Skip to content

Commit

Permalink
Fix elision of dot nodes (AcademySoftwareFoundation#1250)
Browse files Browse the repository at this point in the history
This changelist fixes a bug in the elision of dot nodes (AcademySoftwareFoundation#1152), where dot nodes with channels attributes would be incorrectly bypassed, causing the shader generator to produce incorrect code.
  • Loading branch information
jstone-lucasfilm authored Feb 18, 2023
1 parent 36ebf56 commit b3471cb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions source/MaterialXGenShader/ShaderGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,14 +1020,22 @@ void ShaderGraph::optimize(GenContext& context)
size_t numEdits = 0;
for (ShaderNode* node : getNodes())
{
if (node->hasClassification(ShaderNode::Classification::CONSTANT) ||
node->hasClassification(ShaderNode::Classification::DOT))
if (node->hasClassification(ShaderNode::Classification::CONSTANT))
{
// Constant and dot nodes can be removed by moving their value
// or connection downstream.
// Constant nodes can be elided by moving their value downstream.
bypass(context, node, 0);
++numEdits;
}
else if (node->hasClassification(ShaderNode::Classification::DOT))
{
// Dot nodes without modifiers can be elided by moving their connection downstream.
ShaderInput* in = node->getInput("in");
if (in->getChannels().empty())
{
bypass(context, node, 0);
++numEdits;
}
}
else if (node->hasClassification(ShaderNode::Classification::IFELSE))
{
// Check if we have a constant conditional expression
Expand Down

0 comments on commit b3471cb

Please sign in to comment.