PDA

View Full Version : alpha blend with an extra alpha.



alh
01-19-2005, 05:40 AM
Hello!

I'm looking for a way to blend a source texture containing an alpha channel, onto the framebuffer, modulated by an extra alpha.
that is, insted of just
dst = a*src + (1-a)*dst
I need:
dst = (a1*a2)*src + (1-(a1*a2))*dst;
where a1 is the texel alpha value, and a2 is a constant value for the whole texture.

How can I achive this using OpenGL ES 1.0?

[ January 19, 2005: Message edited by: Olof Hedman ]

bentlegen
01-19-2005, 06:38 AM
Set flat color shading and call glColor4f(1.0f, 1.0f, 1.0f, a2). This assumes you're blending with the frame buffer using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). Should blend according to your equation.

Edit: Oops, you'll also need glTexEnvf(GL_TEXTURE_ENV_MODE, GL_MODULATE).

- ben

[ January 19, 2005: Message edited by: bentlegen ]

alh
01-20-2005, 04:56 AM
Thanks!
It worked perfectly.