Page MenuHomeAnticto

Mutable for Unreal Engine 4 | Material Variations
Updated 8 Days AgoPublic

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.

The Material Variation node allows showing different meshes, morphs, materials or textures when a certain object is active.
We recommend visiting the Basic Concepts page before start creating any Customizable Object

Hair’s mesh variation when a handkerchief is on

The resulting Customizable Object of this example can be found in the Village Demo in Content/Examples/HowTo/Material Variations named "Material Variations"

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
The resulting Customizable Object of this example can be found in the Village Demo in Content/HowTo/MaterialVariations named "MaterialVariations"

Steps

  1. The first step is to create a basic Customizable Object asset with the Base Object, the Material and the Skeletal Mesh.

imagen.png (157×902 px, 52 KB)

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.


  1. 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.

imagen.png (282×899 px, 76 KB)


  1. In the Node Properties name this first object.

imagen.png (165×325 px, 12 KB)

In this case, the child object’s name is "Hair".


  1. From the “LOD 0” connection of the Child Object node create a Material node for this “hair” object.

imagen.png (274×903 px, 87 KB)

With this last node selected go to the Node Properties tab and set the hair’s material.

imagen.png (266×412 px, 25 KB)

In this example, the material selected is “MaterialVariations_Hair_M”.


  1. 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.

imagen.png (182×377 px, 18 KB)

In this case, the “MaterialVartiations_Hair” is chosen.

Afterward, link both “Mesh” connections of the Skeletal Mesh and the Material nodes.

imagen.png (251×1 px, 107 KB)


  1. 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.

imagen.png (351×925 px, 105 KB)

In the Node Properties tab, write a name for this group and choose the group type preferred.

imagen.png (118×276 px, 8 KB)

In this example, the group’s name is “Handkerchief” and the type is “Toggle”.


  1. Now, create a Child Object node and link its “Object” connection to the “Objects” one of the Group node created previously.

imagen.png (121×388 px, 30 KB)

Name this object in the Node Properties tab.

imagen.png (164×289 px, 12 KB)

In this case, the group’s name is “Handkerchief” again.


  1. From the “LOD 0” connection of the Child Object node drag and drop to create a Material node.

imagen.png (111×584 px, 38 KB)

Set the handkerchief’s material in the Node Properties tab.

imagen.png (285×457 px, 29 KB)

In this example, the material selected is “MaterialVariations_Handkerchief_M”.


  1. Finally, create a Skeletal Mesh node to add the handkerchief’s mesh. In the Node Properties tab, set the corresponding handkerchief’s mesh.

imagen.png (179×430 px, 20 KB)

In this case, the mesh selected is “MaterialVariations_Handkerchief”.

Link the "Mesh" connections of both Skeletal Mesh and Material nodes.

imagen.png (117×923 px, 60 KB)


  1. 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.

imagen.png (599×656 px, 384 KB)

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.

imagen.png (284×448 px, 28 KB)

Create a name for this tag.

imagen.png (282×441 px, 29 KB)

In this example, the tag is called “Handkerchief”


  1. 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.

imagen.png (118×1 px, 60 KB)


  1. With the Material Variation node selected, go to the Node Properties tab and add a new variation by clicking the “+” button.

imagen.png (143×272 px, 9 KB)

Unfold the “0” layer sub-tab under Variations and write the same name written on the handkerchief material’s tag previously.

imagen.png (173×265 px, 10 KB)

In this case, the tag is also called “Handkerchief”

The name of the tag must be exactly the same, if not, the activation of the object whose material has a tag won’t trigger the modified mesh.

  1. Connect the previously disconnected hair’s material and skeletal mesh to the “Default” connection of the Material Variation node.

imagen.png (134×890 px, 49 KB)

This is the mesh that will be displayed as default if the handkerchief is not enabled.


  1. 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.

imagen.png (238×1 px, 107 KB)


  1. 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.

imagen.png (171×475 px, 20 KB)

In this example, the mesh chosen is “MaterialVariations_HairHandkerchief”


  1. Finally, the nodes’ structure is finished. Verify that the Source Graph tab looks like the image below.

imagen.png (493×1 px, 187 KB)


  1. Compile. Compare how the hair looks without the handkerchief and then enabled it. Notice the differences between the meshes.

imagen.png (671×601 px, 423 KB)

imagen.png (695×605 px, 503 KB)

Last Author
gerard
Last Edited
Fri, Sep 17, 4:10 PM