Skip to content

Custom colours explained

Peter Crew edited this page Jan 15, 2019 · 1 revision

When using the MaterialComponent to add a customisable colour to an entity, the colour in the model has to be specially prepared.


It is the Kd part of each material in an MTL file that defines the colour that the material represents in-game, with the values representing the RGB components on a scale of 0 to 1. All other parts (Ns, Ka, Ni, etc) can be ignored or omitted.

Custom colours require a special value for the Kd field. The R component should always be -1 when a custom colour is being used. The G component then contains a code stating which colour components the offset defined by B should be added to. For example, Kd -1 7 0.1 adds an offset of 0.1 to all three colour components of the custom colour.

The table below states the codes for the G component, and the offset components that they represent:

Code Colour components
0 None
1 R
2 G
3 R, G
4 B
5 R, B
6 G, B
7 R, G, B

The following is an example of a material file which defines two custom colours: the first material applies an offset of 0.1 to the G and B components of the custom colour; the second material applies an offset of 0.2 to the R and G components of the custom colour.

# Blender MTL File
# Material Count: 2

newmtl Slime_material_1
Kd -1 6 0.1

newmtl Slime_material_2
Kd -1 3 0.2
Clone this wiki locally