How to Properly use LERP Material Nodes?
Hello all. I apologise in advance for such a basic question, but I have found a problem that has left me stumped. I am trying to understand how materials work, so I thought I would make a very simple expression:
The intent here is to take the horizontal value of the uv, subtract 0.5 from it and take the absolute value, so on a simple UV square, the value will start at 0.5 on the left edge, drop to 0 on the middle and rise back to 0.5 on the right edge.
This value then is fed into the alpha field of lerp with A set to 1 (which should work as white (1,1,1) ) and B set to 0 (which should work as black (0,0,0)). Yet the result is a completely white image. If, however, I invert the parameters order, we get:
At first I thought this might simply be an issue of A needing to be lesser than B, but not only would this seem rather weird, the expression works as intended when I use a simple linear u coordinate as the input.
So, I am pretty much at a loss to figure out what the issue here is. Is there a problem with the math expressions I used to put u's value in range? Am I just not using lerp correctly? My editor version is 4.22.1 and I am doing this on a Basic Code C++ project with starter content, if it makes a difference.
Thanks for reading this question!
asked Apr 30 '19 at 05:12 PM in Rendering
Apply some rubberducking here. On the left edge, you UV.r value is zero. Subtracted 0.5, it becomes -0.5, absolute of which is 0.5. lerp between 1 and 0 on 0.5 is 0.5.
In the middle, you UV.r value is 0.5. Subtracted 0.5, it becomes 0.0, absolute of which is 0.0. lerp between 1 and 0 on 0.0 is 1.0.
On the right edge, you UV.r value is 1. Subtracted 0.5, it becomes 0.5, absolute of which is 0.5. lerp between 1 and 0 on 0.5 is 0.5.
So, everything works as intended.
Follow this question
Once you sign in you will be able to subscribe for any updates here