In your example, it works for the given input, that is a value 0.2
produces 1
output: value is both greater than 0.1
and lesser than 0.3
, both condition nodes outputs sum up to 2
which is clamped into the 0...1
range, so becomes 1
.
However let's see what happens if your value is below the 0.1...0.3
range: it passes only one condition, but since summing 0
and 1
results in 1
, which is the same result as in previous case due to clamping in that previous case.
So Math > Add is an equivalent to Logical OR: if either of operands is True, the result is True. You need something different, Logical AND: if both of operands are True (both less than .3 and more than .1) the result is True, otherwise it's not True (False). In order to do that, replace your Math > Add with Math > Multiply - now if either of the comparison nodes will result with 0
, the other result will be multiplied by 0
, resulting, of course, with 0
. So the only way to get 1
will be to have a value both lesser than .3
and greater than .1
!
There's a simpler way, however, Math > Compare will result in 1
if you're not more than Epsilon away from Value (otherwise 0
)
In general to output 1
if input is in range a...b
, set the Math > Compare this way:
- Epsilon = (b-a)/2
- Value = a + Epsilon
so for range 0.1 ... 0.3
:
- Epsilon = (0.3-0.1) / 2 = 0.2 / 2 = 0.1
- Value = 0.1 + 0.1 = 0.2
In simpler terms set the the Value to the middle of the range, and Epsilon to half of the range.