It has the usual bleeding problems of this sort of approach, and I didn’t do anything to fix them.
I actually had this working six months ago, but it took a while for Unity 3’s rendering pipeline to stabilize, and then more time for me to bother making it compatible with Direct3D.
Here’s what it looks like:
To use it:
• Attach MotionBlurEffect to your camera (CameraInfo is also required but will be attached automatically).
• Attach ObjectBlur to all objects which you wish to blur. The easiest way to do this is to choose Custom>Add Object Blur, which will attach it to all selected MeshRenderers that don’t already have the script.
That’s it! Objects will blur when they or the camera move, for any reason other than skinned mesh animation. Unfortunately I can’t think of a way to support skinned mesh animation using this technique in Unity.
Note that you need ImageEffectBase.cs from the Image Effects (Pro Only) package in order for this script to work.
The attached package has a demo scene with draggable objects that use the blur script.
Let me know how it works or doesn’t work for you.
Update: v4 has better comments and removes the unused minimumVelocity variable.
Wow,this implementation seems so sleek and clean compared to my rather hamfisted approach
runs miles faster too,I’m sure
kinda makes me feel ashamed,but oh well,it’s been a learning experience
Could you post a demo for us 2.6 folks?
Unfortunately I have lost the 2.6 version of the code. The current version could be back-ported, but I don’t have the time right now. The obvious changes that come to mind are:
Velocity storage relies on the Unity 3 UnityCG functions for storing and reading floats encoded in two channels of a texture. I’m guessing that Aras would be Ok with people copying those and using them in Unity 2.
It should work fine using per-vertex velocity, but the issue is how to get the previous position of each vertex. Since Unity handles all the skinning transparently on the CPU, I don’t know how you’d get that information into the shader.
I’ve cleaned up the code a bit and uploaded v4. Hopefully the comments will help people understand how it works. I also removed the minimumVelocity variable, which I’d stopped using because it wasn’t a good optimization.
Sorry for the thread necromancy but i wonder if somebody knows how to make this work when you have two cameras instead of one and one of them is set to “depth only” (you know, typical case of a FPS weapon camera). I tried with two cameras and shows everything in gray.
I tested it and works phenomenal! but i wondering if it some day is coming to work with character animations, right now it’s works when the object is moving but is the object have translation 0 and just play a animation Idle, Kick, Punch don’t work
I added another camera (depth-only) to the demo scene and it worked (no gray). If I get the same problem later, I’ll mention it, since I’m making a FPS.
Hey this is great, thanks so much. the demo scene works well.
I would like to know, does this work for a moving camera? does it calculate the velocity relative to the camera, or just the absolute velocity of objects themselves?
Also, I’ve started to apply it to objects in my own scene but it causes a serious flickeryness. Any ideas what could be wrong?