This article explains how to create and use a Table Node to create variations of objects with similar characteristics.
There are two assets required to create a Table Node :
- UDataTable: This asset will store all the asset of the different variations. Each column will represent a pin in our Table Node and each row a variation for our objects.
- UStruct: This asset will determine the structure and default values of our Data Table. Each variable of this Struct will generate a new column in our Data Table. Also, this asset allow us to select the Default Asset which helps set similar properties between all the assets of the same column.
There are some assets that require some conditions to work in a Table Node:
- All Skeletal Meshes of the same column should have:
- Same Layout Structure.
- Same number of LODs.
- Same number of Materials.
- Same Material Slot structure (All material sections should we in the same position).
- Material Instances can modify parameters of a Material Asset. Mutable must know which parameters are going to be modified in a Material Instance Column. To do so, we have to select all the modifiable values that our material instances will modify in the Default Material Instance. For example, if the Material Instance of the Row 3 modifies the parameter A, and the Material Instance of the Row 6 modifies the parameter B, we should set as modifiable the parameters A and B in the Default Material Instance.
If we want to create a mesh variation with a Node Table first, as we said, we need to create first a UStruct and then a UDataTable. To create a UStruct we just right click on the content browser and then we type "struct" in the context menu that has appeared (Context Menu -> Blueprints -> Structure). We are going to name it "ExampleStruct". If we click on it to open the asset, we will see two tabs:
- Structure: In this tab we are going to define the structure of our data table by pressing the "+ Add Variable" button.
- Default Values: In this tab we are going to define the default values for each variable of the struct.
As we already have a default variable created we are going to use it for our mesh. To do so, we have to select the drop down menu which specifies the type of our variable. We are going to search for Skeletal Mesh and the create a **Soft Class Reference". We are going to name our mesh variable "Hair Mesh" which would be the name of the column in our Data Table and the name of our pin in the Table Node.
Once we have our first variable, we have to select a Default Value for it in the "Default Values" tab. Take into account that the Default Variable will be the reference mesh for all the meshes of the same column of our Data Table. That means that all the meshes of the same column will have the same Layout and also they should have the same amount of LODs and Materials (Sections). I will select the asset "Bandit_Hair_Backwards" for this example.
At this point we already set up our Structure. Now it's time to create and set up our Data Table. To do so, we right click on the content browser and we type "Data Table" in the context menu (Context Menu -> Miscellaneous ->Data Table). We are going to name it "ExampleDataTable". If we open it, we will see that there are three tabs:
- Data Table: This tab shows the information of each row and columns of the table. Right now there are two columns, one for the name of the row "Row Name" (automatically generated) and another one for the variable that we just created in the Structure "Hair Mesh".
- Data Table Details: Tab with some information of the table. We are going to ignore it.
- Row Editor: Tab to select the assets that we want to use for each row.
Now is time to fill our Data Table to create some mesh variations. To do so, first we have to add a new row by clicking on the "+ Add". This will create a new row with the default values. We are going to keep the mesh with the default value and we are going to change the row name to "Backwards". This name is the one that will appear in the variation selector of our UI.
We are going to create two new rows with the following Skeletal Meshes: "Bandit_Hair_Greek" & "Bandit_Hair_Sir".
Now we have our Data Table set up. It is time to create our Customizable Object and test our Table Node. We are going to name our Customizable Object "TableNodeCustomizableObject". Once we have opened our Customizable Object, we need to create two nodes: a Table Node and a Material Node.
Our Table Node doesn't have any pin because it doesn't have any Data Table assigned. To select a Data Table for our Table Node we have to click on the node and then fill the property Table, in the Node Properties tab, with our Data Table "ExampleDataTable". We will name the parameter as "Hair".
We will see how the node refreshes automatically after select the Data Table and our mesh pins appear.
Now we can connect the first LOD pin to the Material Node and connect the Material Node to the Base Object Node. We will select the material "HairMaterial" for our Material Node and then we will compile our Customizable Object.
We can see in the results of the previous example that there are some visual artifacts in the Greek and Sir meshes. This is because we are using the same textures (Roughness, Normal, Details) for all the meshes and we should not. With the Table Node we can also create texture variations. To do so, we are going to create three new Texture 2D variables (Soft Object References) in our struct, one for each texture of the material (Roughness, Normal, Details). The default values would be: "Bandit_HairBackwards_D", "Bandit_HairBackwards_N", "Bandit_HairBackwards_R". We will also add a color variation to distinguish each type of hair. To do so, we will have to create a Linear Color variable and we will let the black color as default.
Each new variable has created a new column in our Data Table, let's fill each row with the corresponding textures and colors. For the backward hair we will use the default values. For the greek hair we will us a brown color and the following textures: "Bandit_HairGreek_D", "Bandit_HairGreek_N", "Bandit_HairGreek_R". For the Sir hair we will us a white color and the following textures: "Bandit_HairSir_D", "Bandit_HairSir_N", "Bandit_HairSir_R".
If we refresh our Table Node our new pins will appear.
Let's connect these textures to our Material Node and compile. For the color parameter of the Material Node we will generate a texture by linking our color parameter and the Texture_D to a Texture Layer Node.
We could also use a float variable to control some float parameters of the material, like the metallic parameter.
We can use material instances to clean a little bit the graph and have better control of the variations. To do so, we are going to delete all the textures, floats and color variables from our structure. Then, we will create a material instance variable (Soft Object Reference). We are going to name it "Hair Material".
However, before selecting a material instance, we have to create them. We will create three material instances from our material "HairMaterial": "HairMaterialBackwards", "HairMaterialGreek" and "HairMaterialSir". In each of this instances we will modify the parameters to match the values from the last example.
Now that we have our material instances, we have to select a default value (we will use the "HairMaterialBackwards") for our Structure and then, fill the values of our Data Table rows. Once we have all set up, we will have to refresh our Table Node. All the texture pins will disappear and a Material Pin will appear. Link this material pin to the Table Material pin of the Material Node and compile.
We can select which animation instance, animation slot and animation tags we want to use for each Skeletal Mesh column of the data table. To do so we have to create three new variables in our Structure. An Anim Instance variable, which has to be a Soft Class Reference, for the animation blueprint, an Integer variable for the animation slot and a Gameplay Tag Container variable for the animation tags.
Once we have added these new variables, we can fill the information in the Data Table. Then, to indicate which animation instance, slot index and tags uses a skeletal mesh, we have to use the Table Node properties tab. In the "Animation Properties" section we will see a that if we select a mesh column in the "Mesh Column" parameter, three new combo boxes will appear. In this combo boxes we will have to select the Animation Instance column, the Animation Slot column and the Animation Tags column that the Skeletal Mesh Column will use.