I have OpenGL application which blends colors based on the following settings:
glBlendEquationSeparate( GL_FUNC_ADD, GL_FUNC_ADD );
glBlendFuncSeparate( GL_ONE, GL_ONE, GL_ONE, GL_ONE );
In the same way I would like blend two textures in the fragment shader. Does the above blending settings translate to the simple addition:
vec4 colorA = texture( samplerA, texCoords );
vec4 colorB = texture( samplerB, texCoords );
vec4 colorC = colorA + colorB;
?
The resulting formula of
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD); glBlendFuncSeparate(GL_ONE, GL_ONE, GL_ONE, GL_ONE);
is
dst.rgb = 1 * src.rgb + 1 * dst.rgb
dst.a = 1 * src.a + 1 * dst.a
Blending is very different from computing colors in the fragment shader.
In this case, the current fragment color (and the alpha channel) is added to the fragment color (and the alpha channel) in the framebuffer. So yes, you can think of it as colorA + colorB
.