6.3 Color Blender

Now that we have explained how the coverage value is calculated, next we will talk about the blending process with the Blender. The Blender, like the Combiner, performs linear arithmetic on values obtained from a number of input sources to determine the color for output.

Color = (p * a + m * b) / (a + b)

In this expression, p and m are the colors for blending. You can change the colors that will serve as the basis for mixing by selecting specific input sources. The coefficients a and b are the alpha values. The extent of blending of p and m is adjusted according to these values.

The usable input source colors are the same for p and m. The appropriate source is chosen from the list below:

 
Mux Select   Source
0 First cycle-pixel's RGB
Second cycle-the blended RGB from first cycle
1 RGB in memory
2 Blend(register's)RGB
3 Fog(register's)RGB

In contrast, the usable input source for a and b are different from one another. This is due to the fact that they are blend coefficients. Often values of (b = 1 - a) are used.

 A Mux input source
 
Mux Select   Source
0 Color Combiner's output alpha
1 Fog (register's) alpha
2 Shade alpha
3 0.0

 B Mux input source
 
Mux Select   Source
0 1.0 - a mux output
1 Alpha in memory (coverage value)
2 1.0
3 0.0

The difference between the Blender and the Combiner is that the Blender can use the framebuffer RGB and the framebuffer alpha as input sources. In other words, with the Blender, a new polygon can be rendered and blended while another polygon is being drawn. Also, the Blender output does not necessarily have to be written back to the framebuffer, but sometimes can be removed if there is no need to write back the result of Z buffering. The blend result can also be removed sometimes when alpha comparing.

In the case of the Combiner, the linear arithmetic coefficients are in essence the combine mode. In the same way, it would seem plausible that you could call these linear coefficient settings the rendering mode. Actually, the rendering mode is more complicated than the combine mode, and the term refers to not only the p, m, a, and b input sources, but also a number of flag settings relating to anti-aliasing and Z buffering.

A review of the role of all of these flags is beyond the scope of this tutorial. You can read the details in Chapter 15 of the Programming Manual. Here we will only cover the number of rendering modes that have already been defined in <gbi.h>.