Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Texture edge transparency issue

I'm making a drawing software, I've almost improved the brushes to a decent level of both performance and looks, however I have one last problem. To obtain the performance I was looking for (multiple undo/history levels) I had to draw every shape to a texture and use that texture on a simple 4 vertices poly. All went well, the performance is awesome and the looks great (especially after I've enabled multisampling) Still, somewhere in the process of drawing the texture in a separate framebuffer, a contour surrounds each object like in the image below. I've observed that the colour of the contour is the same as the one in glClearColor. I suspect is the blending? I use

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 

But not sure. How can I get rid of the contour?

enter image description here

like image 284
Meda Avatar asked Apr 24 '26 00:04

Meda


1 Answers

Try to use premultiplied alpha for the blending:

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

For this to work with any colour you should also clear the colorbuffer in which you'll draw the texture like this:

glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);

However, this will probably cause problems if you have translucent parts.

like image 93
Rad'Val Avatar answered Apr 26 '26 22:04

Rad'Val



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!