next up previous contents
Next: 12.5 Using Multisampling Up: 12. Transparency Previous: 12.3 Sorting

   
12.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 6.10), in which a rectangle is turned to perpetually face the eye point.

Like polygon stippling, the alpha function discards fragments instead of drawing them into the framebuffer. 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.


next up previous contents
Next: 12.5 Using Multisampling Up: 12. Transparency Previous: 12.3 Sorting
David Blythe
1999-08-06