0% found this document useful (0 votes)
86 views6 pages

Chris Albeluhn - UDK Advanced - Vertex - Painting

This document provides instructions for creating an advanced vertex painting material in Unreal Engine. It begins with a basic vertex shader that lerps between two textures based on the vertex color. It then describes adding variation by multiplying the vertex color with a cloud texture, inverting values, and using a rotator node. The result is clamped and powered to create a noisy variation. This output is used to drive the lerp amounts, allowing the material to blend realistically based on the painted vertex values. Following these steps carefully will result in a material that adds variation and realism to vertex painted surfaces.

Uploaded by

Kristine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views6 pages

Chris Albeluhn - UDK Advanced - Vertex - Painting

This document provides instructions for creating an advanced vertex painting material in Unreal Engine. It begins with a basic vertex shader that lerps between two textures based on the vertex color. It then describes adding variation by multiplying the vertex color with a cloud texture, inverting values, and using a rotator node. The result is clamped and powered to create a noisy variation. This output is used to drive the lerp amounts, allowing the material to blend realistically based on the painted vertex values. Following these steps carefully will result in a material that adds variation and realism to vertex painted surfaces.

Uploaded by

Kristine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Chris Albeluhn - UDK Advanced_Vertex_Painting

chrisalbeluhn.com /UDK_Advanced_Vertex_Painting.html

Vertex painting can be a po werful thing, but a large piece o f what makes it po werful is the material yo u create.

A vertex blend between two different textures is co mmo n kno wledge, but if yo u’re un-sure abo ut ho w to set this up, here is
a very quick tuto rial o n the basics. This is essential kno wledge fo r making this material. I will start at the mo st basic and
wo rk my way up explaining what every no de do es to make the final versio n o f this material wo rk.

First we will need a shader. This image is a VERY basic representatio n o f what a vertex shader may lo o k like.

What this do es is the ‘vertex co lo r’ (red) co ntro ls which texture is visible based o n the Lerp.

A Lerp no de has 3 inputs and o ne o utput. The inputs are channel A, channel B and Alpha. The alpha is where yo u will plug
in black and white variable (either a red, green, blue o r fully desaturated texture). The black value o f this texture represents
channel A, and the white value represents channel B. What this means is whatever vertex has a red vertex value o f 100%
(fully white) yo u will get a texture plugged into channel B, but the mo re yo u paint this value so the red vertex is clo ser to a
value o f 0% (fully black) the mo re o f the texture plugged into channel A will appear.

Every single o bject yo u impo rt into the scene will have a default value o f 100% white fo r all the red, green and blue vertex
co lo rs, so by default, if yo u want a certain texture to sho w up first, make sure that is plugged into channel B o f the lerp.

No w, yo u will need 3 lerps, and the images plugged into them sho uld match. Usually, yo u have a diffuse, specular and
no rmal map texture, so in the image abo ve, i have a lerp fo r each o ne o f these. There is a wall texture plugged into channel
B; Likewise, there sho uld be a Lerp with the spec o f the wall texture plugged into channel B and the same go es fo r the
no rmal map. The brick will be painted in, so that sho uld be plugged into channel A o f the lerp alo ng with the matching specs
and no rmal maps. Make sure yo u have the red vertex co lo r plugged into the alpha o f each o f these lerps. And there yo u go ,
a functio ning vertex shader. No w, lets see it o n a mo del.
First, the mo del needs a bit o f extra geo metry than usual. Typically, anything in unreal that is less than 500 po lys isn’t much
o f a perfo rmance hit the lo wer yo u go , so adding a bit o f geo metry to suppo rt this shader isn’t usually a big issue. Lets take
this geo metry fo r example.

With this mo del there are 28 po lys o n o ne side


instead o f the typical 1 po ly. Witho ut this extra
geo metry, yo u wo n’t have any verts to paint, so
they are required.

This screen sho t is here to sho w the mo del in


the engine and the vertex’ that are painted.
Bright red represents 100% red vertex value fo r
the red channel, the darket it gets, the clo ser it
beco mes to 100% black.

This is the same geo metry with the same vertex painted values with the shader we just made.

As yo u can see, it’s no t the best result, no where near what I want it to be. What this needs is variatio n. To get this variatio n,
i will be adding a ‘vertex variatio n’ shader setup i co vered in ano ther tuto rial. I will go o ver it again since it has been
changed slightly fro m my last tuto rial which co vered it.

This is where it gets a little mo re ‘advanced’. Regardless, if yo u fo llo w the instructio ns clo sely, yo u sho uld achieve the
same results. First we need a ‘clo ud’ texture which is as easy as pressing a butto n in pho to sho p. Under the filter menu,
select ‘Render’ and ‘Clo uds’. This will create a repeating texture based o n the two co lo rs yo u have available fo r painting o n
the left handed menu. Make sure yo u have 100% black and 100% white so there will be no co nfusio n.

Only o ne o f these textures needs to be used. This is what the final versio n o f the shader lo o ks like.

The main additio n to this shader is o n the bo tto m right side. Here is a clo se up o f just that sectio n.

First, we need to bring in the texture lo cated o n the to p right and multiply this by the vertex co lo r. If i sho w this ‘multiply’
plugged into the diffuse, this is the result we go t. This will help better understand what this shader is actually do ing.
Where the vertex is 100% red, the ‘clo ud’ texture remains the same, ho wever where it is painted clo ser to 100% black, it
gets darker.

Next we need to multiply this by a co nstant variable o f 4 so the white areas are much whiter than befo re. If yo u paint the
black areas clo ser to black, since we are multiplying, the black areas will remain black.

This is what that change will lo o k like.

Since we are using the ‘multiply’ variables, we will need to invert the values co ming o ut o f the ‘vertex co lo r’ no de fo r this
next part. With the o riginal ‘vertex co lo r’ no de, yo u need to plug that into a ‘OneMinus’ variable. This will flip the black and
white values. To add a different variatio n to this, we need to ‘ro tate’ the texture; Because o f this we will need to duplicate the
o riginal clo ud texture, create a ‘ro tato r’ no de and add a ‘co nstant’ variable with a setting o f 2 plugged into the ‘time’ variable.

This is what that change will lo o k like.


YES! It lo o ks ugly, but lets ‘add’ this with the o riginal step, and this is what yo u’ll get.

Again, ugly, but there’s mo re. We then need to ‘add’ the o riginal vertex co lo r to this. This is what that change will lo o k like.

We then need to insert this into a ‘po wer’ no de with an expo nent o f 20. This is then ‘clamped’ so yo u are o nly left with
100% white and 100% black.

This is what that change will lo o k like.


THERE we go . THAT’S what we want..... This is what will be inserted into the ‘alpha’ o f the lerps in place o f the ‘vertex
co lo rs’ co vered earlier.

We then need to duplicate the ‘co nstant clamp’ ‘po wer’ and ‘co nstant’. Have them set up in the same way, but change the
‘co nstant’ to 75. Yo u then need to create a ‘multiply’ no de and plug in the ‘wall’ texture the recently duplicated ‘co nstant
clamp’ no de into either o f the A o r B channel o f the multiply. This multiply will then plug into channel B o f the diffuse lerp
no de.

I kno w in wo rd fo rmat this can be co nfusing, but if yo u refer back to the o riginal shader screen sho t, it will help.

This is what that change will lo o k like.

THERE ya go . The shader’s co mplete. Yo u can do mo re by painting in burned marks, grime, whatever else. Use different
vertex co lo rs co nnected into different lerps either placed befo re o r after the existing lerps to co ntro l dirt, grimes o r
scratches.

You might also like