# How to Properly use LERP Material Nodes?

**URL:** <https://forums.unrealengine.com/t/how-to-properly-use-lerp-material-nodes/448121>\
**Category:** Rendering\
**Tags:** basics, lerp, unreal-engine, question\
**Created:** [April 30, 2019, 5:12pm UTC](https://forums.unrealengine.com/t/how-to-properly-use-lerp-material-nodes/448121 "2019-04-30T17:12:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_AB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alex\_AB](https://forums.unrealengine.com/u/Alex_AB)\
**Post date:** [April 30, 2019, 5:12pm UTC](https://forums.unrealengine.com/t/how-to-properly-use-lerp-material-nodes/448121/1 "2019-04-30T17:12:51Z")

</div>

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:

 ![275584-bad-lerp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/0/4/504b23097d7b729e21c573e0801f25694f21a2a5.png)

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:

 ![275585-good-lerp.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/4/d/34d7edc855422c498f39ce50ac9ecb90ed4198f7.jpeg)

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.

 ![275586-simple-lerp.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/5/8/758f4f05f725b38902cd89ae74203a88dfa29f99.jpeg)

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!

---

<div class="post-metadata">

**Author:** ![Deathrey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deathrey](https://forums.unrealengine.com/u/Deathrey)\
**Post date:** [April 30, 2019, 6:37pm UTC](https://forums.unrealengine.com/t/how-to-properly-use-lerp-material-nodes/448121/2 "2019-04-30T18:37:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Alex\_AB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alex\_AB](https://forums.unrealengine.com/u/Alex_AB)\
**Post date:** [April 30, 2019, 7:26pm UTC](https://forums.unrealengine.com/t/how-to-properly-use-lerp-material-nodes/448121/3 "2019-04-30T19:26:51Z")

</div>

Thank you very much! The answer was rather simple and yet I spent so many hours trying to get it…
