ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Progressive, smooth wiggle frequency change...

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Nico Jones
Progressive, smooth wiggle frequency change...
on Jun 8, 2010 at 4:13:09 pm

'm trying to mimmick a POV shot, purely in AE. I've got a 3D cockpit set up in Invigorator, and a camera that is going to be my character's 'eyes'.

It's all working fine, but I need to add wiggle to the camera POV (or position) to give realistic movement. I have a null object set up with 2 sliders controlling the amount and frequency of the wiggle on the camera, all working nicely.

The problem comes when I try to animate the sliders. Keyframing the severity of the wiggle is fine, but when I animate the frequency I get a massive, out of control judder between keyframes.

I really need to be able to smoothly change between different levels of wiggle frequency. Any ideas how I might be able to do this?

Here is a project file that illustrates the problem. Notice the judder inbetween the keyframes. It's not the boomerang effect, easing the keyframes doesn't help and I can't use hold keyframes without losing the transition between frequency changes.

https://www.yousendit.com/download/YWhOSlI5OW5TSUR2Wmc9PQ

Many thanks,

nico



Return to posts index

Dan Ebberts
Re: Progressive, smooth wiggle frequency change...
on Jun 8, 2010 at 7:29:28 pm

Changing a wiggle's frequency smoothly is surprisingly complicated. You can't just animate the frequency parameter because as the frequency value changes, the expression is evaluated as if it had been using the new frequency the entire time. So weird things happen. If you're animating using linear keyframes, you'll have better luck animating wiggle's seldom-used 5th parameter (time). Here's an example that integrates (converts frequency to time elapsed) your frequency control and uses that value to advance through time of a wiggle with a nominal 1 Hz frequency:

freq = thisComp.layer("Wiggle Control Sliders").effect("FREQUENCY")("Slider");
amp = thisComp.layer("Wiggle Control Sliders").effect("AMOUNT")("Slider");

if (freq.numKeys > 0){
accum = 0;
v0 = freq.valueAtTime(0);
t0 = 0;
i = 1;
while (i <= freq.numKeys){
t = freq.key(i).time;
if (t < time){
accum += (v0 + freq.key(i).value)*(t - t0)/2;
v0 = freq.key(i).value;
t0 = t;
if (i == freq.numKeys){
accum += (time - t0)*v0;
}
}else{
accum += (time - t0)*v0;
break;
}
i++;
}
}else{
accum = freq*time;
}
wiggle(1,amp,1,.5,accum);

Dan



Return to posts index

Dan Ebberts
Re: Progressive, smooth wiggle frequency change...
on Jun 8, 2010 at 7:37:55 pm

Hang on, that doesn't work quite right....

Dan



Return to posts index


Dan Ebberts
Re: Progressive, smooth wiggle frequency change...
on Jun 8, 2010 at 7:53:15 pm

OK - sorry for the misfire. I think this works:


freq = thisComp.layer("Wiggle Control Sliders").effect("FREQUENCY")("Slider");
amp = thisComp.layer("Wiggle Control Sliders").effect("AMOUNT")("Slider");

if (freq.numKeys > 0){
accum = 0;
v0 = freq.valueAtTime(0);
t0 = 0;
i = 1;
while (i <= freq.numKeys){
t = freq.key(i).time;
if (t < time){
accum += (v0 + freq.key(i).value)*(t - t0)/2;
v0 = freq.key(i).value;
t0 = t;
if (i == freq.numKeys){
accum += (time - t0)*v0;
}
}else{
accum += (freq + v0)*(time - t0)/2;
break;
}
i++;
}
}else{
accum = freq*time;
}
wiggle(1,amp,1,.5,accum);

Dan



Return to posts index

Nico Jones
Re: Progressive, smooth wiggle frequency change...
on Jun 9, 2010 at 1:07:36 pm

Many thanks for the help, Dan. I can't seem to get smooth results when applying that expression to my project though - it gives a jagged hit just at as the second keyframe happens. I'll admit that this expressionis a bit beyond me, so I can't really make any tweaks myself...

Nico J BB


Return to posts index

Dan Ebberts
Re: Progressive, smooth wiggle frequency change...
on Jun 9, 2010 at 3:09:00 pm

I just tried it again with your project and I'm not seeing that behavior (it seems very smooth at the 2nd keyframe). That was the problem with the first version I posted though. Are you sure you didn't use that one? The only difference is the 9th line from the end, which should be:

accum += (freq + v0)*(time - t0)/2;


Dan



Return to posts index


Nico Jones
Re: Progressive, smooth wiggle frequency change...
on Jun 9, 2010 at 3:21:53 pm

How strange...yes I'm using the right one.

The actual transition is smooth, but it's jumping a few pixels on the frame after the second keyframe. Even though the value is the same...

http://webfilemanager.co.uk/dsf.php?fileid=B1LuN3kz

Maybe something in my setup is awry...

Nico J BB


Return to posts index

Tom Granberg
Re: Progressive, smooth wiggle frequency change...
on Jul 24, 2017 at 9:55:28 pm

Is there a way to pause a given time between each new number?


Return to posts index

Matthew Roberts
Re: Progressive, smooth wiggle frequency change...
on May 19, 2016 at 4:15:51 am

Hi Dan - this looks great.

Is there a way to do this smooth wiggle only on one axis (e.g. on Y only?)

Matthew Roberts
http://kupon.co.uk/
http://dribbble.com/matthewkupon


Return to posts index


Dan Ebberts
Re: Progressive, smooth wiggle frequency change...
on May 19, 2016 at 5:38:54 am

Maybe just change the last line to this:

w = wiggle(1,amp,1,.5,accum);
[value[0],w[1]]


Dan



Return to posts index

Paul Wright
Re: Progressive, smooth wiggle frequency change...
on May 22, 2017 at 8:51:21 am

Dan, you are the man. Thanks very much for this script. Its helped me out immeasurably. Only found it yesterday.

Ta :)


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]