blending of particle effect

So I've got my particle system up and running and it looks great as long as the background is dark. My problem is that I need to render the effect on light colored backgrounds to. I've been trying lots of different settings to glBlendFunc but can't figure out how to get it working. My current blending is glBlendFunc(GL_SRC_ALPHA, GL_ONE) and you can se the not so satisfying result in the image below. How do I render the effect on light colored backgrounds?

illustration of the question http://babelstudios.se/stackoverflow/blended-particle-effect.png


If you have a normal ol' texture with alpha, and you're rendering in back-to-front order, this is the way to go:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

If your texture has premultiplied alpha, and you're rendering in back-to-front order, do this instead:

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)

From opengl.org

You might want to use the alpha values that result from texture mapping in the blend function. If so, (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) is always a good function to start with.

However, if you want blending to occur when the primitive is texture mapped (ie, you want parts of the texture map to allow the underlying color of the primitive to show through), then don't use OpenGL blending. Instead, you'd use glTexEnv(), and set the texture environment mode to GL_BLEND. In this case, you'd want to leave the texture environment color to its default value of (0,0,0,0).

链接地址: http://www.djcxy.com/p/31828.html

上一篇: 我们可以使用什么来代替OpenGL ES中的混合?

下一篇: 粒子效果的混合