views:

149

answers:

2

With modern hardware, what is the fastest way to draw an image with a "bitmask", i.e., a mask that specifies whether a given pixel will be drawn or not (this could be extracted from "magic pink" pixels, for example) using OpenGL?

Should I just use alpha blending and set invisible pixels to a=0? Should I use the old "AND black/white mask then OR image on black bg" technique? Should I use the alpha pass test? Should I use a shader?

This matters because I'm planning on drawing massive quantities of such images - as much as I can afford to.

+1  A: 

If the mask and the texture are always the same (e.g. for splatting), you probably should use blending with a pre-multiplied color values. This usually is just saturated adding the texture with the background (no need to multiply per-pixel).

beef2k
TomF's tech blog at http://home.comcast.net/~tom_forsyth/blog.wiki.html has a really good explanation of this technique - see the article on Premultiplied Alpha.
Nathan Monteleone
A: 

You should definitely use the alpha pass test - by default it's set to something like >0.08, so you'll automatically get this if you set your pixels to 0.0 alpha.

Nathan Monteleone