[shader] MotionBlur Filter

Yo all.

I know there already exists a thread on this topic (here), but I didn’t want to necro the thread. Plus I feel this is a cleaner presentation anyways.

So my project requires a MotionBlur effect and I couldn’t find a complete JME3 implementation for it, so I made my own using the optimized strategy I pulled from here.

I committed the filter to shaderblowlibs, and a test demo of it.

This filter provides framerate independent motion blur, you can specify how smooth the blur is (samples) and the intensity of the blur (strength).
This doesn’t support per-object motion blur, it depends on camera movement/rotation.

Here’s a video of the filter, sadly the recording software can’t really show it that well.

If anyone can improve upon this please by all means, thanks!


Cool, seems to be based on the same technique I used before =) thanks for sharing!

Yea I started out with what you had posted, then I implemented the “optimized” version and saw a 10% increase in performance :slight_smile:

Sadly there are still some bugs to work out… getting strange jitters/artifacts…


Okay, fixed it. Was calculating the framerate independence just plain wrong x_x

I’m happy with how this one turned out.

Index: MotionBlur.frag
--- MotionBlur.frag Base (BASE)
+++ MotionBlur.frag Locally Modified (Based On LOCAL)
@@ -27,11 +27,11 @@
   // sample over the blurVector to accumulate the final color
-  gl_FragColor = texture(m_Texture, texCoord);
+  gl_FragColor = texture2D(m_Texture, texCoord);
   for (int i = 1; i < m_BlurSamples; ++i) {
     vec2 offset = blurVector * (float(i) / float(m_BlurSamples - 1) - 0.5); // centered over blurVector
-    gl_FragColor += texture(m_Texture, texCoord + offset);
+    gl_FragColor += texture2D(m_Texture, texCoord + offset);
   gl_FragColor /= float(m_BlurSamples);

I had to change texture to texture2D in order for this to run on my computer. I like the effect, it certainly works better than mine =P.

1 Like

Super cool filter! Thank you a lot!

Tested. Works ok on my nVidia card.

I updated the fragment shader to reflect your fix kwando. Thanks