Skip to content

Commit 9e755e1

Browse files
committed
Fix case where an enumerated input is driven by an interfacename.
1 parent 286e458 commit 9e755e1

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

source/MaterialXGenShader/ShaderNode.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,21 @@ void ShaderNode::initialize(const Node& node, const NodeDef& nodeDef, GenContext
353353
}
354354
}
355355
const string& valueString = portValue ? portValue->getValueString() : EMPTY_STRING;
356-
std::pair<TypeDesc, ValuePtr> enumResult;
357-
const string& enumNames = nodeDefInput->getAttribute(ValueElement::ENUM_ATTRIBUTE);
358-
const TypeDesc type = context.getTypeDesc(nodeDefInput->getType());
359-
if (context.getShaderGenerator().getSyntax().remapEnumeration(valueString, type, enumNames, enumResult))
360-
{
361-
input->setValue(enumResult.second);
362-
}
363-
else if (!valueString.empty())
356+
if (!valueString.empty())
364357
{
365-
input->setValue(portValue);
358+
// We explicitly check the valueString is not empty before checking the enumeration,
359+
// because otherwise the enumeration value would always return nullptr
360+
std::pair<TypeDesc, ValuePtr> enumResult;
361+
const string& enumNames = nodeDefInput->getAttribute(ValueElement::ENUM_ATTRIBUTE);
362+
const TypeDesc type = context.getTypeDesc(nodeDefInput->getType());
363+
if (context.getShaderGenerator().getSyntax().remapEnumeration(valueString, type, enumNames, enumResult))
364+
{
365+
input->setValue(enumResult.second);
366+
}
367+
else
368+
{
369+
input->setValue(portValue);
370+
}
366371
}
367372
}
368373
}

0 commit comments

Comments
 (0)