By popular request Im doing a quick breakdown of the landscape material that we showed in our last post!
If there are any questions or if you would like an even more indepth look at it in form of a video tutorial or something let me know in the comments 🙂
This is the material we are talking about:
It has distance based tessellation, height blending between the textures and procedural puddles that you can paint on top.
Lets start with a look at the complete material:
And its settings:
Its not using a mask since we dont need holes but it should not be a problem to add that to your version.
And this is what an instance looks like with all of the settings that are exposed to the artist:
The interesting part here are ofc the puddles.
So lets break down the Material, starting with the UVs:
Nothing too crazy here, just a world position and a multiply to control the tiling. This means the texture will stretch on steep angles, not important for us since we wont be using it there but you might want to change this if you plan on using it for rocks and stuff.
Next up is one of the material layers:
We put our materials into functions to keep the graph from getting messy and just expose the relevant settings as parameters. Were also feeding it the world position uvs.
Detail shot of the function:
Pretty simple and regular setup with a few inputs for the parameters. We have the roughness, height and ao stored in one texture to save memory. Since the material attributes do funny things to the scalar value of the heightmap and were going to use that to mask stuff I created a separate output for that.
Important: If your using a lot of textures or layers you need to set the texture Sampler Source to Shared:Wrap.
We then use a regular Landscape Layer Blend node to blend the layers:
The important part here is having an unused alpha blend layer as well as having one layer that is going to cover the whole landscape as weight blended. We use this to get rid of problems with black spots on the landscape as well as it not compiling properly and showing the grey worldmaterial when more then 3 layers are used with tessellation.
We also use the separate heightmap output for the height input on the blend node.
Since we arent using the material attributes for the height information we need to blend that separately:
Here we sample the layers mask information and use that to lerp between the different heightmaps.
Once the materials are blended we add the puddles ontop:
This layer has a lot of parameters that arent really necessary, I was experimenting with my procedural setup which is why I have so many 😀
We input the blended Material as well as the blended heightmap and the layer information for the landscape “puddles” layer that we sample here into this function.
This is screenshot of the puddles function:
Its still really messy as I havent found the time to clean it up yet. Its basically a custom blend, using the heightmap to blend between the terrain material and constants as well as a 3-vector for the puddle values. The cool stuff is in some features like normal blending and wetness on the edges, color and opacity for depth or dirty puddles and a option that allows us to shift the height of the puddle from nothing to covering the whole area. All of this is then masked by the puddle landscape layer information.
You can take a look at some other puddle tutorials to get similar results, most of them use vertex color to blend in the puddles, just use the layer information instead.
Edit: Added detail shots of this graph for anyone interested in what exactly it does.
Final step is the tessellation:
Here we use the heightmap information to get our worlddisplacement for the landscape material (upper right).
Our tessellation setup is dependent on the camera location and has the vector length in there since unreal likes to tessellate the whole object otherwise (which we obviously dont want) We have some extra parameters to control the fade distance, offset and tessellation resolution.
We use a material parameter control to input our overall tessellation strength since we want to be able to control the effect via the users option menu (on all our materials at once).
And there you have it!
Keep in mind that this is a pretty expensive material and we only use it on the highest settings, its probably not something you should use on very big terrains and fewer layers is always better for performance.
Let me know if this was of any help or if you have any questions in the comments!