How do I set up landscape WorldAligned Material to handle cliffs?

Hey guys,

I’m currently working on a landscape material that blends by distance from player, then blends by surface angle. I’m using tiled procedural textures and trying to pull it off without any global/baked textures.

However, at this point I think I’m not entirely grasping how the WorldAligned node works in the material editor. I’ve read all the associated documentation provided by Epic, and I thought I understood it all, but I’m still not getting my desired response. I ran into this problem before setting up a distance blend, so my issue shouldn’t have anything to do with my distance blend logic.

I’m looking for sharp and complete blends based on angle. For example, a cliff that has a plateau on the top, the plateau should be entirely grass, and when it runs to that 90 degree drop (the cliff edge), it should be entirely cliff when the landscape faces are vertical. Here’s an example of what I’m trying to describe.

Here’s my current material setup: http://i.imgur.com/4Ly0yRR.jpg (I did some no-so-clever Photoshop editing to get it all on one image)

I apologize for the mess in that material - my distance blend functions (and my desire to tweak EVERYTHING via parameters) makes it look a lot more complicated than it is. I’m doing essentially the same thing as shown in the last post here: Best method for creating a cave in a landscape - World Creation - Epic Developer Community Forums

I’ve tweaked Bias and Sharpness about 1000 times to test as many combinations as possible, which is why I’m asking for outside advice because I think there’s something else I’m doing wrong.

Here are my results, in a nutshell:

Sharpness always at 4 to keep the blend relatively sharp.

Bias at 0 - Pure grass, no rock (angle doesn’t matter)

Bias at -1 - A blend between Rock and grass (the blend seems to be uniform and almost entirely ignores the angle)

Bias at -2 - Pure rock, no grass (angle doesn’t matter)

Any advice would be greatly appreicated!

P.S. - for the sake of testing, I also tried sculpting the terrain with 0 falloff so that the angles would be 90 degrees (and really no room for misunderstandings as to what textures should show up where), and it looks the exact same as my above images.

The best way I found to blend world aligned textures like is to :

-Create a Constant 3 Vector, with the direction vector of the blending (like 0,0,1 for up/down)

-Perform vector transformation (tangent to world)

-Perform an Abs (absolute) over the result (this way you get up and down, otherwise just use a clamp)

-Plug the result of this chain of nodes in the Alpha of one of your Lerp.

You can even apply a power over the abs() result to sharpen/contrast the blending value. This way, perfectly horizontal faces will get 100% of the grass texture. This method will be much cheaper than you “bias” method by the way.

So for clarification, is this meant to replace the WorldAligned node or should it go before or after? Sounds like you’re replacing the functionality, but I’m not sure.

Oh also, what power works for you? I tried a few numbers but they all turned out incomprehensible.

Yes, this is meant to replace your worldaligned node used in the “alpha” input of your lerp nodes. Apologies for my explanation above, I forgot a node (ComponentMask) after the tangent to world transformation. Here is my setup :

The Lerp node blend between two values (A and B), the more close to 1 your Alpha value is, the more you will see of the value B. Therefore applying a power of 2 (for example) on your alpha will contrast it (it’s a power function, meaning input_value ^ power_value, so a power of two equals input_value * input_value). More details in the documentation : Math Material Expressions in Unreal Engine | Unreal Engine 5.1 Documentation

You can also try your Lerp in the other direction, inverting A and B and user an other vector direction to use the power at your advantage.

Some examples of my setup above :

6229-cube_mesh.jpg