Back to the bouncing ball..
In the last days we had to deal with a procedural animation for the wings of a thinkerbell. The final animation consisted in having the wings flapping very fast and changing the speed along the animation.
Easy task, isn’t it?
To have a continuous animation, we could drive some parameters of our object by using a trigonometric function, i.e.:
But what if we animate the frequency value along time? Here’s what we may get:
This translates into the motion of our 3d object as instantaneous jumps and changes of direction. The reason why this behaviour is that by changing the frequency of the sinus curve, we are squashing/stretching its base period, but the instantaneous phase is not kept, i.e. at the same instant we ‘see’ different angles between the two curves. Thus, to fix the problem, we have to impose that when we are changing the frequency, we keep the same instantaneous phases, i.e.:
As we can see, the new instantaneous phase brings an additional phase term p1, coming from the previous phase. This term must keep the same propery of the new instantaneous phase:
Please note that t is not the same between the first and the second term.
In general, to keep the continuity at each time t (in a discrete time, e.g. our frames), the instantaneous phase for t=tn can be written as:
Note in this case the curve has ‘broken tangents’ at the points changing frequency. This because the resulting function is not continuous in C1, ie. for it’s derivate. To have smoother transitions, simply avoid instantaneus changes of frequency.
We can use this formula into an expression. Because the iterative sum, a smart way to evaluate the expression would be storing the partial sums along the playback of the animation:
Though this method is very efficient, it has some limitations. The partial sum is calculated according the previous expression evaluation, that means, if we scroll the timeline or jump back and forth during the playback (as usually animator do while working), we loose the exact counting of the partial sum and the result is wrong. To fix that, at each expression evaluation we have to recalculate the whole sum, so the expression becomes state-independent:
So far so good… for now.
What about setting high frequencies? We might experiment ugly animations, jumps and even… no animation.
The reason is due to the downsampling of the motion described by our high frequency sinusoid and the frame rate chosen to playback in our animation, that usually is set as 24 fps.
Let’s consider this case:
Where the blue curve is our expression, the vertical red lines marks the frames and the red circles are the result of computation of the expression at each frame.
In this case it is easy to understand the movement of our object. Now let’s increase progressively the sinus frequence:
The movement starts to become fuzzy..
In this case the period of the sinusiod equals the time between 2 frames. Even if the expression describes a movement, the final result after sampling is no movement. The same effect verifies if we have the period equals to 2 fotograms.
Keep increasing the frequency:
All these effects are well known in signal theory, and as anticipated, is the result of the wrong sampling of the equation describing the motion. They can be also seen in the classic inverse wheel rotation effect.
Now the question is, what is our maximum frequency bound?
According the Nyquist-Shannon theorem, the maximum frequency we can have for a certain fs (sampling frequency, in our case is the fps) cannot be higher than fs/2. i.e., if we animate our object at a frequency higher than 12 sampling at 24 fps, we perceive a distorted motion.
A higher range of action in the computer graphics is given by the vector motion blur algorithm. In this case, even if the object ‘jumps’ too much between adjacent frames, the blurring helps the viewer to perceive the motion. Moreover the subsampling method of this algorithm captures the motion inbetween frames.
But even motion blur sumbsampling has its bounds. If the frequency of our object is higher than ( scene fps/2) * #subsamples, the algorithm perceives in input wrong motion, exactly as aforementioned.
In visual effects industry for extreme frequencies unreachable by the renderer even by using motion blur subsampling, a common technique consists in animating multiple copies of the object with lower frequencies and different phases and compositing the copies in post production.
A more accurate but computationally expensive way to sove the problem would be ‘supersampling’ the frames, e.g. rendering at 48 fps and ‘downsampling’ in post production.