PDA

View Full Version : Blending texture background bug.



pixelita
01-19-2011, 04:31 AM
Hi

I'm drawing bitmaps with transparent background.When the objects don't overlap each other then all is good, but when they overlap then there is some disturbance. I'm using

glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Is it right? My alpha value is from PNG alpha chanel.

Thanks.

Dark Photon
01-19-2011, 04:34 AM
Are you drawing the alpha objects back-to-front?

Generally speaking, if you want good multi-layer compositing (e.g. for alpha texture impostors), you're going to want to use pre-multiplied alpha. It's associative. That is (ONE, ONE_MINUS_SRC_ALPHA) blend function, with a texture that has already had the alpha pre-multiplied:

http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[Premultiplied%20alpha]]

pixelita
01-19-2011, 06:26 AM
Thanks, solved

I also forgot to add glDepthMask(GL_FALSE);