What are LayerMaterials
The four LayerMaterial types - SurfaceMaterial, MaskMaterial, OverlayMaterial and DataMaterial - and what each is for.
LayerMaterials are materials that are used in LayerGraphs. A LayerMaterial can be a SurfaceMaterial, MaskMaterial, OverlayMaterial or DataMaterial. See What is a LayerGraph for how they're used.
LayerMaterials need matching LayerShaders to work. So a SurfaceMaterial must use a SurfaceShader, MaskMaterial uses a MaskShader and so on. See What are LayerShaders.
There are 4 types of LayerMaterials, each with their own purpose.
SurfaceMaterial: Acts as a base material. Only outputs its material
properties. Does not have access to material properties from layers below.
Can read the data variables of DataMaterials below it. E.g. a rock
material. See What is a SurfaceShader.
MaskMaterial: Blends a SurfaceMaterial with layers below. The Blend
input takes in a SurfaceMaterial, Base takes in the existing layer
chain. The blending logic is controlled in the MaskShader, completely up
to the author. E.g. height blending with vertex color mask. See What is a
MaskShader.
OverlayMaterial: A combination of SurfaceMaterial and MaskMaterial. Handles its own blending with the previous layers, does not require a separate MaskMaterial. E.g. a moss or snow overlay. See What is an OverlayShader.
DataMaterial: Passes up to 16 vec4 and 16 float values up the chain. Does not have access to any material properties. Useful for injecting data once for the whole chain, instead of once per layer. E.g. a texture sampler data material that samples a texture once at the bottom of the chain, the layers above it can read it instead of having to sample it every time. See What is a DataShader.
LayerMaterials come with LayerShader templates. So you can start writing LayerShaders without needing to set anything up. See Writing SurfaceShaders for a practical example.