• Advertisement
Sign in to follow this  

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

Recommended Posts

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!

Edited by getBrain();

Share this post


Link to post
Share on other sites
Advertisement

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

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

Edited by getBrain();

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Advertisement