Advertisement Jump to content
Sign in to follow this  
getBrain();

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

This topic is 622 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!