Screen space motion blur on the gpu (2011)

View Source Code

Motion blur adds to the "realism" of animation by enhancing the illusion of speed but is a costly effect to calculate. This project attempts to improve and speed up Image space motion blur using CUDA. Image space motion blur is a short cut to apply motion blur as a post process to an image of the scene based on object velocities.


I am using OpenGL and GLSL to create the rendering and velocity data and vbo objects for displaying the geometry. CUDA is then used for blurring the image by the screen space vector.

The basic steps are:
-render the scene to the frame buffer
-create a velocity map (x, y velocity in screen space, length in z channel)
-map the float velocity and colour texture so that its memory is accessible from CUDA
-run CUDA to blur the image based on velocity vectors
-copy result back
-display the texture with a full screen quad

A screen shot of the running program


A right mouse menu in the window shows all the user settable options which are:

  • ·Enable CUDA or GLSL [space bar]
  • ·animate [a]
  • ·Toggle cube/ship [c]
  • ·Render only [r]
  • ·Velocity only [v]
  • ·Decrease number of samples [n]
  • ·Increase number of samples [m]
  • ·Increase blur scale [+]
  • ·Decrease blur scale [-]
  • ·Reset timer [t]

A screen shot of the running program


The following resources helped me to develop the code:


  • ·Ship loader and model from CS175 class
  • ·CUDA Sdk examples: PostProcessGL and SimpleGL
  • ·Cg motion blur code demo code from NVIDIA (i translated to GLSL)


screen space blur

using CUDA and GLSL