diff --git a/documents/Specification/MaterialX.Specification.md b/documents/Specification/MaterialX.Specification.md
index c66a448798..158cb9ddae 100644
--- a/documents/Specification/MaterialX.Specification.md
+++ b/documents/Specification/MaterialX.Specification.md
@@ -1592,7 +1592,7 @@ Conditional nodes are used to compare values of two streams, or to select a valu
* **`switch`**: output the value of one of up to ten input streams, according to the value of a selector input `which`. Switch nodes can be of output type float, colorN or vectorN, and have five inputs, in1 through in10 (not all of which must be connected), which must match the output type.
- * `in1`, `in2`, `in3`, `in4`, `in5`, `in6`, `in7`, `in8`, `in9`, `in10` (float or colorN or vectorN): the values or nodenames to select from based on the value of the `which` input. The types of the various `in`N inputs must match the type of the `switch` node itself. The default value of all `in`N inputs is 0.0 in all channels.
+ * `in1`, `in2`, `in3`, `in4`, `in5`, `in6`, `in7`, `in8`, `in9`, `in10` (float or colorN or vectorN or matrix33 or matrix44): the values or nodenames to select from based on the value of the `which` input. The types of the various `in`N inputs must match the type of the `switch` node itself. The default value of all `in`N inputs is 0.0 in all channels.
* `which` (integer or float): a selector to choose which input to take values from; the output comes from input "floor(`which`)+1", clamped to the 1-10 range. So `which`<1 will pass on the value from in1, 1<=`which`<2 will pass the value from in2, 2<=`which`<3 will pass the value from in3, and so on up to 9<=`which` will pass the value from in10. The default value of `which` is 0.
diff --git a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
index dfbb639560..3453b34d83 100644
--- a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
+++ b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
@@ -645,6 +645,8 @@
+
+
@@ -653,6 +655,8 @@
+
+
diff --git a/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx b/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
index b5e24f2f8e..f2ccc6854f 100644
--- a/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
+++ b/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
@@ -654,6 +654,8 @@
+
+
@@ -661,6 +663,8 @@
+
+
diff --git a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
index dd1eb93273..4610af9917 100644
--- a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
+++ b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
@@ -645,6 +645,8 @@
+
+
@@ -653,6 +655,8 @@
+
+
diff --git a/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx b/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
index e51e0a4631..8a75b268ab 100644
--- a/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
+++ b/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
@@ -645,6 +645,8 @@
+
+
@@ -652,6 +654,8 @@
+
+
diff --git a/libraries/stdlib/stdlib_defs.mtlx b/libraries/stdlib/stdlib_defs.mtlx
index 010e2bfc1d..b1514061e8 100644
--- a/libraries/stdlib/stdlib_defs.mtlx
+++ b/libraries/stdlib/stdlib_defs.mtlx
@@ -4010,6 +4010,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -4094,6 +4122,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/Materials/TestSuite/stdlib/conditional/conditional_switch.mtlx b/resources/Materials/TestSuite/stdlib/conditional/conditional_switch.mtlx
index 70c9ad29d1..7ed363e962 100644
--- a/resources/Materials/TestSuite/stdlib/conditional/conditional_switch.mtlx
+++ b/resources/Materials/TestSuite/stdlib/conditional/conditional_switch.mtlx
@@ -69,6 +69,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -135,6 +157,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/MaterialXGenGlsl/GlslShaderGenerator.cpp b/source/MaterialXGenGlsl/GlslShaderGenerator.cpp
index c33f262c79..09fdedd177 100644
--- a/source/MaterialXGenGlsl/GlslShaderGenerator.cpp
+++ b/source/MaterialXGenGlsl/GlslShaderGenerator.cpp
@@ -67,6 +67,8 @@ GlslShaderGenerator::GlslShaderGenerator() :
"IM_switch_vector2_" + GlslShaderGenerator::TARGET,
"IM_switch_vector3_" + GlslShaderGenerator::TARGET,
"IM_switch_vector4_" + GlslShaderGenerator::TARGET,
+ "IM_switch_matrix33_" + GlslShaderGenerator::TARGET,
+ "IM_switch_matrix44_" + GlslShaderGenerator::TARGET,
//
"IM_switch_floatI_" + GlslShaderGenerator::TARGET,
@@ -75,6 +77,8 @@ GlslShaderGenerator::GlslShaderGenerator() :
"IM_switch_vector2I_" + GlslShaderGenerator::TARGET,
"IM_switch_vector3I_" + GlslShaderGenerator::TARGET,
"IM_switch_vector4I_" + GlslShaderGenerator::TARGET,
+ "IM_switch_matrix33I_" + GlslShaderGenerator::TARGET,
+ "IM_switch_matrix44I_" + GlslShaderGenerator::TARGET,
};
registerImplementation(elementNames, SwitchNode::create);
diff --git a/source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl b/source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl
index 8b948bb605..2f9f58e25e 100644
--- a/source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl
+++ b/source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl
@@ -3765,6 +3765,74 @@ export float4 mx_switch_vector4(
return returnValue;
}
+export float3x3 mx_switch_matrix33(
+ float3x3 mxp_in1 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in2 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in3 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in4 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in5 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in6 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in7 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in8 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in9 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in10 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float mxp_which = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float3x3 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ case 5: returnValue=mxp_in6; break;
+ case 6: returnValue=mxp_in7; break;
+ case 7: returnValue=mxp_in8; break;
+ case 8: returnValue=mxp_in9; break;
+ case 9: returnValue=mxp_in10; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export float4x4 mx_switch_matrix44(
+ float4x4 mxp_in1 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in2 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in3 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in4 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in5 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in6 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in7 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in8 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in9 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in10 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float mxp_which = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float4x4 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ case 5: returnValue=mxp_in6; break;
+ case 6: returnValue=mxp_in7; break;
+ case 7: returnValue=mxp_in8; break;
+ case 8: returnValue=mxp_in9; break;
+ case 9: returnValue=mxp_in10; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
export float mx_switch_floatI(
float mxp_in1 = float(0.0),
float mxp_in2 = float(0.0),
@@ -3909,6 +3977,74 @@ export float4 mx_switch_vector4I(
return returnValue;
}
+export float3x3 mx_switch_matrix33I(
+ float3x3 mxp_in1 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in2 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in3 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in4 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in5 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in6 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in7 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in8 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in9 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float3x3 mxp_in10 = float3x3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ int mxp_which = int(0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float3x3 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ case 5: returnValue=mxp_in6; break;
+ case 6: returnValue=mxp_in7; break;
+ case 7: returnValue=mxp_in8; break;
+ case 8: returnValue=mxp_in9; break;
+ case 9: returnValue=mxp_in10; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export float4x4 mx_switch_matrix44I(
+ float4x4 mxp_in1 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in2 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in3 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in4 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in5 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in6 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in7 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in8 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in9 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_in10 = float4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
+ int mxp_which = int(0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float4x4 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ case 5: returnValue=mxp_in6; break;
+ case 6: returnValue=mxp_in7; break;
+ case 7: returnValue=mxp_in8; break;
+ case 8: returnValue=mxp_in9; break;
+ case 9: returnValue=mxp_in10; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
export color mx_convert_float_color3(
float mxp_in = float(0.0)
)
diff --git a/source/MaterialXGenMdl/mdl/materialx/stdlib_1_8.mdl b/source/MaterialXGenMdl/mdl/materialx/stdlib_1_8.mdl
index da22210c42..5d73b58866 100644
--- a/source/MaterialXGenMdl/mdl/materialx/stdlib_1_8.mdl
+++ b/source/MaterialXGenMdl/mdl/materialx/stdlib_1_8.mdl
@@ -265,12 +265,16 @@ export using .::stdlib_1_7 import mx_switch_color4;
export using .::stdlib_1_7 import mx_switch_vector2;
export using .::stdlib_1_7 import mx_switch_vector3;
export using .::stdlib_1_7 import mx_switch_vector4;
+export using .::stdlib_1_7 import mx_switch_matrix33;
+export using .::stdlib_1_7 import mx_switch_matrix44;
export using .::stdlib_1_7 import mx_switch_floatI;
export using .::stdlib_1_7 import mx_switch_color3I;
export using .::stdlib_1_7 import mx_switch_color4I;
export using .::stdlib_1_7 import mx_switch_vector2I;
export using .::stdlib_1_7 import mx_switch_vector3I;
export using .::stdlib_1_7 import mx_switch_vector4I;
+export using .::stdlib_1_7 import mx_switch_matrix33I;
+export using .::stdlib_1_7 import mx_switch_matrix44I;
export using .::stdlib_1_7 import mx_convert_float_color3;
export using .::stdlib_1_7 import mx_convert_float_color4;
export using .::stdlib_1_7 import mx_convert_float_vector2;
diff --git a/source/MaterialXGenMsl/MslShaderGenerator.cpp b/source/MaterialXGenMsl/MslShaderGenerator.cpp
index db23510ad8..bf22127f26 100644
--- a/source/MaterialXGenMsl/MslShaderGenerator.cpp
+++ b/source/MaterialXGenMsl/MslShaderGenerator.cpp
@@ -71,6 +71,8 @@ MslShaderGenerator::MslShaderGenerator() :
"IM_switch_vector2_" + MslShaderGenerator::TARGET,
"IM_switch_vector3_" + MslShaderGenerator::TARGET,
"IM_switch_vector4_" + MslShaderGenerator::TARGET,
+ "IM_switch_matrix33_" + MslShaderGenerator::TARGET,
+ "IM_switch_matrix44_" + MslShaderGenerator::TARGET,
//
"IM_switch_floatI_" + MslShaderGenerator::TARGET,
@@ -79,6 +81,8 @@ MslShaderGenerator::MslShaderGenerator() :
"IM_switch_vector2I_" + MslShaderGenerator::TARGET,
"IM_switch_vector3I_" + MslShaderGenerator::TARGET,
"IM_switch_vector4I_" + MslShaderGenerator::TARGET,
+ "IM_switch_matrix33I_" + MslShaderGenerator::TARGET,
+ "IM_switch_matrix44I_" + MslShaderGenerator::TARGET,
};
registerImplementation(elementNames, SwitchNode::create);
diff --git a/source/MaterialXGenOsl/OslShaderGenerator.cpp b/source/MaterialXGenOsl/OslShaderGenerator.cpp
index 5f6a37e332..a7a6b089b9 100644
--- a/source/MaterialXGenOsl/OslShaderGenerator.cpp
+++ b/source/MaterialXGenOsl/OslShaderGenerator.cpp
@@ -44,6 +44,8 @@ OslShaderGenerator::OslShaderGenerator() :
registerImplementation("IM_switch_vector2_" + OslShaderGenerator::TARGET, SwitchNode::create);
registerImplementation("IM_switch_vector3_" + OslShaderGenerator::TARGET, SwitchNode::create);
registerImplementation("IM_switch_vector4_" + OslShaderGenerator::TARGET, SwitchNode::create);
+ registerImplementation("IM_switch_matrix33_" + OslShaderGenerator::TARGET, SwitchNode::create);
+ registerImplementation("IM_switch_matrix44_" + OslShaderGenerator::TARGET, SwitchNode::create);
//
registerImplementation("IM_switch_floatI_" + OslShaderGenerator::TARGET, SwitchNode::create);
registerImplementation("IM_switch_color3I_" + OslShaderGenerator::TARGET, SwitchNode::create);
@@ -51,6 +53,8 @@ OslShaderGenerator::OslShaderGenerator() :
registerImplementation("IM_switch_vector2I_" + OslShaderGenerator::TARGET, SwitchNode::create);
registerImplementation("IM_switch_vector3I_" + OslShaderGenerator::TARGET, SwitchNode::create);
registerImplementation("IM_switch_vector4I_" + OslShaderGenerator::TARGET, SwitchNode::create);
+ registerImplementation("IM_switch_matrix33I_" + OslShaderGenerator::TARGET, SwitchNode::create);
+ registerImplementation("IM_switch_matrix44I_" + OslShaderGenerator::TARGET, SwitchNode::create);
//
//