Why this tutorial makes materials a certain way.

Hi there, I’m watching a tutorial on Digital Tutors (Pluralsight) about making blizzard environments.

What is vertex color? To make a blendable snow and concrete material in unreal engine 4, the artist lerps the two texture samples together using the vertex color’s alpha channel as input for the lerp. He then multiplies this by all of the vertex color to get his “base color” input for the material.

He does this exact same thing for his normal and specular maps. This method of texture blending could be outdated, which may explain why I’ve never seen it done before- still I’m curious and interested about the math behind this.

Also, he stresses that the “main” texture, the one we want to be there before any painting is done, must be plugged in to the ‘B’ input of the lerp node. Why is this so important?

Here’s what his setup looks like (I left out specular and diffuse):

http://puu.sh/phwUj/76eaded504.png

Hi!

It is common to use vertex colors to create a lot of effects. It’s an efficient way to store some extra data for each of the vertices of the mesh. Then, in the shader, you can read those colors and use them for whatever you want. They don’t need to be used as colors (they are just four numeric values from 0 to 1).

So, in your example, they are using those vertex colors to add some coloring to the mesh and specify how those two textures will blend. You can paint those vertex colors inside your 3d application (3DS Max, Maya, Blender, etc.) or you can paint them inside UE4 with the Paint tool. With this, you can, for example, add two instances of the same rock in your scene and assign them that material. With the paint tool, you can paint some values to the alpha channel of vertices of each instance of the rock. So that will allow you to add snow differently to each instance. So with only one material and one mesh, you can have a lot of different looking rocks. One instance of the rock could be under a bridge, so you could specify that instance to don’t have snow.

And the tutorial is recommending to plug the main texture to the B input because by default, the vertex colors of a mesh are always white (RGBA 1,1,1,1), so by default, meshes with that material would show that main texture (A = 0, B = 1). If the textures where plugged in the other way, everything would be snowy and you would have to subtract the snow instead of adding it. It just depends of your needs.

I hope this information is useful to you and ask if you have any doubts.

Greetings!

Hi! Thanks for the well-detailed explanation. So I guess you would actually want to subtract some alpha from the rocks when you go to paint them if you want more snow, right?

That makes sense, but why is the lerp result multiplied by the vertex color as a whole?

Exactly. In your case, the less alpha, the more snow. And the final multiplication is just to give an extra coloring to the mesh. The final texture blending will be multiplied by the RGB color in the vertices. You could add some extra difference to each instance of a mesh. Some darker areas or something like that.