➡️In today's tutorial, we'll explore vertex painting in Unreal Engine, including creating materials for it. Vertex painting involves painting colors on a 3D model's vertices and creating masks for materials.
➡️Each vertex can store RGB color values, allowing for detailed masking. We start by adding a sphere, enabling us to vertex paint on its vertices.
➡️Vertex painting requires polygons, so we use a plane with added geometry for better painting control. We create a master material with RGB channels and set up parameters for base colors, normals, ambient occlusion, roughness, and metallic values.
Add a sphere to the scene and scale it to a bigger size.
We can see through the Wireframe that the sphere has its own topology.
This is important for vertex painting since the more vertices are present, the better the painting will turn out.
To use the vertex paint tool, switch to the Mesh Paint Mode.
Each asset in Unreal has an RGB map.
We can switch between each 3 of them with the Mesh Paint brush, and add or take away from any of the given maps.
By checking only the red channel and switching to the Red Color View Mode, we can only see the red channel and we can take away from it by switching to the Erase Color.
If we switch to the RGB Channel Color View, the sphere will turn white.
This is because when all 3 color channels are active they make up a white color.
Only removing the red channel in this view, will reveal the blue channel underneath.
Remove the sphere and add in a plane instead.
We can see that the place only has 4 vertices and if we try to use the Vertex Paint brush it will not have a good impact because of the lack of topology.
We can instead make our own plane by going in the Modeling Mode, selecting the rectangle plane, add 1000x1000 width and depth, and adding 50x50 subdivisions.
Click on the scene to place the rectangle, and then click Accept.
Now when we use the Vertex Paint brush, there is more topology to work with, giving us a better result when using this tool.
Now we’ll start making a Master Material that will help us create a transition between two textures.
Make a new material and rename it M_VertexPaintMaster.
Inside the material graph, make two TextureSamplePeramater2D.
Rename them to Base Color 1 and 2.
Change the Material Expression Texture Base on one of them to Black, while the other one should be white.
Add a Vertex Color node and a Lerp node.
Search them up and add them in the editor.
Connect all the nodes together.
Drag and drop the material on the mesh and test it out with the vertex paint brush.
We can see that when we remove the black color, it reveals the white color underneath.
Time to make the material more interesting.
Back in the graph editor, copy and paste the two 2D parameters and move the Vertex Color node back.
Rename the copied 2D parameters to Normal 1 and 2.
Change the Material Expression Texture Base to the T_Normal texture map on both of them.
Add a Lerp node and connect all the nodes together.
To make things easier, double-click on the thread coming from the Vertex Color node to add a redirector.
From the point added to the thread, you can drag out connection threads and connect nodes with them like normal.
Copy and paste two more TextureSamplePeramater2D nodes.
Change the Material Expression Texture Base to the AORM color we made in the previous tutorial when we talked about Master Materials and Material Instances.
Add 3 Lerp nodes and connect them.
Connect the Vertex Color to the Lerps.
Connect the Lerps with the bigger node in the graph.
Save the changes and close the graph for now.
In the content drawer, create a Material Instance from the Master Material.
Open Quixel Bridge and download two materials, one grass and one stone material.
Open the Material Instance and we can see we have 6 places where we can put texture maps.
Two for the base color, 2 for normal, and 2 for AORM.
Place the texture maps of both the grass and rock material.
If you haven’t placed the Material Instance on the plane, drag and drop it on the plane.
With the vertex paint brush, when we erase the top layer it reveals the grass material below.
Back in the graph, we can make a height adjuster that will give us more control over the fade of the corners between the materials.
Add a HeightLerp node and connect it with the Vertex Color.
Move back the AORM nose below the Vertex Color.
Detach the blue dot of AORM 1 from the Lerp node and its place put two Parameters, and rename them Metallic 1 and 2.
Connect the Lerp node with the redirector of the Vertex Color node.
Add two new Peramaters naming them Height Contrast and Height Strength.
Add a Multiply node, and connect the nodes together.
Add a 1- node to the Vertex Color.
Save the changes and see if the nodes are working well with the Material Instance.
Add a Switch node and a Static Bool Parameter.
Rename the Parameter to Is This A Bridge Material?.
Connect the Multiply node with the Switch.
Add a TextureSamplePeramater2D node, and change the Material Expression Texture Base to a noise material.
Connect the texture to the Switch node.
Add a new Multiply node and connect the Texture node, Height Strength parameter, and Switch.
Copy and paste the Static Bool Parameter and place it near the two Metallic nodes that are connected to a Lerp node.
Add a Switch node and connect to the Bool.
Add a new Lerp node and connect the blue dots of the AORM 1 and 2 to the Lerp node.
Connect the Lerp node with the redirector.
Connect the Lerp node to the Switch and then connect the Switch to the metallic part of the bigger node.
At the Base Color nodes, add a Vertex Parameter, a Switch node, and a Static Bool Parameter.
Rename the Bool Use Color 02 Instead of BC.
Connect the Bool and Vertex Parameter to the switch node, and then connect the switch to the Lerp node.
Save the changes and check if the controls work well.
If we tick the Use Color 02 Instead of BC, we can then change the color of the material.