Paint is a way to colour individual objects at runtime, without defining new materials or making new textures. This is often used for cars, and other objects where colours vary from one object to another, but the basic material remains the same.

There can be up to 4 paint colours per object. Also some parts of the material may not be affected by paint at all. E.g. dirt smears and special features may have their own fixed colours, while there is a base colour underneath them.

For each object, each of these 4 colours is assigned a separate diffuse RGB, a specular RGB, and a metallic flakes value (usually used for cars).

Diffuse texture as paint alpha

If the following material attribute is used: (defaults to false)


Then a diffuse texture must exist and it should have an alpha channel. Although, it may be a simple DXT1 texture with a single bit alpha channel. An alpha value of 0 means the paint colour is visible. You can imagine the diffuse texture therefore being a layer that is alphablended on top of the assigned paint colour. This is how decals, scratches, dirt, and special features are achieved. Non-dirty areas have alpha of 0, and dirty areas have full alpha.

Here is an example of a diffuse map with the Grit logo on top of some grunge. The alpha is probably hard to see in your browser, but you can save the png and load it in a paint program to see more clearly. Try putting it on top of different solid colour background layers.


Here is what it would look like when used in an object whose paint colour assignments are pure red, and pure blue.



Diffuse texture as mask

If the material attribute is left to its default value:


The behaviour is to multiply the object's assigned paint colour with the diffuse map. This is similar to what Grand Theft Auto: San Andreas did. It is like setting the diffuseColour material attribute to a colour, except that the colour can vary between different objects using the same material, because the objects have different paint assignments.

With this, no alpha channel is needed, but decals, special details, etc will not be possible as everything will be stained by the paint colour.

You can even choose to use no diffuse map at all, in which case the default diffuse colour of white will be masked by the paint. This means that the material will simply be the colour of the paint assignments.

If this were used with the above diffuse map, then the end result with red and blue paint would be as follows:



Materials with only 1 paint colour

The simplest example is a material that has a single paint colour. There are 4 paint colours to choose from, and one is selected as follows:


Other values are 1 to 4.

Materials with up to 3 paint colours

Although it is possible to have an object with 4 paint colours by having a material for each paint colour, this interferes with batching and it requires the boundaries between different paints to be edges in the geometry. For more complex effects one can use another texture, called a paintmap. This is then mapped using the standard UV coords to choose the paint colour at each fragment on screen. To use this, give the name of the texture as follows:


The texture contains red, green, and blue channels. A red, green, or blue texel means that paint colours 1, 2, or 3 will be used, respectively. Blending the colours is also possible, and in fact is necessary in order to get a good appearance for low mipmap levels.

Materials with 4 paint colours

For the 4th colour, a colour map with an alpha channel can be used. In this case, an alpha value of 0 means that paint colour 4 will be used.

See also