Re: [AD] memory bitmap blending

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Wed, 2008-12-10 at 14:06 -0700, Trent Gamblin wrote:
> > Funny, I'd be all for option 2 because it means I can do something
> > without needing to learn how to use platform specific shaders (ie, I
> > can "just" use Allegro).
> >
> > I haven't thought about instances where I'd need alpha-alpha
> > blending, but on first thought it doesn't sound like it would be that
> > isoteric.
> 
> You can already do alpha alpha blending with the current api. It
> just won't work on d3d when drawing that way to the screen because
> d3d won't even let you set a backbuffer format that has alpha in
> it. It is a fairly esoteric thing to do though, the only use for
> destination alpha I can thing of is if you wanted to draw a scene
> inside of a shape or inside some text, but then the stencil
> buffer is better fit for the job.
> 

This is about drawing from one bitmap with alpha to another bitmap with
alpha though, not the screen (haven't looked yet how that works in
OpenGL). A use case would be, let's say you have one bitmap which is 50%
transparent red. And you have a sprite with alpha on it.

Now, you blit your sprite onto the other bitmap (and not to the screen).
What I would expect to happen is that areas where the sprite is fully
opaque, the target gets completely overwritten. Areas where the sprite
is transparent, the target is not touched. A pixel which is 25%
transparent on the sprite should result in a 75% transparent pixel on
the target, after blitting.

This has nothing to do with OpenGL's "destination alpha" (blending modes
like GL_ONE_MINUS_DST_ALPHA, which aren't even supported by most OpenGL
drivers I think), it just means that blending for the alpha channel is
separate from the color channel (in the example, additive for alpha but
alpha-blended for color).

It seems to be supported in OpenGL since 1.0 (except that I wouldn't
know how to draw to another texture with that). But anyway, DX probably
has something similar to glBlendFuncSeparate() - should search docs for
"separate alpha blending" or something.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/