blending in fbo

Hi, everyone!

I have a problem with blending semitransparent textures while drawing them in fbo. I need to draw such scene: some image in background blended with transparent fbo. Fbo consists of transparent brush textures. I need to get image where brush overlay background image. What type of blending should I use?

Add screenshots: first is what I want to get, second is what I get.

Alexei.

To get the result in the first image you just need normal alpha blending; in the second image it looks that the color of your brush strokes have an alpha value <255 (or 1.0 depending on how you describe your colors :slight_smile: )

It looks that your brush strokes are done drawing multiple circles, so here’s an example that draws a simple white dot:

  
  
...  
fboStrokes.allocate(w,h,GL_RGBA);  
...  
fboStrokes.begin();  
ofClear(0,0,0,0);  
ofSetColor(255,255,255,255);  
ofCircle(100,100,20);  
fboStrokes.end();  
...  
bgImg.draw(0,0,w,h);  
fboStrokes.draw(0,0,w,h);  
  

the problem was i should make separate blending inside fbo like this:

glEnable(GL_BLEND);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,GL_ONE,GL_ONE_MINUS_SRC_ALPHA);
///draw here
glDisable(GL_BLEND);