PDA

View Full Version : expressions help: smooth keyframes?



monovich
04-04-2008, 10:58 AM
Hello,

I've got series of camera keyframes that I've baked from Motion Mixer and they appear to have little jaggies in the keyframe, almost as if I'd attached a small noisy channel effect to the camera to make it shake. I suspect its because they are very very small movements and maybe lightwave is rounding on the precision of the calculations that small. eitherway, I need them smooth and I've got to find a way.

In After Effects I can apply a pre-written expression that will evaluate existing keyframes and smooth them out. It looks like this: smooth(width = .2, samples = 5, t = time)

Would anyone be up for writing or helping me write channel modifier expression that will do the same in LW? There is a baked keyframe for every channel of the camera move on every frame, so if the expression looked at a series of 3-5 frames and evaluated smoothing based on that, might it work?

If anyone is up to this, thanks in advance!

-SF

monovich
04-04-2008, 11:30 AM
I tried a keyframe reducer, but even that doesn't seem to work because the precision isn't there.

SplineGod
04-04-2008, 01:52 PM
Are you seeing jaggies or is there actual jitter in the motion?
Do you have fractional keyframes on or off?

monovich
04-04-2008, 01:59 PM
you can see the jaggies in the baked keyframes, the look like a saw blade when viewed very very close in.

check out the Z position channel in this .mot file and you can see the problem clearly. its in the other channels also.

jeanphi
04-04-2008, 02:05 PM
You can try KeyStrainer:

http://www.tmproductions.com/FrameSets/FS-Products.html

http://www.tmproductions.com/ProductsHTML/Docs/KeyStrainer_Docs.html

I used this to reduce mocap motion data and had good results.

SplineGod
04-04-2008, 02:50 PM
Its possible with expressions, the hard part is coming up with the math. Something like a least squares fit maybe. http://www.efunda.com/math/leastsquares/leastsquares.cfm
Otherwise filtering the keyframes would be the way to go.

monovich
04-04-2008, 07:49 PM
or how about just simple frame averaging where the equation looks at two keyframes to the left and the right of the current keyframe and averages the values to create a smoothing effect?

SplineGod
04-04-2008, 08:35 PM
That might work but I noticed that theres a lot of stairstepping in the z channel which may not smooth well.

monovich
04-04-2008, 09:12 PM
any idea on how to write an expression for that? thats where come up cold.

vfxwizard
04-05-2008, 01:21 AM
or how about just simple frame averaging where the equation looks at two keyframes to the left and the right of the current keyframe and averages the values to create a smoothing effect?

The following expression will average 5 frames, just apply it as a RelChanneler modifier in graph editor, changing Z with X and Y when you apply it to the other channels.

Z(SELF,t)*.5+Z(SELF,t+.04)*.15+Z(SELF,t-.04)*.15+Z(SELF,t-.08)*.1+Z(SELF,t+.08)*.1

The expression is set at 25fps change .04 to .033 and .08 to .066 for 30fps. Be warned: it will cut corners a lot but may be what you were after.

Hope this helps!