Dear community,
I’m working on a project where I need to blend FBO’s, but it’s not working out too well. The basic idea is to have a number of layers, all of which are filled with objects, and I want to be able to fade layers in and out. Every layer has a number of inputs so parameters can be controlled (from audio, or from external controls such as MIDI or OSC) and every layer has a setup(), update() and draw() function. In the main application, every layer is set up, updated and drawn.
Every layer has it’s own FBO, and the FBO is drawn like this:
void Layer::draw(){
ofSetColor(255, 255, 255, 255 * opacity);
fbo.draw(0,0);
fbo.begin();
// draw stuff
fbo.end();
}
I want the background of the FBO to be transparent, and if drawn objects inside a layers’ fbo have an opacity of <255, I want them to blend with whatever is behind them in the final composition of multiple layers.
If I use just one layer, without any FBO magic, everything is as expected. I called ofSetBackgroundAuto(false), and on every draw() I draw a bunch of ofCircles in the Layer::draw() method. A screengrab of the result is attached.
I tried calling ofSetBackgroundAuto(true), and implementing the Layer::draw() method like this:
void LayerOne::draw(){
ofSetColor(255, 255, 255, 255*opacity);
fbo.draw(0, 0);
fbo.begin();
//draw a bunch of circles
fbo.end();
}
If I clear the fbo (in the constructor, after allocating) with fbo.clear(1,1,1,0) I get a very faint output (see attached image #2). If I clear with fbo.clear(1,1,1,1), I get yet another version of the same visuals (attached image #3).
I’m using OF 0062 as I couldn’t get the github master to compile.
What I’d want is the output as seen on image #1 (without FBO’s) but using FBO’s to be able to do the blending. What am I doing wrong?
Cheers,
Daan
PS. the visuals seen on the attachment are not exactly the same, because they are generated by sound.
PPS. The forum says: “The upload folder is full. Please try a smaller file and/or contact an administrator.” Below are the images as hosted on imageshack.