TUTORIAL: UNREAL - Vertex Painting
Vertex Painting allows us to paint a secondary texture over parts of a static mesh, on top of the base texture. This is useful for adding grime to walls, moss to rocks etc.
Note that this will add ‘paint’ on a per-vertex basis, so to do detail, you will need a high poly count.
1: Create a new material. We will call this ‘M_two_tone_rock’. We will be creating a rock that we can paint moss onto. We will also use starter content textures for this tutorial.
2: Add 4 Texture Sample nodes – Two on top will be Diffuse, and Two on bottom will be for normals. Pick appropriate textures and put them in the Nodes.
3: Add two Linear Interpolate (Lerp) Nodes – one by the diffuse textures and one by the normal textures.
A Lerp Node has two slots – A and B, and an Alpha slot. The alpha simply controls the mixture of A and B.
4: Put your Diffuse into the A and B slots of one Lerp Node. Put the normals into the other. Now connect the Lerp Node output pin into our material’s corresponding Base Colour and Normal slot.
5: Add a Vertex Colour Node. And Pin its RPG output into the Alpha input of each Lerp node.
6: Optionally, we can create Constant nodes to adjust the Metallic, Roughness and Specular values. We will set metallic to 0, Specular to 0 and Roughness to 1.
NB – Specular makes things shiny and makes light bounce off. Roughness also affects light bounce, but also the sharpness of light reflections.
We can also add a texture co-ordinates node to the top of our chain to scale up or down our UV tiling if necessary.
7: Save the material and Add it to a rock mesh in our scene. Now click on Paint Mode from the Modes Panel on the left of the main editor screen.
There are the usual size/ strength/etc tools for our brush. What we are mainly interested in is the Vertex Painting options. You will see we have two colours – Black and White. Don’t change these. To go between, just click the little curved arrow swp button. Each one represents one of the two textures in our material. So just paint with left mouse button to add the secondary texture, or Shift L-Click to mask it back out.
You can see here how we can duplicate the lanterns - same mesh, same material, but each can have a unique appearence.
APPLYING A HEIGHTMAP
What can be really useful, is to have the second texture only appear on certain parts of the base texture. For example, if we have a cobbled street base texture, we may only want to apply grass between the cracks.
1: Create a material similar to the one above.
We also need a heightmap that corresponds with the cracks in the cobblestones. This should be added as a Texture Sample Node.
2: Instead of plugging the Vertex Map into the Lerp node alphas as before, instead create a multiply node. Plug the Vertex Colour and Height Map Texture nodes into the A and B slots.
3: It’s possible this combination won’t be strong enough so we can boost it. Now create a Power Node and a Scalar Parameter Node. Set Scalar Parameters base value to 1. Also name it to ‘Blend Power’
Plug our Multiply into the Power Node’s Base pin, and the Scalar Parameter into the Power Node’s Exp pin.
4: Add a Clamp Node and Plug our Power Node into it’s input pin. Set min to 0 and Max to 1, just to stop values getting too high or low.
5: This chain of Nodes can now be plugged into the Alpha slots of our original Lerp Nodes.
6: If the effect isn’t strong enough, increase the Blend power of our Scalar Parameter. (NB – This can be done in the Object inspector, we don’t need to open the material editor again.)