Transparency 1 - Blending

Bryson R. Payne, M.Ed.

Transparent yellow teapotDiscussion:

Blending can be used in a number of creative and effective ways in OpenGL programs. Simplest of all is the effect of making objects transparent - this simply requires enabling GL_BLEND and using a 4-component color in place of a 3-component one, where the fourth component is an alpha (or opaqueness) value. Low alphas will be seen faintly (such as rays of light, glass, or water), and high alphas will be well-defined but translucent (like jello or a ghost). One important note on transparency - the order in which objects are drawn on the screen matters. Objects closer to the viewer should be drawn last so that the transparency computation includes objects in the background. To see how this manifests itself at run time, notice the handle of the teapot - the rest of the teapot is visible through the handle, but the handle is not visible behind the teapot. This is because the handle is drawn after the body of the teapot. Take this into account when designing scenes with transparent objects. 

Sample code:

Click here to see the sample code: blending.c

Executable example:

Click here for a running demo: blending.exe


Back to Main Tutorial Page

Last modified December 11, 2000, Bryson R. Payne, bpayne@ngcsu.edu