next up previous contents
Next: 8.1 Compositing Up: Advanced Graphics Programming Techniques Previous: 7.6 End Caps On

   
8. Blending and Compositing

OpenGL provides a rich set of blending operations which can be used to implement transparency, compositing, painting, and other effects. Rasterized fragments are linearly combined with pixels in the selected color buffers, clamped to 1.0 and then written to the color buffers. The glBlendFunc() command selects the source and destination blend factors. The most frequently used factors are GL_ZERO, GL_ONE, GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA. OpenGL 1.1 specifies additive blending, but vendors have added extensions to allow other blending equations such as subtraction and reverse subtraction, and several of these extensions are standard commands in OpenGL 1.2, or are part of the ``imaging subset'' of OpenGL 1.2 (see Section 13.1.4).

Most OpenGL implementations use fixed point representations for color throughout the fragment processing path. The color component resolution is typically 5, 8, or 12 bits. Resolution problems usually show up when attempting to blend many images into the color buffer, for example, in some volume rendering techniques or multilayer composites. Some of these problems can be alleviated using the accumulation buffer instead, but the accumulation buffer does not provide the same flexibility for building up results and hardware accumulation buffer support is not as widely available as blending support.

OpenGL does not require that implementations support an alpha buffer (``destination alpha'') for storing alpha values like the other color components. For many applications this is not a limitation, but there is a class of multipass operations where maintaining the current computed alpha value is necessary.



 
next up previous contents
Next: 8.1 Compositing Up: Advanced Graphics Programming Techniques Previous: 7.6 End Caps On
David Blythe
1999-08-06