Jump to content
Sign in to follow this  
J Montreuil

Shared AE Expressions document for all

Recommended Posts

I am building a shared Google document of my favorite and most commonly used Expressions. That way I don't have to keep Googling for them when I am out and about.

 

 

 

 

https://docs.google....GDGzfMn8NY/edit

 

Here's an easy bit.ly to use as well: http://bit.ly/aeExp

 

If there is anything you want me to add, please let me know and I'll plop it right in there. If you think you are super special and want edit privileges, let me know.

Edited by J Montreuil

Share this post


Link to post
Share on other sites

Here's a couple of the top of my head that I don't think I saw in there:

 

3D layer invisible while facing backwards to camera (use on Opacity):

if (toCompVec([0, 0, 1])[2] > 0 ) value else 0

 

Parent Puppet pin to Null (there is a script on AEscripts for this also I beleve, haven't used it):

n=thisComp.layer("NullObject_Name");

nullpos=n.toComp(n.anchorPoint);

fromComp(nullpos);

Share this post


Link to post
Share on other sites

3D layer invisible while facing backwards to camera (use on Opacity):

if (toCompVec([0, 0, 1])[2] > 0 ) value else 0

 

Parent Puppet pin to Null (there is a script on AEscripts for this also I beleve, haven't used it):

n=thisComp.layer("NullObject_Name");

nullpos=n.toComp(n.anchorPoint);

fromComp(nullpos);

 

That first one is real good to know! The second one, I always just pick whip it to the null's position. How is this different?

Share this post


Link to post
Share on other sites

The second one, I always just pick whip it to the null's position. How is this different?

 

Pick whipping will only work when you have perfectly comp size layers. You also won't be able to create parent hierarchies to create joint chains for rigging, i.e. Soulder>elbow>wrist so you can animate rotations of parents, or use IK expressions.

Share this post


Link to post
Share on other sites

I use Wunderlist for this as well because I prefer the list style layout. I probably use this expression the most.

 

Parent Camera focus distance to Null

length(position, thisComp.layer("Null 1").transform.position)

 

 

it's super useful to get your camera's focus to follow a specific layer/null.

Share this post


Link to post
Share on other sites

Kudos the the great Dan Ebberts for the handy range mapping expression:

 

input = effect("Slider Control")("Slider");

inputLow = 0;
inputHigh = 100;
outputLow = -100;
]outputHigh = 100;

linear(input,inputLow,inputHigh,outputLow,outputHigh)

 

This way you can use the visual range of a slider much more intuitively, rather than relying on numeric input. I use it all the time for prototyping wiggles.

Edited by SFBurning

Share this post


Link to post
Share on other sites

Kudos the the great Dan Ebberts for the handy range mapping expression:

 

input = effect("Slider Control")("Slider");

inputLow = 0;

inputHigh = 100;

outputLow = -100;

outputHigh = 100;

 

linear(input,inputLow,inputHigh,outputLow,outputHigh)

 

This way you can use the visual range of a slider much more intuitively, rather than relying on numeric input. I use it all the time for prototyping wiggles.

can you explain this?....I usually do something like this on the position of a layer linking them to two sliders for control:

 

wiggle(thisComp.layer("Null 1").effect("Slider Control 1")("Slider"),thisComp.layer("Null 1").effect("Slider Control 2")("Slider"))

 

... how does your setup work? ....guess I will give it a try.

Share this post


Link to post
Share on other sites

can you explain this?....I usually do something like this on the position of a layer linking them to two sliders for control:

 

wiggle(thisComp.layer("Null 1").effect("Slider Control 1")("Slider"),thisComp.layer("Null 1").effect("Slider Control 2")("Slider"))

 

... how does your setup work? ....guess I will give it a try.

 

Basically this lets you define your own range for the Slider expression control effect, which by default only goes from 0 to 100 when using the visual slider.

 

You can use this expression to basically roll your own mixing board of sorts. So now you're not thinking in terms of actual integer values, but more along the lines of zero to one hundred percent, where the min and max are defined by you to taste. Then you just drag the sliders around visually and forget real number values altogether. Super handy for anything where you're not sure how much of x you need, regardless of what x is.

Edited by SFBurning

Share this post


Link to post
Share on other sites

Here are some I've collected (not written) you might want to add:

 

 

fades a layer in or out

fadeInTime = 1; // fade in time (seconds)

fadeOutTime = 1;

Math.min(linear(time,inPoint,inPoint + fadeInTime,0,100),linear(time,outPoint - fadeOutTime,outPoint,100,0))

Makes a second hand rotate for a clock:

value + Math.floor(time)*6 //

Countdown clock:

now it counts down from whatever you tell the h:m:s:f: to be.

h=71;m=59;s=59;f=99;

f-=timeToFrames(t = time + thisComp.displayStartTime, fps = 3.99 / thisComp.frameDuration, isDuration = false);

s+=Math.floor(f/99);

m+=Math.floor(s/60);

h+=Math.floor(m/60);

f=f%99;

s=s%60;

m=m%60;

if(f<0) {f=100+f}

if(f<10) {f="0"+f}

if(s<10) {s="0"+s}

if(m<10) {m="0"+m}

if(h<10) {h="0"+h}

h+":"+m+":"+s+":"+f

Random integer generator

hold frame = the number of frames before the number changes

holdFrames = 3;

seedRandom(index,true);

f = timeToFrames();

seg = Math.floor(f/holdFrames);

r = Math.floor(random(10));

for (i = 0; i < seg; i++) r = (r + Math.floor(random(1,10)))%10;

r

Share this post


Link to post
Share on other sites

 

Basically this lets you define your own range for the Slider expression control effect, which by default only goes from 0 to 100 when using the visual slider.

 

You can use this expression to basically roll your own mixing board of sorts. So now you're not thinking in terms of actual integer values, but more along the lines of zero to one hundred percent, where the min and max are defined by you to taste. Then you just drag the sliders around visually and forget real number values altogether. Super handy for anything where you're not sure how much of x you need, regardless of what x is.

cool man thanks!

Share this post


Link to post
Share on other sites

No problemo. Here's an example in practice from the project I'm working on this morning:

 

input = effect("Time")("Slider");
inputLow = 0;
inputHigh = 100;
outputLow = .05;
outputHigh = 1;
timeVal = linear(input,inputLow,inputHigh,outputLow,outputHigh);
input2 = effect("Space")("Slider");
inputLow2 = 0;
inputHigh2 = 100;
outputLow2 = 5;
outputHigh2 = 70;
spaceVal = linear(input2,inputLow2,inputHigh2,outputLow2,outputHigh2);
wiggle(timeVal,spaceVal);

 

In this example, "Time" and "Space" are the names I've given to a pair of slider controls. As long as you have the same setup, you should be able to just plug this code directly into any property of an object and have it work OOB.

 

Also, heads up for the rest of the thread... looks like this BBS has a special code field available. Hit the "<>" button in the toolbar or use CODE and /CODE in square brackets to roll it out.

Share this post


Link to post
Share on other sites

For when you want burn in text to automatically display the layer name (i.e. render out tiff sequence first, then making a QT w/ name burn in).

 

Make text layer, add expression to 'source text'.

 

function pad(number, length) { var str = '' + number; while (str.length < length) { str = '0' + str; } return str; } var theLayerName = thisComp.layer(index+1).name; var theLayerNameSplit = theLayerName.split('.'); theLayerNameSplit[0];

 

To change which layer is read for the name, change the (index+1) to (index+2) and so on.

Share this post


Link to post
Share on other sites

I'm surprised the inertia script isn't listed from Dan. Add this to the list for some nice secondary movement to animated elements:

//Inertial Bounce - Dan Ebberts:  Apply to any animated param.

amp = .1;
freq = 2.0;
decay = 8.0;
n = 0;

if (numKeys > 0)
{n = nearestKey(time).index;
if (key(n).time > time){
  n--;
}}
if (n == 0){ t = 0;}
else{t = time - key(n).time;
   }
if (n > 0){
 v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
 value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{value}

Share this post


Link to post
Share on other sites

I'm surprised the inertia script isn't listed from Dan. Add this to the list for some nice secondary movement to animated elements:

//Inertial Bounce - Dan Ebberts:  Apply to any animated param.

amp = .1;
freq = 2.0;
decay = 8.0;
n = 0;

if (numKeys > 0)
{n = nearestKey(time).index;
if (key(n).time > time){
  n--;
}}
if (n == 0){ t = 0;}
else{t = time - key(n).time;
   }
if (n > 0){
 v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
 value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{value}

 

It's on the first page.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...