View Full Version : fast fading
12-24-2003, 04:14 PM
I have a particle system that is constantly moving and drawing to the screen. I am not erasing the background each pass, so the buffer naturally adds up to white over time. I would like to keep this, however, I would like the older trails of the particle to fade out over time so it doesn't keep adding up, but rather lasts for a while.
An idea I had was to clear the buffer with an alpha value, so that every frame it would paint the background color over the frame with an alpha of say 0.1f This, I believe would give that effect, but couldn't figure out how to do it any other way than drawing a full screen quad, which really hurt my rendering time. Can clear() do this somehow or is there a faster way to fade this?
12-24-2003, 05:34 PM
I don't think that drawing _one_ full screen quad each frame will affect performance significantly. just try..
well I do so and it doesn't cost anything..
12-24-2003, 06:16 PM
The other problem is with double buffering the trails aren't guaranteed, i.e. with a swap the back buffer contents are not guaranteed. Some implementations may show you the last frame others two frames ago (especially in fullscreen mode), and others still may not show you either.
It'll probably work on most if not all systems but on many the particle trails will flip flop each frame between two sets that compliment each other showing every other particle. That'll be OK if the particles don't move much between frames.
12-25-2003, 07:47 AM
the "brute force" solution would be simply to have more particles, i.e. to let the "old trails" be part of your paticle system. one particle could not be "one particle", but for example an array of ten particles that you update, with every frame the oldest one dropping out and adding a new one at a new position and all other ones color is faded. But that would slow down the program as you have 10 times as many particles to manage.
A solution to the bufffer swapping problem could be rendering the particles not to framebuffer, but to a texture, which basically contains the screen contents (particles only) and gets mapped orthogonally on the full screen (one large quad), with a process like this:
1. clear framebuffer
2. draw one screen sized quad with the existing particle texture
3. update it (fade, add new particles)
4. copy screen contents to particle texture
5. clear screen again
6. draw everything else
7. map the particle texture to screen (as in 2)
I think I would choose thie technique, although resolution suffers, as the quad texture have to be 512x512 or 256x256 texels and gets mapped to the full screen (see my water reflections, http://de.geocities.com/westphj2003/refl.html , the reflection on the water shows this effect).
A somewhat related question : http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/014812.html
Depending on your needs, the simple solution is to use single buffer (instead of double buffer).
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.