Download

World Aligned Texture & Linear Gradient

I want to blend a gradient into my texture aligned to Z. Imagine a black & white gradient, if I had a box that was 100m tall, the top is white, blended to black at the bottom. If another box 50m tall was next to it, the top would be 50% grey to the black bottom.

I want to use the WorldAlignedTexture but it only takes texture object inputs and I want to use LinearGradient. I have no idea how to use LinearGradient, I couldn’t find anything in the docs.

If someone else has a better method for achieving this effect thats cool too!

The linear gradient material function is based on the texcoords. You would need to unwrap your meshes in a specific way (using an additional UV channel) to achieve what you are looking for.

As an alternative you can use the worldposition z component to generate a gradient. E.g. calculating the distance between the pixel world position and the object position / pivot point. https://forums.unrealengine.com/showthread.php?31389-Shading-a-material-based-on-height&p=124302#post124302