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

Upgrade switch node to ten inputs in 1.39 #1660

Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 12 additions & 12 deletions libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -639,19 +639,19 @@

<!-- <switch> -->
<!-- 'which' type : float -->
<implementation name="IM_switch_float_genmdl" nodedef="ND_switch_float" sourcecode="mx::stdlib::mx_switch_float({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_color3_genmdl" nodedef="ND_switch_color3" sourcecode="mx::stdlib::mx_switch_color3({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_color4_genmdl" nodedef="ND_switch_color4" sourcecode="mx::stdlib::mx_switch_color4({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector2_genmdl" nodedef="ND_switch_vector2" sourcecode="mx::stdlib::mx_switch_vector2({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector3_genmdl" nodedef="ND_switch_vector3" sourcecode="mx::stdlib::mx_switch_vector3({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector4_genmdl" nodedef="ND_switch_vector4" sourcecode="mx::stdlib::mx_switch_vector4({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_float_genmdl" nodedef="ND_switch_float" sourcecode="mx::stdlib::mx_switch_float({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_color3_genmdl" nodedef="ND_switch_color3" sourcecode="mx::stdlib::mx_switch_color3({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_color4_genmdl" nodedef="ND_switch_color4" sourcecode="mx::stdlib::mx_switch_color4({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector2_genmdl" nodedef="ND_switch_vector2" sourcecode="mx::stdlib::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="mx::stdlib::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="mx::stdlib::mx_switch_vector4({{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="mx::stdlib::mx_switch_floatI({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_color3I_genmdl" nodedef="ND_switch_color3I" sourcecode="mx::stdlib::mx_switch_color3I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_color4I_genmdl" nodedef="ND_switch_color4I" sourcecode="mx::stdlib::mx_switch_color4I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector2I_genmdl" nodedef="ND_switch_vector2I" sourcecode="mx::stdlib::mx_switch_vector2I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector3I_genmdl" nodedef="ND_switch_vector3I" sourcecode="mx::stdlib::mx_switch_vector3I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_vector4I_genmdl" nodedef="ND_switch_vector4I" sourcecode="mx::stdlib::mx_switch_vector4I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{which}})" target="genmdl" />
<implementation name="IM_switch_floatI_genmdl" nodedef="ND_switch_floatI" sourcecode="mx::stdlib::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="mx::stdlib::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="mx::stdlib::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="mx::stdlib::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="mx::stdlib::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="mx::stdlib::mx_switch_vector4I({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{in5}}, {{in6}}, {{in7}}, {{in8}}, {{in9}}, {{in10}}, {{which}})" target="genmdl" />

<!-- ======================================================================== -->
<!-- Channel nodes -->
Expand Down
60 changes: 60 additions & 0 deletions libraries/stdlib/stdlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -3902,6 +3902,11 @@
<input name="in3" type="float" value="0.0" />
<input name="in4" type="float" value="0.0" />
<input name="in5" type="float" value="0.0" />
<input name="in6" type="float" value="0.0" />
<input name="in7" type="float" value="0.0" />
<input name="in8" type="float" value="0.0" />
<input name="in9" type="float" value="0.0" />
<input name="in10" type="float" value="0.0" />
<input name="which" type="float" value="0.0" />
<output name="out" type="float" defaultinput="in1" />
</nodedef>
Expand All @@ -3911,6 +3916,11 @@
<input name="in3" type="color3" value="0.0, 0.0, 0.0" />
<input name="in4" type="color3" value="0.0, 0.0, 0.0" />
<input name="in5" type="color3" value="0.0, 0.0, 0.0" />
<input name="in6" type="color3" value="0.0, 0.0, 0.0" />
<input name="in7" type="color3" value="0.0, 0.0, 0.0" />
<input name="in8" type="color3" value="0.0, 0.0, 0.0" />
<input name="in9" type="color3" value="0.0, 0.0, 0.0" />
<input name="in10" type="color3" value="0.0, 0.0, 0.0" />
<input name="which" type="float" value="0.0" />
<output name="out" type="color3" defaultinput="in1" />
</nodedef>
Expand All @@ -3920,6 +3930,11 @@
<input name="in3" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in4" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in5" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in6" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in7" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in8" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in9" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in10" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="which" type="float" value="0.0" />
<output name="out" type="color4" defaultinput="in1" />
</nodedef>
Expand All @@ -3929,6 +3944,11 @@
<input name="in3" type="vector2" value="0.0, 0.0" />
<input name="in4" type="vector2" value="0.0, 0.0" />
<input name="in5" type="vector2" value="0.0, 0.0" />
<input name="in6" type="vector2" value="0.0, 0.0" />
<input name="in7" type="vector2" value="0.0, 0.0" />
<input name="in8" type="vector2" value="0.0, 0.0" />
<input name="in9" type="vector2" value="0.0, 0.0" />
<input name="in10" type="vector2" value="0.0, 0.0" />
<input name="which" type="float" value="0.0" />
<output name="out" type="vector2" defaultinput="in1" />
</nodedef>
Expand All @@ -3938,6 +3958,11 @@
<input name="in3" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in4" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in5" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in6" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in7" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in8" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in9" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in10" type="vector3" value="0.0, 0.0, 0.0" />
<input name="which" type="float" value="0.0" />
<output name="out" type="vector3" defaultinput="in1" />
</nodedef>
Expand All @@ -3947,6 +3972,11 @@
<input name="in3" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in4" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in5" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in6" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in7" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in8" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in9" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in10" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="which" type="float" value="0.0" />
<output name="out" type="vector4" defaultinput="in1" />
</nodedef>
Expand All @@ -3956,6 +3986,11 @@
<input name="in3" type="float" value="0.0" />
<input name="in4" type="float" value="0.0" />
<input name="in5" type="float" value="0.0" />
<input name="in6" type="float" value="0.0" />
<input name="in7" type="float" value="0.0" />
<input name="in8" type="float" value="0.0" />
<input name="in9" type="float" value="0.0" />
<input name="in10" type="float" value="0.0" />
<input name="which" type="integer" value="0" />
<output name="out" type="float" defaultinput="in1" />
</nodedef>
Expand All @@ -3965,6 +4000,11 @@
<input name="in3" type="color3" value="0.0, 0.0, 0.0" />
<input name="in4" type="color3" value="0.0, 0.0, 0.0" />
<input name="in5" type="color3" value="0.0, 0.0, 0.0" />
<input name="in6" type="color3" value="0.0, 0.0, 0.0" />
<input name="in7" type="color3" value="0.0, 0.0, 0.0" />
<input name="in8" type="color3" value="0.0, 0.0, 0.0" />
<input name="in9" type="color3" value="0.0, 0.0, 0.0" />
<input name="in10" type="color3" value="0.0, 0.0, 0.0" />
<input name="which" type="integer" value="0" />
<output name="out" type="color3" defaultinput="in1" />
</nodedef>
Expand All @@ -3974,6 +4014,11 @@
<input name="in3" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in4" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in5" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in6" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in7" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in8" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in9" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in10" type="color4" value="0.0, 0.0, 0.0, 0.0" />
<input name="which" type="integer" value="0" />
<output name="out" type="color4" defaultinput="in1" />
</nodedef>
Expand All @@ -3983,6 +4028,11 @@
<input name="in3" type="vector2" value="0.0, 0.0" />
<input name="in4" type="vector2" value="0.0, 0.0" />
<input name="in5" type="vector2" value="0.0, 0.0" />
<input name="in6" type="vector2" value="0.0, 0.0" />
<input name="in7" type="vector2" value="0.0, 0.0" />
<input name="in8" type="vector2" value="0.0, 0.0" />
<input name="in9" type="vector2" value="0.0, 0.0" />
<input name="in10" type="vector2" value="0.0, 0.0" />
<input name="which" type="integer" value="0" />
<output name="out" type="vector2" defaultinput="in1" />
</nodedef>
Expand All @@ -3992,6 +4042,11 @@
<input name="in3" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in4" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in5" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in6" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in7" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in8" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in9" type="vector3" value="0.0, 0.0, 0.0" />
<input name="in10" type="vector3" value="0.0, 0.0, 0.0" />
<input name="which" type="integer" value="0" />
<output name="out" type="vector3" defaultinput="in1" />
</nodedef>
Expand All @@ -4001,6 +4056,11 @@
<input name="in3" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in4" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in5" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in6" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in7" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in8" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in9" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="in10" type="vector4" value="0.0, 0.0, 0.0, 0.0" />
<input name="which" type="integer" value="0" />
<output name="out" type="vector4" defaultinput="in1" />
</nodedef>
Expand Down
22 changes: 22 additions & 0 deletions source/MaterialXCore/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,28 @@ void Document::upgradeVersion()
input2->setName("inx");
}
}
else if (nodeCategory == "switch")
{
// previously we only had 5 inputs, and any value of "which" outside of the valid range of inputs would default to the
// first input. To retain backwards image compatibility we need to revert any value of "which" that is now a valid value
// ie 6,7,8,9,10, to the value of the default, ie. 1.
// NOTE : this won't catch the case if there is something connected upstream in to the 'which' port. Open to suggestions
// on how to handle this.

auto which = node->getInput("which");
if (which && which->hasValue())
{
auto whichValue = which->getValue();
if (whichValue->isA<int>() && whichValue->asA<int>() >= 5)
{
which->setValue(0);
}
else if (whichValue->isA<float>() && whichValue->asA<float>() >= 5)
{
which->setValue(0.0);
}
}
}
}

removeNodeDef("ND_thin_film_bsdf");
Expand Down
Loading