Mutable for Unreal Engine | Create color patterns with masks
Overview
This article explains how to add color patterns in the textures of a character's cloth piece. This is achieved by applying color effects through masks. In this example, two-colored patterns are applied to a head handkerchief: one with lines and one with circles. The first case explains the basic node structure and how to control the colors of the pattern with a slider. The second example adds a second pattern option and the possibility to switch between them. This example is applied to a Child Object inside the parent's Customizable Object asset but the core structure of the example can be ported to any object setup.
Add a pattern with a preset combination of colors
This case explains how to add a pattern with lines to a handkerchief, a child object of a base character, by using two complementary masks. Each part of the pattern is linked to a different color bar.
Both color bars are controlled through only one slider so they share the same horizontal value when selecting. That means that the artist can control and restrict beforehand 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 end-user would choose the most important color information but not the secondary one.
Assets required
- One material asset or material instance of the character 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
- One Color Base and one Normal texture of the cloth asset
- 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
Steps
- The first step is to create a basic 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.
- As the objective is to apply colored patterns to handkerchief's mesh, a Child Object node is to be used to add this mesh to the character. Create a Child Object node.
- Select the Child Object node and name it in the Graph Node Properties tab.
In this case, the Object Name is “Handkerchief”.
- Create an Extend Material node by 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.
- 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”.
Now, this node should inherit the slots from the parent's material.
- From the “Add Mesh” connection of the Extend Material node create a Skeletal Mesh node. In the Graph Node Properties tab, select the handkerchief’s mesh. This mesh is the one on which the color patterns are to be applied.
In this example, the Skeletal Mesh selected is “ColorPatterns_OnlyHandkerchief”.
- Create a Texture node from the “Normal” connection of the Extend Material node.
- In the Texture sub-tab of the Graph Node Properties tab, select the handkerchief’s normal map.
In this example, the Texture selected is “ColorPatterns_Handkerchief_N”.
- Add a 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.
- 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 should appear in the Texture Layer node. The “Mask 0” connection is to be linked 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, choose a blending effect from the drop-down menu in the Effect sub-tab. This effect is 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”.
- As the objective is to have two masked parts of a pattern linked to different colors, another layer is needed in the Texture Layer node. Create another layer by clicking the “+” button in the Graph Node Properties tab. Select the same blending effect as the previous one if wanted.
- 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 Texture node.
- In the Graph Node Properties tab, choose a base texture of the handkerchief 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 mixed with other colors.
- Click and drag from the “Mask 0” connection to create another Texture node. The Mask A of the pattern must be connected here.
- In the Graph Node Properties, select the required mask.
In this example, the “ColorPatterns_Lines_MaskA” is the selected one.
- In this step, the group of nodes that allow having a color bar instead of a simple color begins to be created. Create a Sample Texture and link its “Color” connection to the “Layer 0” one of the Texture Layer node. This node takes individual sample values from multiple color information images, like a color bar.
- From the “Texture” connection, drag and drop to create a Texture node.
- In the Graph Node Properties tab, select a color bar texture. This one has to be the main color bar.
In this example, the texture chosen is “ColorPatterns_ColorBar_1A”.
- As a slider is needed to choose the colors, the most suitable node is a Float Parameter. Create a Float Parameter node.
This parameter requires an axis from which to extract the values. In a color bar texture, the axis in which colors change its value is the horizontal one. Link the “Value” connection of the Float Parameter node to the “x” one of the Sample Texture node.
- Select the Float Parameter node and, at 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 after compiling, so the end-user could see the color options.
Unfold the new layer sub-tab “0” and write a descriptive name for this node's connection. Refresh the Float Parameter node if it doesn’t upload automatically.
In this case, the name is “Main Color Bar”.
- Link the Float Parameter’s new connection “Main Color Bar” to the “Image” one of the Texture node. This image, the color bar, will be displayed on top of the slider after compiling.
- 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.
- 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”
- 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” one of the Texture Layer node.
- From the “Texture” connection of the Sample Texture node create a Texture node.
- 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”.
- 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 has 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.
- Check that the Source Graph looks similar to the image below.
- 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.
Add a second pattern and the option of switching between them
In this case, a color pattern with circles is created in addition to the previous Lines one. Also, the possibility of switching between them is created with a Texture Switch node and an Enum Parameter node.
Moreover, both colors of the new color pattern are controlled through two different sliders to have all the possible combinations the end-user decides.
Assets required
- One mask of a different pattern (Mask A)
- One mask of the previous pattern inverted (Mask B)
- Two color bars with plain colors (not necessarily the same number in each one)
Steps
- Check that the Source Graph tab is similar to this image below.
A comment is used to join and spot all the nodes involving the “Lines Pattern” used in the previous example.
- As the first objective of this example is to be able to switch between two different patterns, another node has to be used before the Texture Layer. Unlink the “Color” connection of the Extend Material node from the “Image” one of the Texture Layer node.
- From the “Color” connection of the Extend Material node create a Texture Switch node. This node allows having multiple Texture or Texture Layer node’s connected to it, that means that it permits choosing between different textures or texture group of nodes.
- To create eligible options in the Texture Switch node, another node is needed. Create an Enum node and link its “Value” connection to the “Switch Parameter” of the Texture Switch.
- Select the Enum Parameter node if it wasn’t. In the Parameter Name sub-tab of the Graph Node Properties tab, write a name. This name is the title of the a drop-down menu that is being created after compiling. The Default Index can be changed afterward if wanted.
The name used in this example is “Handkerchief Patterns”.
Add two layers clicking on the “+” button in the Values sub-tab. These layers are the number of patterns’ options wanted.
Click on the sub-tab icon of each layer and name them. The names should be related to the sort of pattern they are introducing. Change the Default Index if wanted, “0” is the first option, and “1” the second one.
The first choice is the “Lines” pattern, used in the first example, and the second one is the “Circles” pattern. These names are appearing in the drop-down menu as choices after compiling. The Default Index is left at “0” in this example.
- In the Source Graph tab, refresh the Texture Switch node if it hasn’t been updated automatically.
Two new slots should appear named as the two layers of the Enum Parameter’s properties.
- As the “Lines Pattern” group of nodes is already created in the previous example, the second pattern is the one to create in this step. First, a Texture Layer node is needed to use multiple layers and masks in the same texture image connection. Add a Texture Layer node from the “Circles” connection of the Texture Switch node.
- As done in the previous example, create two more layers in the Texture Layer properties, so there can be two parts of the pattern to be colored. Select the “+” button twice in the Layers sub-tab in the Graph Node Properties tab.
Choose a blending effect in the Effect sub-tab of each layer.
In this example, the blending effect chosen is “Cotle Hardlight”.
- From the “Base” connection of the Texture Layer node, create a Texture node. Here, the base texture of the handkerchief has to be set up, the same one applied to the previous Lines pattern.
In the Graph Node Properties tab, select the handkerchief base texture.
In this example, the texture selected is “ColorPatterns_Handkerchief_D”, as in the “Lines Pattern” example since it is the same handkerchief.
- Now, one of the masks of the second pattern has to be applied. Create a new Texture Layer node and connect it to the “Mask 0” of the Texture Layer node.
Apply the Mask A of this second pattern in the Texture sub-tab of the Graph Node Properties.
In this case, the “ColorPatterns_Circles_MaskA” is chosen.
- Create a Sample Texture node and link its “Color” connection to the “Layer 0” one of the Texture Layer node.
- From the “Texture” connection of the Sample Texture node create a Texture node. On this node a color bar has to be set up.
In the Texture sub-tab of the Graph Node Properties tab choose a color bar for this first part of the handkerchief's pattern.
In this example, the “ColorPatterns_ColorBar_2A” is chosen. This bar has only two different plain colors.
- Drag and drop from the “X” connection of the Sample Texture node and create a Float Parameter. This node, as told previously, is used to create selector sliders.
In the Graph Node Properties tab, write a name in the Parameter name sub-tab. This is the title of the first color bar. Change the Default Value if wanted.
In this example, the name is “Handkerchief Color 1”. The Default Value is changed to 0.0, so by default the first color of the color bar will be displayed after compiling.
Click on the “+” button in the Description Image sub-tab to add the color bar texture on top of the slider. Unfold the sub-sub-tab of the new layer and name the new connection.
In this example, the name is “Color Bar 1”.
- Refresh the Float Parameter node, if it hasn’t been updated automatically, and link the “Color Bar 1” connection to the “Image” of the Texture node so it will appear on top of the slider after compiling, The nodes for this first slider are already created.
In this example, the connection is called “Color Bar 1”, the name written at the Description Image sub-tab gap.
- From the “Mask 1” connection of the Texture Layer node, create a Texture node. This node is used to apply the complementary mask of the pattern.
Select the Mask B of the texture applied in “Step 12”.
In this case, the mask texture selected is “ColorPatterns_Circles_MaskB”. This one is the inverted mask of the already applied texture in the “Mask 0” connection.
- The second color bar has to be created for this second mask applied. Create another Sample Texture node. Link its “Color” connection to the “Layer 1” one of the Texture Layer.
- Create a new Texture node and link it to the “Texture” connection of the Sample Texture node. In this Texture node, the second color bar is to be set up.
In the Graph Node Properties, select the second color bar.
The second color bar chosen in this example is “ColorPatterns_ColorBar_2B”. This bar has four different and plain colors, two more than the first color bar of this example.
- Finally, a slider is needed to control the second color bar as well since this example presented two independent color bar selection. Create a Float Parameter node and link its “Value” connection to the “X” one of the Sample Texture.
In the Graph Node Properties tab, write a name for this parameter. This is to be the title of the second color bar. Change the Default Value if wanted.
In this example, the Parameter Name is “Handkerchief Color 2” and the Default Value is changed to 0.0, as in the first Float Parameter properties.
Add a Description Image layer by clicking on the “+” button. It is necessary that this second color bar image appears on top of the second slider after compiling, so the end-user can see all the options. Unfold the sub-tab of the new layer and write a name for the new connection to the color bar image.
In this example, the Name of this Description Image is “Color Bar 2”.
- Refresh the Float Parameter node if needed and link its “Color Bar 2” to the “Image” connection of the Texture node.
- Check that all the “Circle Pattern” nodes are similar to the image below.
- Approach the other pattern group of nodes created in the previous example, the “Lines Pattern”, and link the “Image” connection of its Texture Layer node to the “Lines” one of the Texture Switch node. After that, both patterns are already connected to the Texture Switch, and therefore, to the handkerchief mesh.
- The Source Graph should look similar to the image below.
- Compile. The Preview Instance Properties should look like this:
Check in the drop-down menu of the “Handkerchief Patterns” that the two patterns’ options appear and can be selected.
Select the “Circles” pattern and check that both color bar's sliders work independently by moving each selector and creating different combinations.
- Last Author
- gerard
- Last Edited
- Sep 16 2021, 4:12 PM