Image bm840.GIF Color Operation
Textures, Alpha Operation
When covering an object's surface with a texture the operation can be determined that will be executed between the texture and the object surface. The maximum number of operations and textures that can be set is 8. The active operation stage to be set is determined by the stage element. It will assert itself for an active object. The stage number permissible can be detected by reading the stage element.
The color operation element defines the operation to be performed with the color components. Similarly the operation with the alpha channel can be defined by means of the alpha operation element. The color operation can assume following values:
1 the operation stage and all following stages are switched off
2 the operation output is the first color argument
3 the operation output is the second color argument
4 modulation, output = arg1 * arg2
5 modulation 2x, output = arg1 * arg2 * 2
6 modulation 4x, output = arg1 * arg2 * 4
7 add, output = arg1 + arg2
8 add signed, output = arg1 + arg2 - 0.5
9 add signed 2x, output = (arg1 + arg2 - 0.5) * 2
10 subtract, output = arg1 - arg2
11 add smoothed, output = arg1+arg2 - arg1*arg2
12 blend, alpha from color, output = arg1*(alpha) + arg2*(1-alpha)
13 blend, alpha from texture, output = arg1*(alpha) + arg2*(1-alpha)
14 blend, alpha from factor, output = arg1*(alpha) + arg2*(1-alpha)
15 blend, premultiplied alpha from texture, output = arg1 + arg2*(1-alpha)
16 blend, alpha from result, output = arg1*(alpha) + arg2*(1-alpha)
17 premodulate, modulate with next texture stage
18 modulate alpha from arg1, output = arg1 + alpha1*arg2
19 modulate with add alpha from arg1, output = arg1*arg2 + alpha1
20 modulate invert alpha from arg1, output = arg1 + (1-alpha1)*arg2
21 modulate with add invert alpha from arg1, output = (1-arg1)*arg2 + alpha1
For stage 0 the modulation operation (code 4) is set as a default setting, the other stages being switched off (code 1).
Not all operations are supported by every interface and videocard. The OpenGL interface enables to carry out the argument choice and modulation operations (operations 1 through 4) only, the argument can be the object color or texture. The alpha channel operations are ignored. The DirectX 5 interface supports, besides operations quoted for the OpenGL, the addition (7) operation. Operations 5, 6, 8 and 9 are replaced by operations 4 and 7. A full support of operations exists only for the DirectX 6 through DirectX 8, depending on whether the operations are supported by the videocard. If the desired operation is not supported by the videocard, then a better option can be the use of a software driver that supports most of the operations.

Full Html Context Help of The Peter - Gemtree Software & Children Programming