How to simulate motion blur?

Hi
I need to simulate motion blur like the game “NFS Most Wanted”. How to simulate such effect? I had read a simple article about simulating the motion blur technique using accumulation buffer(It was not so useful for me). At the time of reading that article, there were no hardware support for accumulation buffer. So what’s the best way to simulate motion blur?
-Ehsan-

Accumulationbuffer motionblur is supported by any GPU that support DX9. The Accumulationmotionblur has the advantage, that the idle time will be used.
Use that if you are a beginner. You can add motionblur to any game with 20 lines code (for example to the quake3 engine)

Other ways are per pixel motionblur (a shader takes many samples) or a postrendereffect: A second rendertarget is used for storing the speed vectors. A post rendering filter blurs the picture with that data. This both techniques aren’t something for beginners.

Accumulationbuffer motionblur is supported by any GPU that support DX9.
Are you sure?

Remember that I don’t use DX. I use OpenGL’s accumulation buffer. What version of OpenGL supports accumulation buffer with hardware?
-Ehsan-

Originally posted by Ehsan Kamrani:
Remember that I don’t use DX. I use OpenGL’s accumulation buffer. What version of OpenGL supports accumulation buffer with hardware?
-Ehsan-

All that support the accumulation buffer, which is 1.0 if i am not mistaken, the openGL version does not have anything to do with hardware support of the accumulation buffer, it’s the hardware itself that has to support it, if it doesn’t it is run in software.

AFAIK (read it somewhere), accumulation buffers are now accelerated on most modern hardware (e.g., ATI 9500 and NV GeforceFX hardware, or better?).

A few nice demos using the accumulation buffer (and a lot more):
http://www.opengl.org/resources/code/samples/glut_examples/advanced/advanced.html

Yup, cards up GF FX d0 support fast accumulation buffer. Actually, every card capable of using shaders will most probably have hardware accelerated accumulation buffer.

caveman > those examples are nice although a bit strange, when lauching them they ask for glut.dll, glu.dll and opengl.dll instead of glut32.dll, glu32.dll and opengl32.dll

also, in case you’re using a postprocessing framework like the one described on gamasutra.com by Marko Kylmamaa, can the accumulation buffer be of any use ?

That examples moves the sphere a bit in “each for loop” and adds it to the accumulation buffer. But in my game, I need to get the information of the last frames, add them to the accumulation buffer as well as the current frame and return the results to the color buffer.Is it a good idea to save the previous frames(As an example 5 frames) to a tga file and load them to the accumulation buffer?(They are 2D images, but the current frame is a 3D scene ).
-Ehsan-

You need to render an integration of the blurred object for the duration of the frame being rendered.

There are many ways to do this.

  1. You can convolve using a post process stage using motion vectors at the fragment shader level.

  2. You can draw the object many times with blending in some cases.

  3. You might be able to use the alpha to mask capability to make 2 simpler to implement or more generally applicable.

  4. You could render to texture then use blending to accumulate the image of the object on the screen.

  5. Depending on the blurred object you can generate blur geometry for fast moving stuff and render that with blending, for example insect wings, helecopter blades, swords, light sabers and spheres and particle systems are good candidates for this and tend to be drawn this way.

  6. You can use shaders to shade motion blur into the filled portion of an object, moving terrain or is a good candidate for this type of shader based direct rendered convolution.

The method you chose depends heavily on the platform targeted, the performance requirements and the types of things you want to blur, e.g. full scene, a few 3D objects in the scene a few simple objects or object parts in the scene or a particle effects system.

Most motion blur in games is wrong/crap, because they integrate inter-frame rather than intra-frame. This can be cheaper for full screen because you render a series of frames anyway but you can usually see discrete frames, it looks “kinda cool”, and it exaggerates the effect so it catches on. It is also intrinsically more tricky to correcty render the right intra-frame motion blur over several frames with a variable frame rate.

I decided to use the “render to texture” technique to simulate the motion blur effect. I don’t get good results with low FPS, since I use the timer and render the objects based on the timer value. With low FPS, the previous object’s positions in last frames are not near the current object’s positions of the current frame. How to solve this problem?
-Ehsan-

Most racing games I have seen use even simpler methods :

Instead it is simply image based : render your scene once to texture, then apply a radial blur when rendering it.
Also you can offset the radial blur center to left when the cars turns left etc.

As you can see on this NFSMW picture, even the distant buildings have this radial blur, it is not realistic but “good enough” for fast racing :slight_smile: http://img.jeuxvideopc.com/images/articles/935/6243/grandformat/4338.jpg
The player car is blurred too, and that is a stupid mistake, they should have rendered it unblurred…

Currently I’m playing this game. The motion blur effect is so interesting.That is why I again replied to this old topic.
What about the method that I have used? It depends on the last frames and you have not responsed to my problem yet :wink:

Yes I did.
You can’t really solve it, it is a performance problem, and you already have low FPS as you say. The real solution is to store multiple renderings with the same frame time, and blend them together.
ex :
screen rendering : 60 FPS
FBO rendering : 600 FPS
blend ten consecutive FBOs to screen to get intra-frame motion blur.
You can play with my (messy but working) true motion blur implementations here, dates back from before FBO even existed :
http://www.chez.com/dedebuffer/

In my previous post I pointed you to the exact solution used in your beloved game.

What more to you want to know, precisely ?

In NVIDIA SDK, you can find a demo application.

http://developer.nvidia.com/