Possible to Smooth World Position in Materials?

Hey everyone!

So I currently have a material that I want to be applied in a linear gradient relative to the object’s world position. I’ve managed to get a linear gradient on the Z-axis using a Mask - the two colours (negative and positive) blend at the zero point (with an added offset). The problem is that the gradient is pretty hard and it’s a really quick change from one colour to the other even if I divide the world position by a constant and I’d ideally like to smooth it out over a greater distance. Any ideas how I might be able to do this?

Thanks!

Actually, I just realized if I use the world position from 0+, divide it and use it as an input to a lerp between two colours, that might work.

You don’t have to use the zero position, btw. You can do an inverse lerp. This isn’t built into UE4 unfortunately, but you can do it yourself with a math node. The equation is (val - min)/(max-min) where val is the current position and min and max are self-explanatory :slight_smile:

This will return a value between 0 and 1 that you can pass into the lerp function.

Wow…Wish my brain understood that LOL!!!