next up previous contents
Next: 6.10 Billboards Up: 6. Texture Mapping Previous: 6.8.3 Implementing High Resolution

6.9 Transparency Mapping and Trimming with Alpha

The alpha component of textures can be used to solve a number of interesting problems. Intricate shapes such as an image of a tree can be stored in texture memory with the alpha component acting as a matte (1 where the image is opaque, 0 where it is transparent, and a fractional value along the edges). When the texture is applied to geometry, blending can be used to composite the image into the color buffer or the alpha test can be used to discard pixels with a 0 alpha component using GL_EQUALS test. To maximize performance, set the alpha test to GL_LESS and discard pixels with a small alpha value, for example less than .05. This way some more pixels are discarded that do not contribute significantly to the image.

The advantage of using the alpha test instead of alpha blending is that blending typically degrades the performance of fragment processing. With alpha testing fragments with zero alpha are rejected before they get to the color buffer. A disadvantage of alpha testing is that the edges will not be blended into the scene so the edges will not be properly antialiased.

The alpha component of a texture can be used in other ways, for example, to cut holes in polygons or to trim surfaces. An image of the trim region is stored in a texture map and when it is applied to the surface, alpha testing or blending can be used to reject the trimmed region. This method can be useful for trimming complex surfaces in scientific visualization applications.


next up previous contents
Next: 6.10 Billboards Up: 6. Texture Mapping Previous: 6.8.3 Implementing High Resolution
David Blythe
1999-08-06