PDA

View Full Version : Alpha blending and masking.



plastichead
03-26-2003, 02:43 AM
In my app, I currently use alpha blending, just to achieve the normal effect of translucency (glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)).

In addition, I want to do some masking. Some portions of the screen should be opaque, some translucent. So, I guess I need something like an alpha mask, but without affecting my original blending I described above.

Is there a way to achieve this with destination alpha or some other method?

Thanks.

plastichead
03-26-2003, 01:57 PM
Additionally, I can say that I am using orthographic projection and do some 2D only. Maybe this helps.

Spudy
03-26-2003, 08:07 PM
You can use the stencil buffer.

plastichead
03-27-2003, 01:16 AM
Yes, but is there a possibility to do this with destination alpha? Or what are example applications for destination alpha?

Thanks.

Orzech
03-27-2003, 12:06 PM
Try looking at Nehe Tutorials. There is a good tutorial about using of alpha mask and effect of transparency. Meaby it's worth looking at.

Orzech

fringe
03-28-2003, 01:14 AM
Hi,

I haven't really done much alpha stuff but can't you change the blend mode after you have drawn the stuff using the first blending mode to a different more useful one then switch back again?

fringe

plastichead
03-28-2003, 01:54 AM
Well, my problem is how do I apply the alpha mask to the image? E.g. when I first draw the whole scene (which is actually 2D only) then I could switch to a different glBlendFunc() that uses destination alpha and draw a big rectangle over the whole scene. This would apply the alpha mask.

The problem with this approach is it would lead to an effect that I do not desire. I would draw the whole scene first and then apply the alpha mask instead of applying the alpha mask everytime I draw a ... well, lets call it primitive. This would be possible with the stencil buffer, I know, but can you imagine an approach using destination alpha or some other method (except stencil buffer, I actually use it for various other things)?

This would help me a lot.