Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add matrix type switch nodes #1779

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documents/Specification/MaterialX.Specification.md
Original file line number Diff line number Diff line change
@@ -1592,7 +1592,7 @@ Conditional nodes are used to compare values of two streams, or to select a valu
<a id="node-switch"> </a>

* **`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, color<em>N</em> or vector<em>N</em>, 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 color<em>N</em> or vector<em>N</em>): the values or nodenames to select from based on the value of the `which` input. The types of the various `in`<em>N</em> inputs must match the type of the `switch` node itself. The default value of all `in`<em>N</em> inputs is 0.0 in all channels.
* `in1`, `in2`, `in3`, `in4`, `in5`, `in6`, `in7`, `in8`, `in9`, `in10` (float or color<em>N</em> or vector<em>N</em> 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`<em>N</em> inputs must match the type of the `switch` node itself. The default value of all `in`<em>N</em> 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`&lt;1 will pass on the value from in1, 1&lt;=`which`&lt;2 will pass the value from in2, 2&lt;=`which`&lt;3 will pass the value from in3, and so on up to 9&lt;=`which` will pass the value from in10. The default value of `which` is 0.

<a id="node-ifelse"> </a>
4 changes: 4 additions & 0 deletions libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
Original file line number Diff line number Diff line change
@@ -645,6 +645,8 @@
<implementation name="IM_switch_vector2_genglsl" nodedef="ND_switch_vector2" target="genglsl" />
<implementation name="IM_switch_vector3_genglsl" nodedef="ND_switch_vector3" target="genglsl" />
<implementation name="IM_switch_vector4_genglsl" nodedef="ND_switch_vector4" target="genglsl" />
<implementation name="IM_switch_matrix33_genglsl" nodedef="ND_switch_matrix33" target="genglsl" />
<implementation name="IM_switch_matrix44_genglsl" nodedef="ND_switch_matrix44" target="genglsl" />

<!-- 'which' type : integer -->
<implementation name="IM_switch_floatI_genglsl" nodedef="ND_switch_floatI" target="genglsl" />
@@ -653,6 +655,8 @@
<implementation name="IM_switch_vector2I_genglsl" nodedef="ND_switch_vector2I" target="genglsl" />
<implementation name="IM_switch_vector3I_genglsl" nodedef="ND_switch_vector3I" target="genglsl" />
<implementation name="IM_switch_vector4I_genglsl" nodedef="ND_switch_vector4I" target="genglsl" />
<implementation name="IM_switch_matrix33I_genglsl" nodedef="ND_switch_matrix33I" target="genglsl" />
<implementation name="IM_switch_matrix44I_genglsl" nodedef="ND_switch_matrix44I" target="genglsl" />

<!-- ======================================================================== -->
<!-- Channel nodes -->
4 changes: 4 additions & 0 deletions libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
Original file line number Diff line number Diff line change
@@ -654,13 +654,17 @@
<implementation name="IM_switch_vector2_genmdl" nodedef="ND_switch_vector2" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_vector2({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector3_genmdl" nodedef="ND_switch_vector3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_vector3({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector4_genmdl" nodedef="ND_switch_vector4" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_vector4({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_matrix33_genmdl" nodedef="ND_switch_matrix33" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_matrix33({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_matrix44_genmdl" nodedef="ND_switch_matrix44" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_matrix44({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<!-- 'which' type : integer -->
<implementation name="IM_switch_floatI_genmdl" nodedef="ND_switch_floatI" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_floatI({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_color3I_genmdl" nodedef="ND_switch_color3I" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_color3I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_color4I_genmdl" nodedef="ND_switch_color4I" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_color4I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector2I_genmdl" nodedef="ND_switch_vector2I" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_vector2I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector3I_genmdl" nodedef="ND_switch_vector3I" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_vector3I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector4I_genmdl" nodedef="ND_switch_vector4I" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_vector4I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_matrix33I_genmdl" nodedef="ND_switch_matrix33I" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_matrix33I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_matrix44I_genmdl" nodedef="ND_switch_matrix44I" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_switch_matrix44I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />

<!-- ======================================================================== -->
<!-- Channel nodes -->
4 changes: 4 additions & 0 deletions libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
Original file line number Diff line number Diff line change
@@ -645,6 +645,8 @@
<implementation name="IM_switch_vector2_genmsl" nodedef="ND_switch_vector2" target="genmsl" />
<implementation name="IM_switch_vector3_genmsl" nodedef="ND_switch_vector3" target="genmsl" />
<implementation name="IM_switch_vector4_genmsl" nodedef="ND_switch_vector4" target="genmsl" />
<implementation name="IM_switch_matrix33_genmsl" nodedef="ND_switch_matrix33" target="genmsl" />
<implementation name="IM_switch_matrix44_genmsl" nodedef="ND_switch_matrix44" target="genmsl" />

<!-- 'which' type : integer -->
<implementation name="IM_switch_floatI_genmsl" nodedef="ND_switch_floatI" target="genmsl" />
@@ -653,6 +655,8 @@
<implementation name="IM_switch_vector2I_genmsl" nodedef="ND_switch_vector2I" target="genmsl" />
<implementation name="IM_switch_vector3I_genmsl" nodedef="ND_switch_vector3I" target="genmsl" />
<implementation name="IM_switch_vector4I_genmsl" nodedef="ND_switch_vector4I" target="genmsl" />
<implementation name="IM_switch_matrix33I_genmsl" nodedef="ND_switch_matrix33I" target="genmsl" />
<implementation name="IM_switch_matrix44I_genmsl" nodedef="ND_switch_matrix44I" target="genmsl" />

<!-- ======================================================================== -->
<!-- Channel nodes -->
4 changes: 4 additions & 0 deletions libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
Original file line number Diff line number Diff line change
@@ -645,13 +645,17 @@
<implementation name="IM_switch_vector2_genosl" nodedef="ND_switch_vector2" target="genosl" />
<implementation name="IM_switch_vector3_genosl" nodedef="ND_switch_vector3" target="genosl" />
<implementation name="IM_switch_vector4_genosl" nodedef="ND_switch_vector4" target="genosl" />
<implementation name="IM_switch_matrix33_genosl" nodedef="ND_switch_matrix33" target="genosl" />
<implementation name="IM_switch_matrix44_genosl" nodedef="ND_switch_matrix44" target="genosl" />
<!-- 'which' type : integer -->
<implementation name="IM_switch_floatI_genosl" nodedef="ND_switch_floatI" target="genosl" />
<implementation name="IM_switch_color3I_genosl" nodedef="ND_switch_color3I" target="genosl" />
<implementation name="IM_switch_color4I_genosl" nodedef="ND_switch_color4I" target="genosl" />
<implementation name="IM_switch_vector2I_genosl" nodedef="ND_switch_vector2I" target="genosl" />
<implementation name="IM_switch_vector3I_genosl" nodedef="ND_switch_vector3I" target="genosl" />
<implementation name="IM_switch_vector4I_genosl" nodedef="ND_switch_vector4I" target="genosl" />
<implementation name="IM_switch_matrix33I_genosl" nodedef="ND_switch_matrix33I" target="genosl" />
<implementation name="IM_switch_matrix44I_genosl" nodedef="ND_switch_matrix44I" target="genosl" />

<!-- ======================================================================== -->
<!-- Channel nodes -->
56 changes: 56 additions & 0 deletions libraries/stdlib/stdlib_defs.mtlx
Original file line number Diff line number Diff line change
@@ -4010,6 +4010,34 @@
<input name="which" type="float" value="0.0" />
<output name="out" type="vector4" defaultinput="in1" />
</nodedef>
<nodedef name="ND_switch_matrix33" node="switch" nodegroup="conditional">
<input name="in1" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in2" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in3" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in4" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in5" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in6" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in7" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in8" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in9" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in10" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="which" type="float" value="0.0" />
<output name="out" type="matrix33" defaultinput="in1" />
</nodedef>
<nodedef name="ND_switch_matrix44" node="switch" nodegroup="conditional">
<input name="in1" type="matrix44" value="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" />
<input name="in2" type="matrix44" value="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" />
<input name="in3" type="matrix44" value="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" />
<input name="in4" type="matrix44" value="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" />
<input name="in5" type="matrix44" value="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" />
<input name="in6" type="matrix44" value="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" />
<input name="in7" type="matrix44" value="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" />
<input name="in8" type="matrix44" value="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" />
<input name="in9" type="matrix44" value="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" />
<input name="in10" type="matrix44" value="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" />
<input name="which" type="float" value="0.0" />
<output name="out" type="matrix44" defaultinput="in1" />
</nodedef>
<nodedef name="ND_switch_floatI" node="switch" nodegroup="conditional">
<input name="in1" type="float" value="0.0" />
<input name="in2" type="float" value="0.0" />
@@ -4094,6 +4122,34 @@
<input name="which" type="integer" value="0" />
<output name="out" type="vector4" defaultinput="in1" />
</nodedef>
<nodedef name="ND_switch_matrix33I" node="switch" nodegroup="conditional">
<input name="in1" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in2" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in3" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in4" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in5" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in6" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in7" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in8" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in9" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in10" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="which" type="integer" value="0" />
<output name="out" type="matrix33" defaultinput="in1" />
</nodedef>
<nodedef name="ND_switch_matrix44I" node="switch" nodegroup="conditional">
<input name="in1" type="matrix44" value="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" />
<input name="in2" type="matrix44" value="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" />
<input name="in3" type="matrix44" value="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" />
<input name="in4" type="matrix44" value="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" />
<input name="in5" type="matrix44" value="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" />
<input name="in6" type="matrix44" value="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" />
<input name="in7" type="matrix44" value="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" />
<input name="in8" type="matrix44" value="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" />
<input name="in9" type="matrix44" value="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" />
<input name="in10" type="matrix44" value="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" />
<input name="which" type="integer" value="0" />
<output name="out" type="matrix44" defaultinput="in1" />
</nodedef>

<!-- ======================================================================== -->
<!-- Channel nodes -->
Original file line number Diff line number Diff line change
@@ -69,6 +69,28 @@
</switch>
<output name="out" type="vector4" nodename="switch1" />
</nodegraph>
<nodegraph name="switch_matrix33">
<switch name="switch1" type="matrix33">
<input name="in1" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in2" type="matrix33" value="0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000" />
<input name="in3" type="matrix33" value="0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000" />
<input name="in4" type="matrix33" value="0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000" />
<input name="in5" type="matrix33" value="1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000" />
<input name="which" type="float" value="3.0000" />
</switch>
<output name="out" type="matrix33" nodename="switch1" />
</nodegraph>
<nodegraph name="switch_matrix44">
<switch name="switch1" type="matrix44">
<input name="in1" type="matrix44" value="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" />
<input name="in2" type="matrix44" value="0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000" />
<input name="in3" type="matrix44" value="0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000" />
<input name="in4" type="matrix44" value="0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000" />
<input name="in5" type="matrix44" value="1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000" />
<input name="which" type="float" value="3.0000" />
</switch>
<output name="out" type="matrix44" nodename="switch1" />
</nodegraph>
<nodegraph name="switch_floatI">
<switch name="switch1" type="float">
<input name="in1" type="float" value="0.0" />
@@ -135,6 +157,28 @@
</switch>
<output name="out" type="vector4" nodename="switch1" />
</nodegraph>
<nodegraph name="switch_matrix33I">
<switch name="switch1" type="matrix33">
<input name="in1" type="matrix33" value="0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0" />
<input name="in2" type="matrix33" value="0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000" />
<input name="in3" type="matrix33" value="0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000" />
<input name="in4" type="matrix33" value="0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000" />
<input name="in5" type="matrix33" value="1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000" />
<input name="which" type="integer" value="2" />
</switch>
<output name="out" type="matrix33" nodename="switch1" />
</nodegraph>
<nodegraph name="switch_matrix44I">
<switch name="switch1" type="matrix44">
<input name="in1" type="matrix44" value="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" />
<input name="in2" type="matrix44" value="0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000" />
<input name="in3" type="matrix44" value="0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000" />
<input name="in4" type="matrix44" value="0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000, 0.7000" />
<input name="in5" type="matrix44" value="1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000" />
<input name="which" type="integer" value="2" />
</switch>
<output name="out" type="matrix44" nodename="switch1" />
</nodegraph>
<nodegraph name="switch_vector3_geometric">
<tangent name="tangent1" type="vector3" />
<bitangent name="bitangent1" type="vector3" />
4 changes: 4 additions & 0 deletions source/MaterialXGenGlsl/GlslShaderGenerator.cpp
Original file line number Diff line number Diff line change
@@ -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,

// <!-- 'which' type : integer -->
"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);

136 changes: 136 additions & 0 deletions source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl
Original file line number Diff line number Diff line change
@@ -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)
)
4 changes: 4 additions & 0 deletions source/MaterialXGenMdl/mdl/materialx/stdlib_1_8.mdl
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 4 additions & 0 deletions source/MaterialXGenMsl/MslShaderGenerator.cpp
Original file line number Diff line number Diff line change
@@ -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,

// <!-- 'which' type : integer -->
"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);

4 changes: 4 additions & 0 deletions source/MaterialXGenOsl/OslShaderGenerator.cpp
Original file line number Diff line number Diff line change
@@ -44,13 +44,17 @@ 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);
// <!-- 'which' type : integer -->
registerImplementation("IM_switch_floatI_" + OslShaderGenerator::TARGET, SwitchNode::create);
registerImplementation("IM_switch_color3I_" + OslShaderGenerator::TARGET, SwitchNode::create);
registerImplementation("IM_switch_color4I_" + OslShaderGenerator::TARGET, SwitchNode::create);
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);

// <!-- <swizzle> -->
// <!-- from type : float -->