OpenGL ES - Blending Particle Effect

So my particle system is up and running, and it looks great if the background is dark. My problem is that I need to render the effect on a light background. I've tried many different settings for glBlendFunc but can't figure out how to get it to work. My current blending is glBlendFunc (GL_SRC_ALPHA, GL_ONE), and you can see a not very satisfying result in the image below. How to make an effect on a light background?

illustration of the question
(source: babelstudios.se )

+2


source to share


2 answers


If you have a normal ol 'texture with alpha, and you are rendering in reverse order, this is the way to go:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

      



If your texture has a pre-multiplied alpha and you are rendering in reverse order, do this instead:

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)

      

+3


source


From opengl.org



You might want to use the alpha values ​​that are the result of the texture conversion into 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 textured (i.e. you need parts of the texture map to provide the primitive's foreground color to show) then don't use OpenGL blending. Instead, you should use glTexEnv () and set the texture environment mode to GL_BLEND. In this case, you want to leave the texture medium color at the default (0,0,0,0).

0


source







All Articles