View Full Version : Masking and Transparency with Blending

02-22-2010, 05:22 PM
I have a 2d openGL scene set up with a lot of texture mapped polys. I'm already using blending for pngs with transparency, using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), or glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR) for some images to get some neat additive blending.

Now I'm trying to also mask these by blending similar to what the nehe tutorials (#20) say for masking. Is it possible to do this and still preserve the transparencies I have set up?

I'm having trouble applying a mask, and have parts of the image still transparent as well as the mask cause transparency in other parts. What I'd like is something like:


Everything I've tried thus far, I end up with large areas of the mask being visible, or losing the transparencies I want to keep.

Am I doing something wrong here, is it not possible to do masking with my current blend modes, or am I missing something?