What is the HowTo about?¶
Material Variation node is the subject of this page. This node allows Customizable Objects to have variations depending on the activation of a tag set in a Material node. This tag decides which variation connected to the Material Variation node will be active. This can be very useful to show different meshes, morphs, materials or textures when another object is active.
In this case, we will change the appearence of the hair of a character depending on if it's wearing a handkerchief.
What assets are needed?¶
All the assets from the basic customizable character HowTo.
A skeletal mesh and its textures and material for the Hair object.
A skeletal mesh and its textures and material for the Hair variation object.
A skeletal mesh and its textures and material for the Handkerchief object. Optional: a remove mesh to delete unseen polygons.
1- Create a basic Customizable Object with Bandit body. As this example is to show hair variations, we skip the eyelashes material.
2 - Create a basic Child Object for the hair with its skeletal mesh and material.
3 - Create a Group with Toggle option for the handkerchief. Create a Child Object for the handkerchief with its skeletal mesh and material. Optional: In this case, we also created a Remove Mesh node with a remove mesh connected on it to delete unseen polygons.
After compiling and checking the Handkerchief parameter in the Viewport tab, we see how the two objects overlap.
4 - To activate the variation in the hair when the handkerchief is active, we need to create a tag in the handkerchief Material. Select the handkerchief Material. In the Graph Node Properties tab, create a new tag by clicink the ‘+’ icon in Tags. Name the new tag. In this example, we named the tag as “handkerchief”.
5 - Now we will set the variation in the hair. Between the Child Object node and the Material node in the hair node group, create a Material Variation node. With this node selected, in the Graph Node Properties tab, add a new variation by clicking on the ‘+’ icon. Name this variation exactly as the tag that will trigger the variation. In this case, the tag was “handkerchief”.
A new connection will have appeared in the Material Variation node: Variation 0 [handkerchief]. Anything connected to the Default variation will be activated as default option, without the effect of any tag. Any node group connected to the Variation 0 will be only active when a Material with the tag “handkerchief” is active.
6 - Save and Compile.
7 - As shown in the following image, the same tag can be used for several Material Variations. In this case, all the different types of hair have their own variations when the handkerchief is active.