We’re excited to announce that we’ve added support for Material Layers in Unreal Engine 4.19 as an experimental feature. Below is some basic documentation to get you started using the feature. Also, if you have any feedback regarding the use of Material Layering, please feel free to [post in feedback thread on our forums][1] or leave feedback and post questions here.
Thank you!
To enable this feature, navigate to the Editor Preferences > General > Experimental > Materials and set Material Layering Enabled to true.
Material Layering is a new way to combine materials in a stack, which builds out the correct material graph without needing to build the node graph by hand. There are two new asset types that we use to do this:
- Material Layer
- Material Layer Blends
Functionally, these behave similarly to Material Functions. These new asset types also enable you to create child instances, which you could not do with Material Functions.
Material Layer assets have a default input node which pipes base Material Attributes in from the Material. Material Layer Blend assets have two default input nodes which enable you to access the Material Attributes from layers above and below.
Once you have created a Material Layer and Material Layer Blend asset, you can combine them using a Material Attributes Layers node in a Material. With the node selected, you can add layers and set the assets that each layer and blend should from the node Details panel.
When editing a Material Instance with a parent Material that contains a Material Attribute Layers node, the Material Instance Editor also contains a Layer Parameters tab. Here, you can change the assets used for any of the existing Layers or Blends that have been set. Use the Add (+) button to add additional Layers to the stack as needed. You can also see the parameters contained in each of the Material Layer and Material Layer Blends and override their values individually by entering a new one.
**
Passing Parameters to Layers
**
There are three main methods at present to do this, most of which apply to Blends and Layers.
- Create a parameter within the layer which behaves similarly to existing Materials and Material Functions. Parameters added within the layer graphs will be unique to that layer and editable within the layer’s section. Even if multiple copies of the same layer are added, each will have its own copy of that parameter to control.
-
Use the Input pin to the Material Attribute Layers stack:
This takes another Material Attributes as input which will be piped into every layer added. For example, we could pass a base normal map for the mesh as an input, like so:
Then within our example Material Layer, we get the Input and blend in:
Each layer can optionally use or ignore the base stack material attributes input. Currently, this method is not accessible within a blend graph.
3. Using Shared Input Connections (New Feature):
These function very similarly to Material Parameter Collections though rather than setting the data in a Global Blueprint, they are used for connecting data between Material Graphs. You will create the asset using the same method by making the asset and filling in the list of available parameters, their names, and types:
The parameters listed will be available for use within your Material Graphs. There are two parts to using the system. The first is setting the shared inputs, which should generally be done at the top-level Material Graph. Continuing with the example collection, the inputs are hooked up to parameters in this case but could be any material graph nodes:
As the parameters here are connected from the main Material Graph, they will be listed in the Material’s Global Parameters list when editing a Material Instance. In this respect, the parameters will be shared between any other graphs that read from them.
The next step is to get the shared input parameters, which can be done within a Material Graph, Layer Graph, or others. All instances of a Get Shared Input node will read the same shader input data, in this case, our global parameters. The following reads the shared data within a layer graph on the stack:
This enables a system where parameters and graph inputs can be shared between layers, however, when editing an isolated instance, we don’t have access to the Material where the shared input is set. This behaves similarly to Material Function inputs and a preview value can be provided in the same way:
The preview values will be used based on the parameter type that is set in the collection, so only the relevant data needs to be filled in. The preview value will be used when generating the layer preview, asset thumbnail, and any other case where the layer must be compiled in isolation.
Of note, the Get Shared Input node in the graph above lists as a Texture2D input. This type is set if the parameter is found but will list an unknown type error if the parameter no longer exists. There is no system in place at this time to automatically rename parameters for you. In a future release, this may be implemented or the Name entry box replaced with a drop-down list of available parameters.