rdMeshTools Tutorial 7 – Adding Spatial Vertex Colors
Last Edited: 5th May 2024
Tutorial created using rdMeshTools version 1.30
Spatial Vertex Colors work in the same way as the Spatial UV data. As you can only move vertices with the WPO, using UV data can take more memory for no reason – although it does have some advantages, like Nanite meshes don’t support VertexColor Data yet.
Storing the meshes Spatial data in the Vertex Colors is easy – it gives you the X,Y,Z in the RGB channels and 2D plane distance (XY) from the center in the Alpha channel.
You can use this information in your materials in any way you want, just by reading the VertexColor data.
This tutorial is going to bend a tree using the VertexColors B value (height) and A value (distance from 0,0) to control it’s WPO.
Step 1. Create a level with a tree
I’m using a simple tree created with a tree generator in Blender – it has a trunk with a reasonable amount of vertices. If the tree has Nanite enabled, disable it to use LODs.
Step 2. Add the Spatial VertexColor Data
Now right-click on the tree asset in the Content Browser and select “Add Spatial VertColor Data”:
If you enable “Show Vertex Colors” in the Show menu, you’ll now see something like this:
Step 3. Add Some Bending to the Material Shader
Now open the Materials used by the shader and add the code below to bend them. This example just adds an animated bend, slowly rotating around the yaw. It just plugs into the WPO pin.
Step 4. Done
Now just play the level, you’ll see the tree bends more at the top, decreasing to no movement at the bottom.