I made a particle trail effect in OpenGL.
The trick is to draw a semi transparent rectangle on the screen to gradually fade the previous frame:
ofSetColor(0,0,0,255*(1.0-persistence)); ofFill(); ofRect(0, 0, ofGetScreenWidth(), ofGetScreenHeight());
and then draw the particles (roughly):
ofEnableBlendMode(OF_BLENDMODE_ADD); ofEnablePointSprites(); vbo.draw(GL_POINTS, 0, (int)points.size()); ofDisablePointSprites();
The problem is that the trails do not fade until being pure black, but remain grayish.
I could threshold the dark gray values, or fade them progressively, but what is the best way to do it? OpenGL blending functions/operations or shader? Speed is a major concern.