next up previous contents
Next: 6.1 Compositing Up: Programming with OpenGL: Advanced Previous: Trade-offs Between 3D and

8.4 Blending

 

OpenGL provides a rich set of blending operations which can be used to implement transparency, compositing, painting, etc. Rasterized fragments are linearly combined with pixels in the selected color buffers, clamped to 1.0 and written back to the color buffers. The glBlendFunc() command is used to select 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.

Most OpenGL implementations use fixed point representations for color throughout the fragment processing path. The color component resolution is typically 8 or 12 bits. Resolution problems typically 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 richness of methods for building up results.

OpenGL does not require that implementations support a destination alpha buffer (storage for alpha). 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.





David Blythe
Thu Jul 17 21:24:28 PDT 1997