Hi,
I'm creating a simple frame buffer trail effect but I'm finding the alpha blending is not working how I would expect. Perhaps I'm misunderstanding how things are composited?
Here is a simplified example which draws a rect at startup, then draws black over it with low opacity every frame so it fades away. Except it doesn't fade all the way – it stops getting visibly darker and just stays there.
Can anyone explain what's going on?
Thx!
void ofApp::setup(){
// Create FBO
everythingFbo.allocate( ofGetWindowWidth(), ofGetWindowHeight() );
// Draw a white rect on black in it
everythingFbo.begin();
ofClear( 0 );
ofSetColor( 255 );
ofDrawRectangle( 100, 100, 200, 200 );
everythingFbo.end();
}
void ofApp::update(){
// Nothing
}
void ofApp::draw(){
// Darken everything in the FBO a bit every frame
everythingFbo.begin();
ofSetColor( 0, 2 );
ofDrawRectangle( 0, 0, everythingFbo.getWidth(), everythingFbo.getHeight() );
ofClearAlpha();
everythingFbo.end();
// Draw the FBO
ofSetColor( 255 );
everythingFbo.draw( 0, 0 );
}
`