0
votes

When I using the Additive(glBlendFunc(GL_ONE, GL_ONE) ) to do the blending for the particle system, if where have a background it will looks perfect, but when I try without background, it will get the black color.
The result is when not background(RGBA(0,0,0,0)), the Additive will add the black color together, for example:
RGBA(0,0,0,1) + background(RGBA(0,0,0,0)) = RGBA(0,0,0,1);
so that is why I get the black color.

How to make it happen:

  1. Run in android without background, but have wallpaper.
  2. Using Fbo and Fbo clear color is RGBA(0,0,0,0), and with Translucent, then draw a bitmap to the Fbo with Additive.

Question: How to solve this problem, make the bitmap won't have black color, or how to avoid that when without background.

1
Could you maybe provide a visual example of what you are trying to achieve and what is going wrong?Reigertje
You example isn't great - if you add two black values, of course you get black ... can you provide a better example ...solidpixel

1 Answers

0
votes

I think that in order to solve your issue you need to use separate blending, which allows to use different factors on RGB and Alpha component.

Currently you have something like this :

glBlendEquation(GL_FUNC_ADD);
glBlendFuncSeparate(GL_ONE, GL_ONE);

You should try with this instead :

glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
glBlendFuncSeparate(GL_ONE, GL_ONE, GL_ZERO, GL_ONE);

And this should give you the following result :

RGBA(0,0,0,1) + background(RGBA(0,0,0,0)) = RGBA(0,0,0,0);

Because internally it will do something like :

result.rgb = src.rgb * 1.0 + dst.rgb * 1.0 = src.rgb + dst.rgb
result.a = src.a * 0.0 + dst.a * 1.0 = dst.a

So basically this will preserve the destination (never change it) while doing additive blending on RGB components.

glBlendFuncSeparate is supposed to be supported starting with OpenGLES 2.0, so it should be supported on most mobile devices.