== Overview
This tutorial explains how to create a Customizable Object in which a mesh morph variation is applied. In this page, four types of Mesh Morphs will be created in order of complexity to obtain all the required variations of a mesh and the selection of intermediate results from the progression between two or more morphs.
(WARNING) We recommend visiting the [[ URL | Basic Concepts ]] page before start creating any Customizable Object
= Add shape variations with Mesh Morphs
(NOTE) The resulting Customizable Object of this example can be found in the [[https://work.anticto.com/w/mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/Examples/HowTo// named "ShapeVariations"
== 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 curve texture
(NOTE) The assets used in this example can be found in the [[ https://work.anticto.com/w/mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/MeshMorphs//
= Get a constant result
== Constant Mesh Morph
This is the simplest example of a Mesh Morph’s Customizable Object. An “ear rotated” morph is proposed as a single and constant result.
== Steps
1) The first step is to create a basic [[ URL | Customizable Object]] asset with the Base Object, the Material, and the Skeletal Mesh.
{F85668}
> In this example, the Customizable Object asset is named "Shape Variations", the Reference Skeletal is "ShapeVariations_BaseBody", the Material is called “ShapeVariations_M” and the Skeletal Mesh is the same as the Reference Skeletal’s one.
2) Click and drag from the “Unnamed Material Mesh” parameter of the Skeletal Mesh node to create a [[ URL | Mesh Morph]]node.
{F85670}
3) With the Mesh Morph node selected, choose a morph among the “Morph Target” sub tab’s drop-down menu in the Graph Node properties tab.
{F85672}
> In this example, the “Ear_rotation” is the chosen morph.
4) As the objective is to variate a part of the mesh directly and without intermediate results, the Factor needed to be applied is the [[ URL | Float Constant]] node. From the “factor” parameter of the Mesh, Morph node create a Float Constant node.
{F85674}
5) With this last node selected, change or maintain the “Value” sub-tab to “1,0” in the Graph Node Properties tab.
{F85676}
(NOTE) The “Value” ranges from 0 to 1. In this example “1” is set to have the full morph modification.
6) Connect the “Mesh” parameter of the Mesh Morph node to the “Mesh” parameter of the Material node.
{F85678}
7) Save and compile. The character must look like this in the Preview Instance Properties tab:
{F85682}
> Before compiling
{F85684}
> After compiling
== Child Object Mesh Morph
The result is similar to the “Constant Mesh Morph” example but, in this case, the objective is to add a shape variation on a mesh and to enable or disable this option. A prominent nose shape is proposed as a child asset choice. As the objective of this tutorial’s example is to add a shape variation on a mesh and to choose how and when to enable or disable this option.
== Steps
(NOTE) This tutorial begins with the same basic customizable object set in Step 1 of the previous example. Start the new tutorial from here:
1) Create a Child Object node from the “Children” parameter of the Base Object node.
{F85686}
2) Name the Object Group in the Graph Node Properties tab and select a type of choice menu in the “Group Type” sub-tab.
{F85688}
> In this example, the Object Group’s name is “Nose Variations” and the Group Type is “Toggle”.
3) Drag and drop from the “Objects” parameters of the Object Group node to create a Child Object node.
{F85690}
(NOTE) Having created an Object Group allows adding as many Child Objects as wanted (depending on the number of morphs).
4) Name the Child Object node in the Graph Node Properties tab.
{F85692}
> In this example, the Child Object is called “Nose Pepper”.
5) Create a [[ URL | Morph Material ]] node. Connect the “Material” parameter to the “LOD 0” of the Child Object node.
{F85694}
6) In the Graph Node Properties, and with the Morph Material node selected, choose the parent’s material in the Parent tab. Then, in the Morph Target tab, click in the drop-down menu and choose the Morph preferred.
{F85696}
> In this example, the Parent’s material is “ShapeVariations_M” and the Morph Target selected is “Nose_pepper”.
7) Save and compile. In the Preview Instance Properties tab, the toggle menu of the child object should be displayed like in the image below.
{F85698}
Then, check the Preview Instance Viewport tab that no morph is already applied. The character shouldn’t have changed before enabling the toggle button:
{F85700}
Now, click on the toggle button and the morph should be applied:
{F85702}
=Create a Mesh Morph controlled by a slider
==Simple slider
In this example, the mesh morph is used as the final shape of a gradual modification of the mesh. The variation between this morph and the default mesh offers a great number of interesting modifications. The same exercise of the ears’ rotation is proposed but with all the intermediates available by moving a slider.
== Steps
(NOTE) This tutorial begins where the previous one finished.
1) Check that the Source Graph tab is similar to this image below.
{F85704}
(NOTE) Create Comment boxes if wanted to arrange and optimize better the space.
2) As in the first example, create a Mesh Morph node from the “Unnamed Material mesh” parameter of the Skeletal mesh node. Then, in the Graph Node Properties tab select the preferred Morph in the Morph Target sub-tab.
{F85706}
> In this example the morph selected is “Ear_rotation” again.
3) The objective is to have a slider to control the intermediates' values of the Mesh Morph node. In this case, instead of creating a Float Constant node as in the first example, the Float Parameter is the most suitable one. Create a [[ URL | Float Parameter]]node dragging form he “Factor” parameter of the Mesh Morph node.
{F85708}
4) In the Graph Node Properties tab and with the Float Parameter node selected change the Default value number if wanted and write a name in the Parameter Name sub-tab.
{F85710}
> In this example, the Default Value is 0, so by default the morph is not applied at all. The Parameter Name is “Ear Rotation”.
5) Connect the “Mesh” parameter of the Mesh Morph node to the “Mesh” on of the Material node.
{F85712}
6) Save and compile. In the Preview Instance Properties tab, a new slider must appear next to the Float Parameter’s name.
{F85714}
7) Check that the ears rotate when moving the slider.
{F85716}
=Curve-based slider
This is the last and more complex example. Multiple mesh morphs can be used as target shapes of a gradual modification of the mesh based on curves’ values. The most interesting thing about this way of applying the morphs is the great control of the transformation and the number of morphs that can be accumulated. It is a versatile tool to create all kinds of different mesh variations. In this example, two different head morphs are proposed as the two ends of the curve passing by the “default” mesh in the middle. In the end, a slider will be displayed to control the nodes.
== Steps
(NOTE) This tutorial begins where the previous one finished.
1) Check that the Source Graph tab is similar to this image below.
{F85718}
2) Create a new Mesh Morph node from the “Mesh” parameter of the previous Mesh Morph node (Ear Rotation Example). Disconnect the “Mesh” parameters of the Mesh Morph node and the Material node.
{F85720}
3) In the Graph Node Properties, select a morph in the Morph Target sub-tab.
{F85722}
> In this example, the Morph Target applied is “Head_crushed”.
4) From the previous Mesh Morph node’s “Mesh” parameter, create another Mesh Morph node.
{F85724}
(NOTE) All the Mesh Morph nodes are attached to add all the transformations to the default mesh.
5) In the Graph Node Properties, select another morph in the Morph Target sub-tab.
{F85726}
> In this example, the Morph Target applied is “Head_eggShaped”.
6) As the Mesh Morph’s transformation must be based on curves’ values to control the variations, a Curve node is required. Create a [[ URL | Curve node]].
{F85728}
7) In the Graph Node Properties, select a curve in the Curve Asset sub-tab.
{F85730}
> In this example, the Curve Asset selected is “ShapeVariations_Curve”.
(NOTE) The Curve Asset is a tool that allows for the control trough curves of the values of the shape variation progress between two or more morphs.
>In this example, there are two channels: “R” related to the “Head Crushed” morph and “G”, related to the “Head Egg Shape” morph. The first morph starts with the 100% influence in the 0 value of the Y-axis and lowers the influence as the value approaches the 0.5 in Y. When arriving at the 0.5, no morph is influencing the default mesh, but after that, the curve of the second morph starts to grow until the 1 value in Y, where the morph is influencing 100%.
{F85732}
>The shape of the curves is describing the behavior of the progression, hence in this example, the variation is slightly more abrupt in the middle of the graph than in the ends.
8) Connect the “Curve 0” parameter of the Curve node to the “Factor” parameter of the first Mesh Morph node (Head_crushed) created in this example. Do the same with the “Curve 1” parameter and the second Mesh Morph (Head_eggShape).
{F85734}
(NOTE) When connecting a parameter of a Curve node to a Mesh Morph, the curve that represents the parameter is related to the morph connected. The first parameter is equivalent to the first channel in the Curve Asset and it proceeds equally with the following ones.
>In this example, only two channels are active.
9) Create a Float Parameter node from the “Input” parameter of the Curve node. This node permits the display of the controller slider.
{F85736}
10) In the Graph Node Properties, and with the Float Parameter node selected, write a name in the Parameter Name sub-tab and change the Default Value if wanted.
{F85738}
>In this example, the Parameter Name is “Head Shape” and the Default Value is “0.5” since it is the value in which the influence of the two morphs is zero.
11) Finally, connect the “Mesh” parameter of the last Mesh Morph to the “Mesh” parameter of the Material node.
{F85740}
(NOTE) Now, all the Mesh Morphs are connected to the default mesh and the shape variation can be controlled by sliders.
12) Save and compile. The Preview Instance Properties should look similar to this:
{F85742}
13) After compiling, the character shouldn’t have changed at all. If you move the slider to each end, the head’s shape should change.
{F85744}
>In this picture, the “Head Shape” slider is set by default at 0.5, so the mesh hasn’t changed.
{F85748}
>In this picture, the “Head Shape” slider is set at 0, so the “Head_Crushed” morph has been fully applied.
{F85746}
>In this picture, the “Head Shape” slider is set at 1, so the “Head_EggShape” morph has been fully applied.