Skip to content

Commit

Permalink
Fix renaming of the ND_normalmap_vector2 node definition.
Browse files Browse the repository at this point in the history
The upgrade code for the <normalmap> shader was indiscriminately
renaming all node definitions to "ND_normalmap_float". This included
"ND_normalmap_vecto2" nodes, whose nodedef should not be renamed.

This commit fixes that, limiting the renaming only to "ND_normalmap",
based on the type of the "scale" input, which is the only
differentiating factor between the two definitions.
  • Loading branch information
rafalSFX committed Sep 18, 2024
1 parent 29dc40a commit e4c3c64
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions source/MaterialXCore/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,8 +1316,17 @@ void Document::upgradeVersion()
}
else if (nodeCategory == "normalmap")
{
// ND_normalmap was renamed to ND_normalmap_float
node->setNodeDefString("ND_normalmap_float");
// ND_normalmap was renamed to ND_normalmap_float.
// But, there is also ND_normalmap_vector2 that was not renamed.
// The only difference between them is the "scale" input type
// (float and vector2, respectively), so use that as a test.
NodeDefPtr nodeDef = getShaderNodeDef(node);
InputPtr scaleInput = node->getInput("scale");
if ((nodeDef && nodeDef->getName() == "ND_normalmap") ||
(scaleInput && scaleInput->getType() == "float"))
{
node->setNodeDefString("ND_normalmap_float");
}

node->removeInput("space");

Expand Down

0 comments on commit e4c3c64

Please sign in to comment.