Smoothing Animation Curves
Smoothing an animation curve can be done through the animation curve's “Edit/Filter” option.
However, this will move the original keyframes which seems a little destructive and doesn't allow a nice fine tuning workflow (other than jumping up and down on the undo button and trying again with a different value).
So here is an expression based solution that uses a user knob value to smooth the curve “live”:
In my Tracker node I have this animation curve:
I have also created two floating point sliders called “smooth” and “smoothedCurve”, one to adjust the amount of smoothing and the other to hold the resulting smooth curve respectively:
The magic in this whole smoothing business is using the integral of the knob that holds the animation (in this case it's track1.x) over a certain range. In other words we want to use something like integrate(a,b). Let's do this just for the range of three frames (previous frame to last frame). Dividing the whole thing by (b-a) will give the average value and thus a box filter (thanks to Bill Spitzak for posting this solution on the nuke ailing list once, I never paid enough attention at high school to even know what this is exactly doing). I do know however, that the next frame minus the previous frame always equals 2, so here we go:
The resulting curve:
This is hard coded to a 3 frame range though (from previous to the next frame of each frame), so let's hook it up to our custom “smooth” knob to make it more interactive:
And that is all. Now you can drive the smoothness of the custom curve by cranking the "smooth" knob:
Comments
i thought it could be useful for others that i let you know the flaw i found in your final formula.
at higher smoothing values i had the case that the smoothed curve started to get "bumpy" again.
this is due to the "smooth" value being used in the frame+/- section.
giving those 2 a fixed value lets you smooth your track or curve down without any resonance problems. i just increased the value to 1.5, 2 is fine as well, depends on how many steps you want in the smooth slider until you get a flat line
cheers
i don't know where to ask the following question - but i guess u guys have an answer
actually i don't want to smooth or filter my animation curves. i just want to delete every 2nd keyframe - simplify curve is that called within maya. how to achieve that effect within
br mayanic
Matt, sounds like a job for python rather than expressions. For general questions and help try the nuke user mailing lists, very helpful people there!
As I can understand this expression drives a filtering algorithm but with more flaxability. Isn't it?
i have a tool based on your formular in our pipeline to smooth out unwanted camera jittering or swaying. the formula for the x and y values is : translate.x.int egrate(frame-1. 5, frame+1.5)/(2*smooth)
i can smooth as much as ia like with this, back and forth.
i can send you a little test script, if you like
dunno why my name isnt displayed.....
thanks
I can't exclude it's my mistake but I've found important differences between Frank expression and edit/filter workflow. Probably is the same issue Mortimer was talking about.
Those are results with Frank expression for value, 5, 10 and 20
https://goo.gl/photos/nubqcZE3GqBFC2xK9
And those are edit/filter results for value 5, 10, 20 and 1000
https://goo.gl/photos/qnptVq4sLoFj55D28
I'm trying to recreate an un-distructive way to filter curves but results are lacking until now!
http://www.nukepedia.com/gizmos/other/videotravolta-stabiliuz
how I connect the gizmo to scanline render camera to get the smooth result?
RSS feed for comments to this post