Using LayeredLit shader to mix texture maps in Unity 2020
Tell me about the LayeredLit shader in HDRP
Ever see one terrain type blend into another terrain type in a videogame?
No?! You need to stay in more…
Anyways, Mr or Ms “I have a life”, when you want your grass to fade into your gravel (or your dirt into your stone in our case), HDRP’s LayeredLit shader is what you want to use!
Layered Lit Shader
The Layered Lit Shader allows you to stack up to four Materials on the same GameObject in the High Definition Render…
“The Layered Lit Shader allows you to stack up to four Materials on the same GameObject in the High Definition Render Pipeline (HDRP).
The Materials that it uses for each layer are HDRP Lit Materials.
This makes it easy to create realistic and diverse Materials in HDRP.
The Main Layer is the undermost layer and can influence upper layers with albedo, normals, and height.
HDRP renders Layer 1, Layer 2, and Layer 3 in that order on top of the Main Layer.
The Layered Lit Shader is perfect for photogrammetry.”
The first thing we’ll do is create a new material and call it LayeredLitMaterial” because I’m original like that.
Make sure to change the shader from HDRP/Lit to HDRP/LayeredLit.
Next, we want to assign the materials we wish to blend to our new LayeredLitMaterial.
Make sure you have upgraded the relevant materials to the HDRP pipeline before doing so.
Next, we’ll need something to apply our material to.
Create a plane game object.
Apply the LayeredLitMaterial to the plane game object.
Hey, smart guy, all I see is dirt…
Yea, we still have more work to do.
We need a layer mask, and since I’m too lazy to whip one up, I’ll just use a texture mask that is already in my project.
I chose this DirtyAlbedo map for my scifi tanks because it had some interesting shapes and I knew the pattern of it would stand out on a square plane.
I’ve also switched my materials on the LayeredLitMaterial.
Since the main layer will be blended on top of the next layer, this gives a better effect of stones that have been covered by dirt over time.
With the mask in place and the materials reversed, this is the effect we get.
As you can see it applies the darkness of the mask as well.
You would think that’d mean black parts of the mask are darkest, but looking at it, I’d see the black areas were given the sand treatment, the white areas the stone treatment, and green just confused the shader.
I believe these masks would normally be just black and white or at least greyscale, but hey, now you know what happens when you break that rule!
I’d say that the green channel in your texture mask could potentially be used to darken areas that are supposed to be wet, just a thought.