diff --git a/documents/Specification/MaterialX.Specification.md b/documents/Specification/MaterialX.Specification.md
index 4b99956fb4..0ef9146c5d 100644
--- a/documents/Specification/MaterialX.Specification.md
+++ b/documents/Specification/MaterialX.Specification.md
@@ -1148,7 +1148,7 @@ Math nodes have one or two spatially-varying inputs, and are used to perform a m
-* **`atan2`**: the arctangent of the expression (iny/inx); the output will be expressed in radians. If both `in1` and `in2` are provided, they must be the same type.
+* **`atan2`**: the arctangent of the expression (iny/inx); the output will be expressed in radians. If both `iny` and `inx` are provided, they must be the same type.
* `iny` (float or vectorN): the value or nodename for the "y" input; default is 0.0.
* `inx` (float or vectorN): the value or nodename for the "x" input; default is 1.0.
diff --git a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
index 90d3120bd7..912d6d9f37 100644
--- a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
+++ b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
@@ -340,25 +340,25 @@
-
+
-
+
-
+
-
+
diff --git a/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx b/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
index ab0d776936..34d6e9aae3 100644
--- a/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
+++ b/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
@@ -343,28 +343,28 @@
-
+
-
+
-
+
-
+
diff --git a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
index fcab8fd69d..5c61f9a979 100644
--- a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
+++ b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
@@ -341,25 +341,25 @@
-
+
-
+
-
+
-
+
diff --git a/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx b/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
index 1ba22ef6a3..0c1235e4fc 100644
--- a/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
+++ b/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
@@ -343,25 +343,25 @@
-
+
-
+
-
+
-
+
diff --git a/libraries/stdlib/stdlib_defs.mtlx b/libraries/stdlib/stdlib_defs.mtlx
index bb5e8edd1f..96a4f3b776 100644
--- a/libraries/stdlib/stdlib_defs.mtlx
+++ b/libraries/stdlib/stdlib_defs.mtlx
@@ -1999,8 +1999,8 @@
-
-
+
+
@@ -2024,8 +2024,8 @@
-
-
+
+
@@ -2049,8 +2049,8 @@
-
-
+
+
@@ -2074,8 +2074,8 @@
-
-
+
+
diff --git a/python/Scripts/genmdl.py b/python/Scripts/genmdl.py
index f42add0425..ac46e7af6c 100644
--- a/python/Scripts/genmdl.py
+++ b/python/Scripts/genmdl.py
@@ -165,13 +165,13 @@ def _writeOperatorFunc(file, outputType, arg1, functionName, arg2):
else:
file.write(INDENT + 'return ' + arg1 + ' ' + functionName + ' ' + arg2 + ';\n')
-def _writeTwoArgumentFunc(file, outputType, functionName):
+def _writeTwoArgumentFunc(file, outputType, functionName, arg1="mxp_in1", arg2="mxp_in2"):
if outputType == 'color4':
- file.write(INDENT + 'return mk_color4(' + functionName + '(mk_float4(mxp_in1), mk_float4(mxp_in2)));\n')
+ file.write(INDENT + 'return mk_color4(' + functionName + '(mk_float4(' + arg1 + '), mk_float4(' + arg2 + ')));\n')
elif outputType == 'color':
- file.write(INDENT + 'return color(' + functionName + '(float3(mxp_in1), float3(mxp_in2)));\n')
+ file.write(INDENT + 'return color(' + functionName + '(float3(' + arg1 + '), float3(' + arg2 + ')));\n')
else:
- file.write(INDENT + 'return ' + functionName + '(mxp_in1, mxp_in2);\n')
+ file.write(INDENT + 'return ' + functionName + '(' + arg1 + ', ' + arg2 + ');\n')
def _writeThreeArgumentFunc(file, outputType, functionName, arg1, arg2, arg3):
if outputType == 'color4':
@@ -661,7 +661,7 @@ def main():
_writeOneArgumentFunc(file, outputType, '::math::'+nodeCategory)
wroteImplementation = True
elif nodeCategory == 'atan2':
- _writeTwoArgumentFunc(file, outputType, '::math::'+nodeCategory)
+ _writeTwoArgumentFunc(file, outputType, '::math::'+nodeCategory, arg1=mxp_iny, arg2=mxp_inx)
wroteImplementation = True
elif nodeCategory == 'sqrt':
_writeOneArgumentFunc(file, outputType, '::math::'+nodeCategory)
diff --git a/resources/Lights/envmap_shader.mtlx b/resources/Lights/envmap_shader.mtlx
index 8c9c6ec0f5..235b1a2ab9 100644
--- a/resources/Lights/envmap_shader.mtlx
+++ b/resources/Lights/envmap_shader.mtlx
@@ -15,8 +15,8 @@
-
-
+
+
diff --git a/resources/Materials/TestSuite/stdlib/math/trig.mtlx b/resources/Materials/TestSuite/stdlib/math/trig.mtlx
index 7e0702796f..5c52983757 100644
--- a/resources/Materials/TestSuite/stdlib/math/trig.mtlx
+++ b/resources/Materials/TestSuite/stdlib/math/trig.mtlx
@@ -188,29 +188,29 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/source/MaterialXCore/Document.cpp b/source/MaterialXCore/Document.cpp
index 9fe55537ac..f19f0fcb61 100644
--- a/source/MaterialXCore/Document.cpp
+++ b/source/MaterialXCore/Document.cpp
@@ -1419,6 +1419,30 @@ void Document::upgradeVersion()
removeNode(top->getName());
}
}
+
+ NodePtr node = elem->asA();
+ if (!node)
+ {
+ continue;
+ }
+ const string& nodeCategory = node->getCategory();
+ if (nodeCategory == "atan2")
+ {
+ // rename input ports
+ // "in1" -> "iny"
+ // "in2" -> "inx"
+
+ auto input1 = node->getInput("in1");
+ if (input1)
+ {
+ input1->setName("iny");
+ }
+ auto input2 = node->getInput("in2");
+ if (input2)
+ {
+ input2->setName("inx");
+ }
+ }
}
removeNodeDef("ND_thin_film_bsdf");
diff --git a/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl b/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl
index bce4a44ea5..b83417521f 100644
--- a/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl
+++ b/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl
@@ -1513,14 +1513,14 @@ export float mx_acos_float(
}
export float mx_atan2_float(
- float mxp_in1 = float(1.0),
- float mxp_in2 = float(0.0)
+ float mxp_iny = float(1.0),
+ float mxp_inx = float(0.0)
)
[[
anno::description("Node Group: math")
]]
{
- return ::math::atan2(mxp_in1, mxp_in2);
+ return ::math::atan2(mxp_iny, mxp_inx);
}
export float2 mx_sin_vector2(
@@ -1574,14 +1574,14 @@ export float2 mx_acos_vector2(
}
export float2 mx_atan2_vector2(
- float2 mxp_in1 = float2(1.0, 1.0),
- float2 mxp_in2 = float2(0.0, 0.0)
+ float2 mxp_iny = float2(1.0, 1.0),
+ float2 mxp_inx = float2(0.0, 0.0)
)
[[
anno::description("Node Group: math")
]]
{
- return ::math::atan2(mxp_in1, mxp_in2);
+ return ::math::atan2(mxp_iny, mxp_inx);
}
export float3 mx_sin_vector3(
@@ -1635,14 +1635,14 @@ export float3 mx_acos_vector3(
}
export float3 mx_atan2_vector3(
- float3 mxp_in1 = float3(1.0, 1.0, 1.0),
- float3 mxp_in2 = float3(0.0, 0.0, 0.0)
+ float3 mxp_iny = float3(1.0, 1.0, 1.0),
+ float3 mxp_inx = float3(0.0, 0.0, 0.0)
)
[[
anno::description("Node Group: math")
]]
{
- return ::math::atan2(mxp_in1, mxp_in2);
+ return ::math::atan2(mxp_iny, mxp_inx);
}
export float4 mx_sin_vector4(
@@ -1696,14 +1696,14 @@ export float4 mx_acos_vector4(
}
export float4 mx_atan2_vector4(
- float4 mxp_in1 = float4(1.0, 1.0, 1.0, 1.0),
- float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0)
+ float4 mxp_iny = float4(1.0, 1.0, 1.0, 1.0),
+ float4 mxp_inx = float4(0.0, 0.0, 0.0, 0.0)
)
[[
anno::description("Node Group: math")
]]
{
- return ::math::atan2(mxp_in1, mxp_in2);
+ return ::math::atan2(mxp_iny, mxp_inx);
}
export float mx_sqrt_float(