Hi, I’m currently creating a material, where in the material instance, you can switch between 3 states.
Since as far as I know, there is no way to add an integer value as an input parameter in a material (right?), these three states would be controlled with a scalar parameter.
I can think of a few ways how to achieve this, but I would like to make use of the static switch nodes, to make my material more light weight.
However, since I have 3 states and not 2, using two static switch parameters, that rely on each other, wouldn’t be pretty. So I want to use two static switch (not parameter) nodes, and control them with a scalar parameter.
But since they only take booleans as an input, I somehow need to convert my scalar parameter value to a boolean. Let’s say 0-0,5 becomes false, and 0,5-1 becomes true.
Is there any way to do that?
To add some clarification: Only 1 of 3 states is needed at the same time, and it doesn’t need to be changed at runtime. So disabling the others, so that 2/3 of the shader are not even compiled in the first place, is actually what I want. That’s also the reason why I would prefer not to use the (non-static) switch node, if nodes, lerp nodes, etc. with which I would know how to do this, but static switches.
Thanks for the reply. Yes, the static switch behind another static switch is what I’m planning to do “behind the scenes”, but don’t want it to be displayed like this (with 2 checkboxes) in the material instance.
So instead of the checkboxes, I would like to display this as a slider, where value 0 = False for the first switch, value 1 = True for the first switch but False for the second, and value 2 = True for the first switch and True for the second.
That’s why I’m wondering if it is possible to convert these values to bools.
While there is no perfect solution to this, you do have a few other options available to you rather than just two static switches. You could use a component mask parameter or a channel mask parameter. Both offer up to 4 switches. The component mask parameter allows for the selecting of several checkboxes, while the channel mask offers a dropdown.
The main downside here is that you can not give the individual options names. The channel mask is searchable in the material editor, while for the component mask you must add a component mask, right click, and convert it to a parameter.