Using Material Functions with Landscapes

When I say that the “layer sample” needs to match an existing layer on your landscape, that means when you go to the landscape paint mode, you see a layer with the same name, and that it has a layer asset assigned.

In this image, the layer “PAINTABLE_LAYER” will work. The one below called “WONT WORK!!!” will not work since there has been no layer asset created. If you see a + sign, it needs a layer asset.

If you use an already existing name that was previously set up it should still work but still double check.

Ryan, first of all thank you for taking the time to show me the flow. I can see exactly what you were saying now.

Secondly, I hooked it up the exact way it shows and it doesn’t seem to be using the alpha like yours is. I even changed it to the checker node to check it.

Thirdly, (Although its awesome to learn this method since I can see the application for it…) this actually isn’t what I want. This seems to be that you combine two materials into one Landscape Layer, and when it loads up only one Material is shown, then when you paint in spots it merges them together with the alpha. What I want is two Materials to be Lerped together by an Alpha, and that itself is the layer, just like how lerping two textures together work. Once they are lerped, they are combined, no painting involved in mixing them on the Landscape. That make sense?

Again, thank you for helping and for your patience.

It should control 2 layers just fine. Thats exactly what its for. There is a Top and Bottom (Base). You can never paint the Base with this setup. If you want to paint the base, you erase the top. But you only need 1 “paintable” layer to control 2 layers.

I am guessing you used a “Weight Blended Layer”. Try deleting that layer and making a new one with a new name. This time add a layer blend asset but choose “non weight blended”. All weight blended layers do is try to normalize the layers automatically. So if you have 2 layers, the 2nd layer is always going to equal the inverse of the first layer (aka, 1-x). It makes it so painting a bottom layer has the same effect as erasing the top layer.

it is possible to use weight blended layers using functions like this but it is more trouble than it is worth. Non-weight blended layers make more sense anyways since it implies a physical relationship between layers. Weight blended layers IMO are buggy and just cause problems like above (its probably confused that it has nothing to normalize with or something) so I suggest avoiding them.

Ie, for a standard terrain Rock is the base. Then you have to erase the other layers to “expose” the rock rather than painting the rock. So a terrain with rock grass and snow really only need 2 paintable layers, the grass and snow. Rock simply shows anywhere the others don’t. And in that case you want snow to be top layer since that makes more physical sense.

Well I changed it to a Non Weight Blend layer and its still the same.

But again, this is not the effect I am looking for. So should I assume there is not way to just lerp the two materials together like explained before?

Try getting rid of the heightlerp for now and just hook the layer blend up directly. Thats your ‘Grass_layer_5’ node above. The checker pattern isn’t really a good pattern for this and only showed up in my test because I used a lot of tiling so it repeated alot. You probably have one checker covering the whole landscape at those scales. Or make another landscapecoords with scaling at 1.

>>So should I assume there is not way to just lerp the two materials together like explained before?

I don’t know why you would assume that. The above setup IS lerping two materials together. Whether you use a single “non weight blended” layer or two weight blended layers really does not matter. It’s mere a difference in how the data is stored.

If you really want to use weight blended with layers, there is a material function to help with that coming in 4.8, and one other function you need to make.

First one is just a MatLayerBlend that does a multiply on all of the Attributes and then re-makes them. Looks like this:

The second is one that Adds them together. It looks exactly the same except each multiply gets replaced with an add. Call it “MatLayerBlend_Add”

What you would do with it is multiply each Layer Function by a “Layer Sample” node that matches it. Then you just add together all the multiplied layers using the add function. That is all the internal weight blending does. It multiplies each layer by its own alpha and then adds the resulting multiplied layers. In fact that is how a regular lerp works under the hood too.

Here is what that blending setup looks like. This is just another way of lerping material functions using weight blended. I vastly prefer the non-weight blended version shown above since it is much harder to get height blending to do fancy things with this:

Of course someday soon the layerblend nodes may work with material attributes.

Hi RyanB, Is there any chance you could upload the example you have used above? I can’t for the life of me find “MatLayerBlend_Add” for some reason… I’m really struggling to paint 2 material functions on a landscape…

chrisedhog, You need to first add a Material Function Call, then point it an actual function.

My god, thanks to this thread I can finally create landscape materials the way I always wanted to, I just didn’t know how. The height lerp part along with “don’t use weight blended layers” was really helpful.
Would be nice if it worked with weight blended layers tho.

Yep I just don’t get it after all.

I simply wanted to blend couple grass, stone and sand textures in one material without having to add 4 maps and 4 blend nodes. But the whole material functions and blends just ****ed me up @ _@
Could someone just give me a simple example of the final material where it blends multiple (more than 2 because apparently the material blend only blends 2?) material functions into one material which could then be used with the landscape tools? I’m not really using any custom UV’s or masks I just figured that since I had materials with roughness and normal maps (and AO but they seem to not do anything anyways…) it would be nice to have the materials represented as just nodes in the graph but then I found out materials can’t even be brought into mats as is and then I found out about material functions and then I tried that but those don’t work with the landscape blend layers and then I found this thread but I have no clue what half of the stuff they are doing is and i can’t find any explanation for what the Landscape sample node does (not even on UE4 documentation) so I’m pretty much ****ed. : | it’s for school assignment so I’m just going to go home and toss all the bloody texture maps into one huge blend mess but for future reference I’d like to find out how to do it smartly. : |

Guys I did not know there was such a good method!

I tried the weight blended version but the second layer returns a null output. The areas I paint with this layer turns the landscape into black and white checker patterns.
Any help??

if you cant use it with the landscape editor layers toools, then what’s the point?

Wow, thank you guys for all the examples in this. I hope im not reviving some dead thread, but this really contains a wealth of knowledge.

I would like to know if this is possible as well. I had hoped this would be useful, but it’s not useful when creating landscapes with many, many different materials applied.