OpenGL Additive blending get issue when no background
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:
Question: How to solve this problem, make the bitmap won't have black color, or how to avoid that when without background.
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.
链接地址: http://www.djcxy.com/p/31842.html上一篇: 是否有可能包含一个CSS文件在另一个?