Extending the Complex Material Sample

It can be difficult to work with the Complex Material sample, but it is designed to be used and customized as template.

This article assumes moderate knowledge about Unreal Engine's material editor and Material Definitions. We also recommend exploring the BasicMaterial sample first.

Some changes - for example, adding support for another material property like roughness - are relatively straight-forward. Others, such as customizing triplanar projection blends, can get very complicated. As such, this article is split into the following two sections:

  • 1.) Step-by-step guides on some straight-forward extensions to the material, i.e. adding support for additional texture channels (roughness, AO, etc.)

  • 2.) Deep explanation of the material design, providing the perspective needed to make more complex changes.

The Complex Material sample does not currently fully support planetary rendering, as the top and sides textures will behave as if the world is flat.

1. Straight-Forward Changes

1.1 Supporting additional material properties

For the purposes of this guide, support for roughness textures will be added to the material. To get started, open VMD_ComplexMaterial, MF_CompleteLayer and MF_FinalOutput.

First off, within the VMD_ComplexMaterial asset, duplicate the Diffuse - Top and Diffuse - Sides parameters by pressing Ctrl-D. Rename the two to Roughness, and change their default textures as needed. Save the VMD asset.

These are the only changes necessary on this side, so the VMD asset can now be closed.

From here, move to MF_CompleteLayer. This function contains a handful of different comment blocks. Zoom in on, and then copy the Color comment block on the left-hand side. Paste it in the empty space to the side.

Select the Voxel Parameter nodes, and in the details panel, select the top and side Roughness texture parameters from the VMD. Delete the Static Bool plugged into the UseModifier pin. Drag out from the Result pin and create a local variable declaration called RoughnessOut.

Lastly, for the sake of organization, rename the comment block to Roughness.

While the core logic is now in place, the data from it still needs to actually be fed into the Material Function's output.

To do this, shift the view to the Output Result node on the right-hand side, and select the SetMaterialAttributes node. Click the plus in the details panel, and change the last entry in the list to Roughness using the selector. Drag out from the newly created pin, and connect a Get RoughnessOut (our previously created named reroute) to it. Click the Apply and Save buttons to make sure the changes are applied.

The roughness information will now be fed through the entire material, and be blended per layer. All that is left is to make sure it's properly assigned before the final output. Close MF_CompleteLayer, and move to MF_FinalOutput instead.

Within MF_FinalOutput, add a roughness pin to the GetMaterialAttributes node, and connect it to the existing roughness pin on the SetMaterialAttributes node. The nodes that are now disconnected can be deleted. Once again, click the Apply and Save buttons to make sure the changes to this function are applied.

With these steps completed, the terrain should now be using the default roughness textures. Textures can be selected per-layer inside the .

1.1.1 Supporting channel-packed textures

In the case of channel-packing, the entire workflow is largely identical, except that the MF_CombinedProjection output should be split into its respective channels.

There is one exception to this when trying to channel-pack additional texture into the Height texture. In this case, the Result pin will only output the height channel (selected through the parameters list).

Instead, use to access the channel-packed result.

Do make sure to connect the individual texture channels to appropriate material properties, both at the output node in MF_CompleteLayer, as well as in the MF_FinalOutput configuration.

1.2 Increase texture size on distant terrain

This section is still to be written.

2. Explanations for Complex Changes

The Complex Material sample is built out of a handful of separate Material Functions.

  • Three MF_CompleteLayer functions, each of which contains the logic for one the three layers processed per-pixel.

  • An MF_ThreeLayerBlend function, which run a height-blend between the three layers.

  • An MF_FinalOutput function, which takes the MaterialAttributes from the blended layers and routes them into a second, cleanly configured, MaterialAttributes pin. This is to avoid unnecessary values being computed.

This section is still to be finished.

Last updated