Advertisement Jump to content
Sign in to follow this  

preserving alpha in blend

This topic is 2432 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well I seem to be having some trouble trying to get my multipass render to work. I have 3 passes: light, diffuse, glow.

I first draw the light and than render the diffuse on top of it and modulate it. The alpha channel of the diffuse render contains the mask for the glow so I try to preserve it with glBlendFuncSeparate but it doesn't seem to work. I know the alpha channel is good as I can change the blend of the diffuse to do an alpha test and the correct parts are transparent. When I use it on the glow, it does not work.

// ** draw lightmap here **

glEnable( GL_BLEND );

// take the color of the lightmap and multiple it by the diffuse
// destroy previous alpha while maintaining source's
glBlendFuncSeparate( GL_SRC_COLOR, GL_ZERO, GL_ONE, GL_ZERO );

// ** draw diffuse here **

glDisable( GL_BLEND );

glEnable( GL_BLEND );

// mask using diffuse's alpha while keeping colors intact
glBlend( GL_DST_ALPHA, GL_ONE );

// ** draw glow here **

glDisable( GL_BLEND );

I know that glBlendFunctSeparate might be the cause of the error but the syntax looks good, if I change the diffuse blend to glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) so I know the alpha is good but still for some reason it is reset to 1 when I do the glow draw.

Thanks for any help !

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!