Terrain shader keywords/naming conventions

Lately I’m trying to learn how to make shaders and currently I’m messing around with custom terrain shaders and I’m trying to access the values in the terrain layers.

I understand that there’s hardcoded names you’re supposed to use to access the terrain layers, but how am I supposed to know the keywords to access the terrain layer’s textures and sliders?

I’ve been looking around the internet and searching the built in shaders and so far I found how to use the diffuse, normal, metallic and smoothness value.

So I think that:
Diffuse is sampler2D _Control; or sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
I’m not sure.

Normal is sampler2D _Normal0, _Normal1, _Normal2, _Normal3;
Metallic is half _Metallic0, _Metallic1, _Metallic2, _Metallic3;
Smoothness is half _Smoothness0, _Smoothness1, _Smoothness2, _Smoothness3;

But what about the specular and the new mask slot in 2018.3+?

Why aren’t they listed anywhere on the unity websites or am I supposed to find them somewhere else?
How are you supposed to know what hardcoded naming you’re supposed to use if you can’t see them anywhere?

I find this very odd

I’m also looking for the Specular slot, is there any documentation or source that I can reference?

I don’t have an answer, but what might help is the fact that Unity has the tendency to refer to Specular as “Shininess” in their code. Hope that, that might help!

You can look at the builtin terrain shaders, but the mask slot is simply sampler2D _Mask0, _Mask1, _Mask2, _Mask3.

Shininess was used before Unity 5 when they switched to PBR, and adopted smoothness instead. Smoothness is of course _Smoothness0, _Smoothness1, etc. But you don’t really want a hardcoded smoothness per terrain channel. You should embed a Smoothness map in the alpha channel of the albedo texture.

I don’t think Specular Color has ever been used in any builtin terrain shaders. If you’re using PBR, you shouldn’t really be using this. Everything non-metallic should have a specular of 0.04, and metallic uses the albedo as the specular color. (And black for albedo, as metal has no albedo) This is all handled automatically if you use surface shaders, and write to the Albedo and Metallic outputs.

Unity don’t document a lot of their shader details, especially the terrain, so you basically have to reverse engineer everything from the shader source.