Motion blur and artifacts
Since the accumulation buffer is insanely slow I decided to achieving some motion blur-effects by rendering my scene and copying the framebuffer to a texture. Next frame, switch to ortho mode and render a quad textured with said texture over the entire screen at 0.9 alpha, then once again copy the framebuffer to the same texture. Repeat as long as motion blur-effects are turned on.
While this performance-wise seems to work pretty well and gives almost exactly the same visual result as the accum buffer, all objects leave a faint trail of its own color on the black background. The blending equation used is GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA.
Does anyone have any ideas about how to eliminate that trail while still maintaining the motion blur-effects?
(ONE,ONE) doesn't 'fade away' with time.
With (SRC_ALPHA,ONE_MINUS_SRC_ALPHA), old frames decay as new frames are rendered on top of them, with (ONE,ONE) the new frame is just layered on top of the old ones without any decay.
With (SRC_ALPHA,ONE_MINUS_SRC_ALPHA), old frames decay as new frames are rendered on top of them, with (ONE,ONE) the new frame is just layered on top of the old ones without any decay.
Oh I know that problem, what I did to overcome it is instead render an alpha blended black screen quad over the scene like this:
Then I copy the result to a texture, and this is what I use for the trails. This way the fade is a linear function where FADE_RATE is the number of seconds it takes for the trail to disappear. Then I just draw the scene normally for the next timestep, and layer the trail texture overtop using glBlendEquation(GL_FUNC_MAX);
btw, BlendEquation is an extension.
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);glBlendFunc(GL_ONE, GL_ONE);glBindTexture(GL_TEXTURE_2D, 0);glBegin(GL_QUADS); float Fade=TimeStep*FADE_RATE; glColor4f(Fade, Fade, Fade, Fade); glVertex2f( 1, 1); glVertex2f( 1, -1); glVertex2f(-1, -1); glVertex2f(-1, 1);glEnd();
Then I copy the result to a texture, and this is what I use for the trails. This way the fade is a linear function where FADE_RATE is the number of seconds it takes for the trail to disappear. Then I just draw the scene normally for the next timestep, and layer the trail texture overtop using glBlendEquation(GL_FUNC_MAX);
btw, BlendEquation is an extension.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement