Advertisement

Painting into FBO by texture brush. Issue with collecting alpha.

Started by May 12, 2017 12:35 AM
0 comments, last by getBrain(); 7 years, 6 months ago

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:

brush.png

Strange behaviour:

exxample1.jpg

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:

brush2.png

Seems to me I'm making a global mistake. How I can solve it. Thank you!

0 views.(( Hmm, may be I posted it in wrong place?

UPD: Oh,sorry 167. But no replyes! ))

This topic is closed to new replies.

Advertisement