Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Draw multiple textures with additive alpha



All suggestions have been helpful. I now have one additional snag. The following does indeed blend two textures of varying opacity while managing 100% opaqueness (transition between two textures). What this will not allow is if one/both texture(s) has an alpha channel. So, if I have a bottom layer, "vid_A" covers the entire image even if "vid_A" is a logo on a transparent background (for example). 

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
...draw bottom layer (solid color)

[vid_A bindCurrentTexture];
glBlendFunc(GL_SRC_ALPHA, GL_ZERO);
[vid_A compositeChannelInRect:theRect];


[vid_B bindCurrentTexture];
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
[vid_B compositeChannelInRect:theRect];


_______________

Rich Salvatierra

678.438.4592 [mobile]

770.992.4004 [home]


On May 17, 2008, at 9:40 AM, Jean-Francois Roy wrote:

The default blend equation for both RGB and alpha is additive (GL_FUNC_ADD). So all you need to do is set up the blend functions.

See http://opengl.org/sdk/docs/man/xhtml/glBlendEquation.xml and http://opengl.org/sdk/docs/man/xhtml/glBlendFunc.xml for all the details. There are separate variants to both these calls in case you need different blending factors or equations for the color components and the alpha component.

Also, from what you wrote, I understand you do not want the background to show at all during the transition. That is, you are drawing two textured quads and whatever is behind those two quads should not appear on screen. In that case, for the first quad the blend function should be

glBlendFunc(GL_ONE, GL_ZERO);

which will essentially ignore the source alpha (or you can set the front color to (r, g, b, 1) and draw the color values at full intensity. You may also simply turn off blending entirely.

For the second quad, use

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

which will result in linear interpolation of the color values between the first and the second quad as you interpolate the alpha component of the front color.

On May 16, 2008, at 15:37, Richard Salvatierra wrote:

The opacity of the two textures does not remain 100% during this transition revealing the background. I think I need to COMBINE or ADD the alpha but not sure how to accomplish this.
I have searched the list and google but can not find the solution. Any suggestions?


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden

References: 
 >Draw multiple textures with additive alpha (From: Richard Salvatierra <email@hidden>)
 >Re: Draw multiple textures with additive alpha (From: Jean-Francois Roy <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.