next up previous contents
Next: 8.2 Advanced Blending Up: 8. Blending and Compositing Previous: 8. Blending and Compositing

8.1 Compositing

The OpenGL blending operation does not directly implement the compositing operations described by Porter and Duff [79]. The difference is that in their compositing operations the colors are premultiplied by the alpha value and the resulting factors used to scale the colors are simplified after this scaling. It has been proposed that OpenGL be extended to include the ability to premultiply the source color values by alpha to better match the Porter and Duff operations. In the meantime, its certainly possible to achieve the same effect by computing the premultiplied values in the color buffer itself. For example, if there is an image in the color buffer, a new image can be generated which multiplies each color component by its alpha value and leaves the alpha value unchanged by performing a glCopyPixels() operation with blending enabled and the blending function set to (GL_SRC_ALPHA,GL_ZERO). To ensure that the original alpha value is left intact, use the glColorMask() command to disable updates to the alpha component during the copy operation.

David Blythe