diff --git a/resources/Materials/TestSuite/stdlib/upgrade/syntax_1_38.mtlx b/resources/Materials/TestSuite/stdlib/upgrade/syntax_1_38.mtlx
new file mode 100644
index 0000000000..21a465a1b9
--- /dev/null
+++ b/resources/Materials/TestSuite/stdlib/upgrade/syntax_1_38.mtlx
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/MaterialXCore/Version.cpp b/source/MaterialXCore/Version.cpp
index a1a6e16d5b..a7cddd942d 100644
--- a/source/MaterialXCore/Version.cpp
+++ b/source/MaterialXCore/Version.cpp
@@ -1316,15 +1316,20 @@ void Document::upgradeVersion()
}
else if (nodeCategory == "normalmap")
{
- // ND_normalmap was renamed to ND_normalmap_float
+ // The nodedef for scalar normal maps was renamed.
+ const string ORIG_SCALAR_NORMALMAP_ND = "ND_normalmap";
+ const string NEW_SCALAR_NORMALMAP_ND = "ND_normalmap_float";
NodeDefPtr nodeDef = getShaderNodeDef(node);
InputPtr scaleInput = node->getInput("scale");
- if ((nodeDef && nodeDef->getName() == "ND_normalmap") ||
- (scaleInput && scaleInput->getType() == "float"))
+ bool isScalarNormalMap = (nodeDef && nodeDef->getName() == ORIG_SCALAR_NORMALMAP_ND) ||
+ (node->getNodeDefString() == ORIG_SCALAR_NORMALMAP_ND) ||
+ (scaleInput && scaleInput->getType() == getTypeString());
+ if (isScalarNormalMap)
{
- node->setNodeDefString("ND_normalmap_float");
+ node->setNodeDefString(NEW_SCALAR_NORMALMAP_ND);
}
+ // The space input for normal maps was removed.
node->removeInput("space");
// If the normal or tangent inputs are set, the bitangent input should be normalize(cross(N, T))