Quantcast
Viewing all articles
Browse latest Browse all 40524

FboTrailing example with transparent background

In the examples folder there is an ofApp that creates a trailing effect by blending several ofFbo renders without calling ofClear. It uses ofDrawRectangle with a given color and a fadeAmount as alpha.

Is it possible to make the same but with a completely transparent background? Any openGL hack that allows this?

One solution I've thought is having

vector<ofFbo> fbos( fadeAmount );

Then at every loop of my application iterate over one of those FBOs and do:

// Main OF loop begin
//
fbos[current].begin();
ofClear(0); // Completely clear
... // Draw stuff for trailing effect
fbos[current].end();

// Draw all fbos on top of each other
screenFbo.begin();
for(ofFbo& fbo : fbos)
{
    fbo.draw(...);
}
screenFbo.end();
screenFbo.draw(...); // Final result from all fbos
if(current++ == fbos.size()) current = 0;
//
// Main OF loop end

I haven't tested this but I believe it should work using the correct blend mode, however it is extremely costly regarding the amount of FBOs required. Something tells me there must be a better way...Might not?

Cheers


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>