Creating Layered Materials (Tutorial) - Epic Wiki

Epic Games on Material Layers in Gears of War 4


https://youtu.be/bCN2LRfBueI

Layered materials are actually just material functions blended with other material functions, and by doing that (combining them) you create a new material.

You don’t need to set up different material ids (you can, but its not necessary for the material layers to work).

  1. Create a new material function (its important that its a material funcion, not just material, otherwise it won’t let you use the material as a node). Then, inside the material function, add a “MakeMaterialAttributes” node, connect it to the output result and then you can start creating your material layer.
  2. Once you’ve got your layers, you’ll need a mask to blend the materials. This will be a RGB or RGBA texture which contains a black and white mask in every channel for each material, to determine where it’s going to “appear” that material. You’ll need one mask less than materials (if you have 4 materials, 3 masks will be needed - I will explain why in the next points)
  3. Now create a regular material and go to the material details tab and check “Use Material Attributes” - that will get rid of the BaseColor, Normal, Roughness, etc. nodes and allow you to use the layered materials.
  4. Once you’ve got all set up, drag your material functions (material layers) into this new material and the mask texture. Create a new “MatLayerBlend_Standard” node and use the “main material layer” as base material (this material is going to be present on all the mesh), add another layer to the top material and the mask for that second layer on the alpha slot. This masking step puts another material on top of the previos one, but only reveals the top material where the pixels are white on the mask.
  5. Once you have all your layers blended, to add the normalmap of the whole mesh just use a “MatLayerBlend_BakedNormal” node, and if you want to add an global ao aswell, use “MatLayerBlend_AO”.
  6. Finally, connect the last node (usually the ao or normal blend node) to the node where it says “Material Attributes” and you should have you layered material ready.

Be careful when connecting the texture to the ao slot because it asks you for an (S) value (which I believe means scalar), not a (V3) (which I also believe means vector3). Because of that, you should only connect one channel,(for example the red channel, doesn’t matter really since they’re all the same in a grayscale ao texture), not the whole ao texture(rgb).Or you could pack the ao in the alhpa channel of another texture, like the normalmap, to save memory and optimize the shader. Also, be careful with how many textures you have. If you’te going to use a texture across different material layers, use FunctionInput nodes (scalar for one channel, vector3 for rgb texture) and then use it from the main material, not the layers. Otherwise, if you use the same texture sampler inside many layers, it quickly piles up and if you reach more than 15 texture samplers, the engine will give you an error when trying to compile.