next up previous contents
Next: 10.5 Using Multisampling Up: 10 Transparency Previous: 10.3 Sorting

10.4 Using the Alpha Function

 

The alpha function is used to discard fragments based upon a comparison of the fragment's alpha value with a reference value. The comparison function and the reference value are specified with the command glAlphaFunc(). The alpha test is enabled with glEnableGL_ALPHA_TEST(GL_ALPHA_TEST).

The alpha test is frequently used to draw complicated geometry using texture maps on polygons. For example, a tree can be drawn as a picture of a tree on a single rectangle. The parts of the texture which are part of the tree have an alpha value of 1; parts of the texture which are not part of the tree have an alpha value of 0. This technique is often combined with billboarding (Section 5.7), in which a rectangle is turned to perpetually face the eyepoint.

Like polygon stippling, the alpha function discards fragments instead of drawing them into the frame buffer. Therefore sorting of the primitives is not necessary (unless some other mode like alpha blending is enabled). The disadvantage is that pixels must be completely opaque or completely transparent.



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