This article explains how to create a Customizable Object with nodes that allow adding patterns on a mesh and applying colors based on the number of masks created. Two examples of a head’s handkerchief are created from less to more complexity. The first example features the choice of a combination of two colors for a handkerchief pattern using only a color selector slider linked to a secondary "color bar". However, the second example presents multiple choices of patterns and two "color bars" working independently one from another.
(WARNING) We recommend visiting the [[ URL | Basic Concepts ]] page before start creating any Customizable Object
= = Add a pattern with a preset combination of colors
In this example, a pattern is applied to the handkerchief and, using two complementary masks, each part of the pattern is to be linked to a different “color bar”. Both “color bars” are to be controlled through only one slider so they share the same horizontal value when selecting. That means that the artist can control and restrict the combinations of colors keeping in mind the horizontal value of each. Only the main "color bar" is to be displayed on top of the slider, so the user can choose the most important color information but not the secondary one.
(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 "ColorPatterns"
== Assets required
* One material asset or material instance of the character standard with two parameters (color and normal)
* One skeletal mesh of the character with the previous material applied (one material, two parameters)
* One skeletal mesh of a cloth asset
* One Color Base, one Normal and one Roughness (if wanted) textures of the cloth asset
* One general mask texture of the cloth area the patterns are to be applied
* One mask of the pattern (Mask A)
* One mask of the pattern inverted (Mask B)
* One color bar with gradient colors
* One secondary color bar with gradient colors
(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/ColorPatterns//
1) The first step is to create a basic [[ URL | Customizable Object]] asset with the Base Object, the Material, and the **Skeletal Mesh**. Link all the connections with the same name.
> In this example, the Customizable Object asset is named "Color Patterns", the Reference Skeletal is "ColorPatterns_mesh", the Material is called “ColorPatterns_M” and the Skeletal Mesh is the same as the Reference Skeletal’s one.
2) As the objective is to apply colored patterns to a cloth asset’s mesh, a **Child Object** node is to be used to add this mesh to the character. Create a [[ URL | Child Object ]] node.
3) Select the **Child Object** node and name it in the Graph Node Properties tab.
> In this case, the Object Name is “Handkerchief”.
4) Create an **Extend Material** node dragging from the “LOD 0” connection of the **Child Object **node. This node allows using the same material as the parent’s one but connecting new textures to the slots if wanted.
5) In the Graph Node Properties tab, select the parent’s material in the Parent sub-tab.
> In this example, the material selected is “ColorPatterns_M”.
6) From the “Add Mesh” connection of the **Extend Material** node create a **Skeletal Mesh** node. In the Graph Node Properties tab, choose a cloth or fabric asset’s mesh.
> In this example, the Skeletal Mesh selected is “ColorPatterns_OnlyHandkerchief”.
7) Create a **Texture** node from the “Normal” connection of the **Extend Material** node.
8) In the Texture sub-tab of the Graph Node Properties tab, select the cloth asset’s normal map.
> In this example, the Texture selected is “ColorPatterns_Handkerchief_N”.
9) Add a [[ URL | Texture Layer ]] node from the “Color” connection of the **Extend Material** node. This new node permits to add multiple layers and masks on a base texture.
10) With the **Texture Layer** node selected, go to the Graph Node Properties tab and select the “+” button in the Layer sub-tab.
After creating a layer, two new slots appear in the **Texture Layer** node. The “Mask 0” connection is supposed to be connected to a pattern’s mask texture whereas the “Layer 0” one to a color bar.
Unfold the little sub-tab next to the “0” layer in the Graph Node Properties tab. Here, the blend effect is to be chosen from the drop-down menu in the Effect sub-tab. This effect is supposed to be applied to the “Base” connection’s texture using the color of the “Layer 0” one.
> In this example, the Effect chosen is “Cotle Hardlight”.
11) As the objective is to have two masked parts of a pattern filled with two different colors, another layer is needed in the **Texture Layer** node. Create another layer in the clicking the “+” button in the Graph Node Properties tab. Select the same blend effect if wanted.
12) The “Base” connection of the **Texture Layer** node has to be linked to a base texture on which the blend effects of the “color bars” are to be applied. Drag and drop from the “Base” connection of the **Texture Layer** node and create a [[ URL | Texture ]] node.
13) Graph Node Properties tab, choose a base texture of the cloth’s asset.
> In this case, the “ColorPatterns_Handkerchief_D” is the selected one. It is a light-gray-color-based texture because of its neutrality when other colors are blended on it.
14) Click and drag from the “Mask 0” connection to create another **Texture** node. One texture masking a part of a pattern must be connected here.
15) In the Graph Node Properties, choose the mask preferred.
> In this example, the “ColorPatterns_Lines_MaskA” is the selected one.
16) In this step, the group of nodes that allow having a color bar instead of a simple color starts to be created. Create a [[ URL | Sample Texture ]] and link its “Color” connection to the “Layer 0” one of the **Texture Layer** node. This node is used as an intermediary for the color bar and the color displayed.
17) From the “Texture” connection, drag and drop to create a Texture node.
18) In the Graph Node Properties tab, select a “color bar” texture. This one is the main “color bar”.
> In this example, the texture chosen is “ColorPatterns_ColorBar_1A”.
19) As a slider is needed to choose the colors, the most suitable node is Float Parameter. Create a [[ URL | Float Parameter ]].
This parameter requires an axis from which to extract the values. In a “color bar” texture, the axis in which colors change is the horizontal one. Link the “Value” connection of the Float Parameter node to the “x” one of the Sample Texture node.
20) Select the Float Parameter node and, in the Graph Node Properties tab, write a name in the Parameter Name sub-tab and change the Default value sub-tab if wanted.
> In this example, the Parameter Name is “Main Color”. The Default Value is changed into 0.0 to make the slider's selector pick the first color of the "color bar" as default.
Click the “+” button in the Description Image sub-tab to add a new slot in the Float Parameter node. This new connection allows displaying the “color bar” image over the slider.
Unfold the new layer sub-tab “0” and change the name if wanted. This one is the name of the new connection created. Refresh the “Float Parameter”node if it doesn’t upload automatically.
> In this case, the name is “Main Color Bar”.
21) Link the Float Parameter’s new connection “Main Color Bar” to the “Image” one of the Texture node. This image, the “color bar”, is to be displayed on top of the slider.
22) The first part of the colored pattern’s nodes is already created. The next step is to add the complementary mask of the pattern. Drag and drop from the “Mask 1” connection of the Texture Layer node to create a Texture node.
23) In the Texture sub-tab of the Graph Node Properties tab, select the complementary mask of the first mask added in the connection “Mask 0”.
> In this example, the texture selected is “ColorPatterns_Lines_MaskB”
24) Create another **Sample Texture** node. With this node starts the second “group of nodes” to create the secondary “color bar”. Link the “Color” connection of the new **Sample Texture** node to the “Layer 1” connection of the Texture Layer node.
25) From the “Texture” connection of the Sample Texture node create a Texture node.
26) In the Graph Node Properties tab, choose the secondary “color bar” texture in the Texture sub-tab.
> In this example, the texture selected is “ColorPatterns_ColorBar_1B”.
27) As one of the objectives of this example is to control two “color bars” with only one slider, in this step, the parameter that controls the main “color bar” is to control the secondary one as well. The value selected along the horizontal axis of the main "color bar" is supposed to be coincident with the one selected on the second one. Link the “Value” connection of the Float Parameter node to the “X” one of this last Sample Texture node.
The same Float Parameter is now connected to both Sample Texture nodes.
28) Check that the Source Graph looks similar to the image below.
29) Compile. A slider with the main “color bar” image should appear in the Preview Instance Properties tab.
Move the slider and get different combinations of the Handkerchief pattern’s colors.