Alpha Testing

Optimizations, Rendering Methods | Tuesday 30 September 2008 4:08 pm

When drawing for example lots of vegetation (with textures containing an alpha channel) you need to minimize overdraw and cost for each draw call. If you use blending for archiving the desired transparent effect on the leaves then you will need to sort all the triangles (back-to-front-order) to draw, (and sometimes this needs splitting of triangles) to get the correct look. Also when blending you might render the same pixel multiple times because you want the result to blend together. All this drawing and sorting takes a lot of time and a better way is to do alpha testing. In alpha testing (or alpha killing) you select an alpha threshold and all pixels with an alpha above (if you use GREATER as test function) this threshold will be drawn. Because no blending occurs, you don’t need to sort the triangles anymore (but preferably you will sort them front-to-back-order for optimization) . The drawback with alpha killing is that you will get sharp edges around the pixels drawn.
Alpha killing does not work with shadow volumes.

Alpha testing in OpenGL
http://opengl.org/documentation/specs/version1.1/glspec1.1/node96.html

Alpha testing in DirectX9 (in DirectX10 you must do your own implementation in a shader)
http://msdn.microsoft.com/en-us/library/bb172254.aspx

 

Please share:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Current
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • StumbleUpon
  • Twitter
  • Reddit
  • Technorati
  • Yahoo! Bookmarks

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment