Jump to content
  • Advertisement
Sign in to follow this  
Valderman

Motion blur and artifacts

This topic is 5119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Surely you should use (ONE, ONE) for the blend modes ?

Share this post


Link to post
Share on other sites
(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.

Share this post


Link to post
Share on other sites
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:


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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!