View Full Version : motion blur using c programming

06-12-2004, 08:18 AM
For an assignment, I have made a tree animated with falling fruit. I want to know how to make the falling fruit have motion blur. There are many ways for it, however I prefer the easiest way to implement it, and with what functions?

Thank You,

06-12-2004, 10:51 AM
For each frame, draw 10 times a transluscent (alpha= 0.1) version of your fruit, each sample at a slight different simulation time.

06-12-2004, 06:30 PM
To render the motion blurred frame at time T, you'll decide on a quality factor N, and render the scene N times to generate N images at times:

I(N-1) = T-(N-1)/N
I(N-2) = T-(N-2)/N
I(1) = T-1/N
I(0) = T

Then you combine these using something like alpha overlay. One good way of doing it is to start with I(0), then do something like:

F = A;
foreach X in 1..(N-1)
I(0) += I(X) * F
F *= B

The values of A and B determine what the fall-off of the trail looks like. I'd suggest starting with A = 0.5 and B = 0.75 and go from there.

06-14-2004, 03:06 PM
Wow, this is the second blatant hack I've gotten to post today. This is visually "good enough" in most cases, but still not quite right. It doesn't require extra rendering passes, though, so it probably won't degrade performance at all.

Figure out an object's displacement in screen space from one frame to the next, then apply an appropriate scale matrix to stretch the object along its direction of motion. I wish I had some sample code available to help with this explanation, but I don't. I can try to supply some pseudocode if you're not a matrix math sadist like me.....

The scale matrix I mentioned is actually going to be a (rotate * scale * inverse_rotate) because you'll only want to scale along one axis.