Hi there!
I've a little experience with OGL and I never worked with blending so close. I try to make a paint app and I work with FBO and brush with simple transparent texture of blurred disk. When I stop a brush my new alpha from a brush accumulate into a FBO during game loop and hence highlights so much color. It looks like a ink collects on paper when stop a pen. Seems to me blending should corrects this behaviour but no. I tried millions combination of alpha blending, blending equation, I try pre/nonmultiplied texture, but everytime I get the same or almost the same result.
My brush:
Strange behaviour:
My game loop:
glEnable(GL_BLEND);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0, 1.0, 1.0, 0.0);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBindFramebuffer(GL_FRAMEBUFFER, FBO);
brush.setPos(mousePos, brush, shaderBrush);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0, 1.0, 1.0, 0.0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
renderScreenQuad(FBOtexture, shaderBuff);
Both shaders are premultiplied! If I use:
glBlendEquationSeparate(GL_FUNC_ADD, GL_MAX);
into FBO, strokes looks better,but alpha on edges of brushes conflicts with each other. And no matter pre or nonmultiplied texture. It's bad solution:
Seems to me I'm making a global mistake. How I can solve it. Thank you!