How to Use Layered Lit to Mix Texture Maps in Unity
Objective: To understand what Layered Lit is in Unity and how to use it to mix Texture Maps.
What is Layered Lit?
This is a feature in High Definition Render Pipeline (HDRP) that allows you to stack materials on top of one another on the same game object. This is a really cool feature where if you wanted to combine a couple materials say sand and water or dirt and grass or even dirt and sand as examples, then instead of going into your software program to create this, you can check this feature out and see if you get the desired result!
How to Get Layered Lit Setup?
To get started create a new material in your Project window and call it ‘Dual’. From here we need to set the Shader to be HDRP/LayeredLit:
You will now notice that your material has been given a ‘Layer Count’ under the ‘Surface Options’ in the Inspector. Layered lit can have up to 4 different materials. When you change this to 3 or 4, you will notice below in ‘Layer List’ that it is automatically creating new material fields for your layers where you are able to drag and drop them into:
We can now drag and drop our 2 materials into these fields and also drag the ‘Dual’ material onto a 3D plane we have created in our scene:
You will notice that only the dirt layer is showing at this stage and this is because the Main Layer is the under most layer out of the 4, the next one being Layer 1, Layer 2, Layer 3. So because the dirt is on Layer 1 it is the one that is visible at the moment.
Next, we need to have a ‘Layer Mask’ to get these layers mixing an mingling. Let’s drag in a texture to this field box:
Lastly, I am going to replace the ‘Dirt’ material with a ‘Grass’ material and I am going to make sure it stays as Layer 1 as I want this to be the one on top of the stones. I have then adjusted the base map colour slightly and played around with some tiling for the grass and stones and this is the final product:
What a cool way to come up with new materials!