InverseVertexColor (Material stage keyword)
Description
The inverseVertexColor keyword instructs the engine to multiply the given stage by the inverse of the vertex color of the mesh to which the material is applied.
Usage
inverseVertexColor
Parameters
This keyword does not accept parameters.
Example
The following stage will take the inverse of the vertex color of the mesh into account…
{
map textures/custom/image1
inverseVertexColor
}
Notes
This keyword uses color math where…
[Image Map] x (1.0 - [Vertex Color]) = [Result]
So for each texel across the surface of a mesh, the color of the image map and vertex color are sampled and then a result is calculated.
So using the above formula here are some examples…
1.0 x (1.0 - 1.0) = 0.0
1.0 x (1.0 - 0.75) = 0.25
1.0 x (1.0 - 0.5) = 0.5
0.5 x (1.0 - 1.0) = 0.0
0.5 x (1.0 - 0.75) = 0.03125
0.5 x (1.0 - 0.5) = 0.25
Generally speaking, as the vertex color shifts from black to white, the image map will darken. If the vertex color is black, result is the same as the image map. If the vertex color is white, the result is black.
This keyword is commonly used in conjunction with VertexColor to create a material that blends between two textures based on vertex color. A very basic example would be like so…
{
blend add
map textures/custom/image1
vertexColor
}
{
blend add
map textures/custom/image2
inverseVertexColor
}