Mutable for Unreal Engine | Material Variations
Overview
This article explains how to trigger the activation of a mesh variation when a certain object is enabled by setting up a tag in its Material node and using it as well in a Material Variation node. In this case, the mesh switch is between the original hair of a character and a variation of it that fits properly when wearing a handkerchief.
Hair’s mesh variation when a handkerchief is on
Assets required
- One material asset or material instance of the character without parameters (textures included)
- One skeletal mesh of the character with the previous material applied (one material, no parameters)
- One hair mesh
- A head’s handkerchief
- A variation of the previous hair mesh adapted to the handkerchief
Steps
- The first step is to create a basic Customizable Object asset with the Base Object, the Material and the Skeletal Mesh.
In this example, the Customizable Object asset is named "Material Variations", the Reference Skeletal is "MaterialVariations_BaseBody", the Material is called “MaterialVariations_M” and the Skeletal Mesh is the same as the Reference Skeletal’s one.
- To begin with, the default hair mesh has to be added to the character. To do so, create a Child Object node and connect it to the “Children” connection of the Base Object node.
- In the Node Properties name this first object.
In this case, the child object’s name is "Hair".
- From the “LOD 0” connection of the Child Object node create a Material node for this “hair” object.
With this last node selected go to the Node Properties tab and set the hair’s material.
In this example, the material selected is “MaterialVariations_Hair_M”.
- Create a Skeletal Mesh node to add the hair’s mesh. In the Node Properties tab, select the default hair’s mesh from the Skeletal Mesh sub-tab drop-down menu.
In this case, the “MaterialVartiations_Hair” is chosen.
Afterward, link both “Mesh” connections of the Skeletal Mesh and the Material nodes.
- Now, the hair is created as a constant resulting object, but in the case of the handkerchief, it is more effective to have the option to enable and disable it to see how the switch between the two hair’s meshes works.
Create a Group node from the “Children” connection of the Base Object node to add the “handkerchief” object.
In the Node Properties tab, write a name for this group and choose the group type preferred.
In this example, the group’s name is “Handkerchief” and the type is “Toggle”.
- Now, create a Child Object node and link its “Object” connection to the “Objects” one of the Group node created previously.
Name this object in the Node Properties tab.
In this case, the group’s name is “Handkerchief” again.
- From the “LOD 0” connection of the Child Object node drag and drop to create a Material node.
Set the handkerchief’s material in the Node Properties tab.
In this example, the material selected is “MaterialVariations_Handkerchief_M”.
- Finally, create a Skeletal Mesh node to add the handkerchief’s mesh. In the Node Properties tab, set the corresponding handkerchief’s mesh.
In this case, the mesh selected is “MaterialVariations_Handkerchief”.
Link the "Mesh" connections of both Skeletal Mesh and Material nodes.
- Currently, both objects are already set, but if enabled at the same time, they don’t match each other. Compile if wanted to check it.
To fix this, a Material Variation node has to come into play. First of all, a tag to identify which is the object's material that triggers the switch between the default and the varied mesh is needed.
Select the Material node of the “handkerchief” object and in the Node Properties tab, click the "+" button on the Tags sub-tab.
Create a name for this tag.
In this example, the tag is called “Handkerchief”
- Afterward, go to the “Hair” Child Object node and disconnect it from its Material node making some room between them. Drag and drop from the “LOD 0” to create a Material Variation node.
- With the Material Variation node selected, go to the Node Properties tab and add a new variation by clicking the “+” button.
Unfold the “0” layer sub-tab under Variations and write the same name written on the handkerchief material’s tag previously.
In this case, the tag is also called “Handkerchief”
- Connect the previously disconnected hair’s material and skeletal mesh to the “Default” connection of the Material Variation node.
This is the mesh that will be displayed as default if the handkerchief is not enabled.
- Finally, it is time to add the modified hair mesh. From the “Variation 0” connection of the Material Variation node create a Material and a Skeletal Mesh nodes (the same structure as the Default’s one) or just duplicate the “Default” ones.
- The Material node should be the same as the default hair’s one, but the mesh is different.
Select the varied hair mesh's Skeletal Mesh node and set the corresponding mesh in the Node Properties tab.
In this example, the mesh chosen is “MaterialVariations_HairHandkerchief”
- Finally, the nodes’ structure is finished. Verify that the Source Graph tab looks like the image below.
- Compile. Compare how the hair looks without the handkerchief and then enabled it. Notice the differences between the meshes.
- Last Author
- gerard
- Last Edited
- Sep 17 2021, 4:10 PM