Pages in Tutorials
1: 3D Model
Part 4: Material With Functions
A tutorial about how to use functions to create a layered material.
Example Modern SideboardThis is the example sideboard used for the tutorial about creating an optimised model.
The MaterialCreate a new material and tick Use Material Attributes in the Details Panel. This will allow the use of functions and layered materials.
Blend NodeThis is where the Mask and Normal textures go in as well as the material layers. The Blend node itself connects to the Material Attributes node.
Overlay Normals and AOFollow the 'baking' tutorial to see how to create these 2 textures.
The overlay AO is stored in the green channel of the Mask.
Material LayersUp to 3 material functions can be plugged in here.
- Layer 1 (no mask, default)
- Layer 2 (Red channel)
- Layer 3 (Blue channel, preferable metallic)
This node is a custom function. By default all layers are active and need a function plugged in. You can turn layers on and off with static bool parameters.
You can also disable the overlay AO and Normals in cases you only need to use the masking of multiple materials. By default AO and Normals are on.
When using a mirror activating the UseMirror feature will remove the Normal map from the blue masked layer to have a flat surface.
The function has another Blend Node for blending the overlay with the material details. Below image shows the node setup.
Overlay Blend NodeMF_OverlayBlend
This function blends the overlay normals and AO with the detail normals and AO of all the material layers.
The node setup is shown in the below image.
Material LayerThe function MF_GlossyWhite is displayed below as an example material function.
Parameters will be passed through all functions if the name of the parameter and the name of the input are identical. Also put all parameters in a group that identifies the material layer clearly. It works very much like a normal material.
I noticed that you actually won't need the input nodes. It works fine with just the parameters.
Material InstanceCreating a material instance will expose all variables from the material functions used.
That's why it is important to use groups and exactly matching names for input and parameters. Any mistakes will show up in the instance as a missing parameter, having the wrong category or any changes won't have an effect. If that happens check the naming.
Setting up a function is a bit more work than setting up a normal material. But once you have the function reusing it is just a matter of seconds.
Unreal has another feature called "Layered Materials". It was put on hold previously so I do not know how reliable it is. It would work pretty much the same way but without having to create functions. The Mask can be used to create the layer blends.