Quantcast
Channel: Adobe Community : Popular Discussions - After Effects Expressions
Viewing all 47983 articles
Browse latest View live

Baking Parented Motion into Keyframes

$
0
0

Hey guys!  I'm trying to stabilize a piece of extremely tricky footage.   The stabilization needs to be reversible.  Ordinarily this is easy... you just apply the tracking and rotation data inverted to a layer, and then you precomp the stabilized comp, and apply the non-inverted data to the precomp.  Voila!

 

However in this case, due to the trickiness of the stabilization, I've ended up with a chain of parented nulls, each with a combination of position, anchor point, and rotation data (some added manually, some imported from Mocha).  The result works, but reversing it in the traditional way is no longer possible.

 

I've thought of a dumb solution to this problem (more on that below), but what I'm wondering is whether anyone has a smarter solution.  Is there a way of using an expression to read the footage layer's objective position and rotation (taking into account the whole chain of parents)?   If so, then I could simply convert that expression to keyframes, and invert the resulting keyframes to get my "unstabilize" data out of my big mess.

 

I think this is what the toWorld expression is for in a 3D context, but using it is a little beyond me.    Does anyone have a good idea for how to fix this?

 

For the record, here's my dumb solution.  I'm hoping to avoid this:

Replace the footage layer with a grid. 

Render.

Import the rendered file into mocha.

Track the grid.


RGB to HEX #ffaadd value to Text Layer

$
0
0

Hi, I am trying to write an expression that will spit out #HEX value to a text layer source.  The RGBA color will come from a fill color on a solid layer.

 

I cannot find anything to convert RGB to a HEX value only rgb to hsl.

 

Is this even possible through expression or extendscript?

 

This is what I have so far, which will spit out RGBA values from converting rgbtohsl and then back to hsltorgb*255

 

in_rgb = thisComp.layer("controller").effect("color_04")("Color");

in_hsl = rgbToHsl(in_rgb);

new_hue = (in_hsl[0] + 0) % 1;

new_sat = in_hsl[1] * ((thisComp.layer("color_04_tint").effect("saturation")("Slider")/100)+1);

new_lightness = in_hsl[2] * ((thisComp.layer("color_04_tint").effect("brightness")("Slider")/100)+1);

mod_hsl = [new_hue, new_sat, new_lightness, in_hsl[3]];

 

 

src = hslToRgb(mod_hsl) * 255;

 

 

Any help is appreciated.  Please feel free to email me, jchung@guidespark.com.

 

Joe

Linking a 2D layer to a 3D layer

$
0
0

Ok, i've come to my limitation of expression skills.

 

I've setuped a 3D composition, with various elements at various depths. One of this element is a Sun. I setuped a camera to do a pan inside my 3D world.

 

So far, so good. None of my elements are animated.

 

Now i'd like to link a lens flare on my sun, which is a 2D layer. I've tried with the "toWorld" and "toComp" expression, but i don't get any results as my 3D layer "Sun" is not moving. Only my camera (and for some reasons i mustn't turn my Lense flare into a 3D layer).

 

But i can't figure out how to calculate the position of my "Sun" layer inside my comp with an offset from the camera position.

 

I'm sure it's possible, but i'm so bad when it comes to heavy math.

Can I link a path vertex to a position property via an expression?

$
0
0

I want to have curves and lines draw across or between points in a video clip that has hand held camera moves in it.

 

I've motion tracked the points I want to use and assigned the tracking data to a null at each point. Ideally I'd like to then link a vertex in a shape path to a null so I can have a stroke animate in and join up the tracked points and then the vertices can "stick" with the video as it draws on.

 

It's not possible to stabilise the shot animate then "de-stabilise" the shape layer as there's some parallax as the camera turns through a small angle.

 

There's a couple of Tuts that suggest work arounds, such as using the Beam or Path Text (dots and dashes) effects on a solid layer as they have vertexes that can be pickwhipped to position properties. I then have to use multiple layers and timings to create the illusion of a single line moving through the space.

 

There's also a RotAE script that I've come across:

http://www.fxfx.org/index.php/2011/03/27/how-to-attach-a-mask-point-to-a-layer-in-after-ef fects/

 

However I wanted to check if it's actually impossible and these workarounds are the only options?

Is it possible to confine expressions to specific keyframes?

$
0
0

I am definitely a beginner when it comes to expressions.

I am currently using a "bounce" expression on the position parameter of some objects as they come on screen. However, the next time they change positions, I don't want them to bounce. Every time a motion tween ends in a static position, the position expression gets applied and the stuff is moving around.

I'd like to be able to keyframe the expression so that it worked only when on the keyframes that it makes sense to affect.

 

amp = .05;

freq = 1;

decay = 7;


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

}

 

I got this script from somewhere online. The only thing I know how to manipulate are the initial values of amp, freq, and decay.

Fill Color Controller to change between colors overtime

$
0
0

Hi All,

 

I'm using CS6 AE..

 

I have created a clapometer style animation that uses a colour controller and value/numbers controller to animate the hand from left to right of a semi circle. As the hand moves (by a value slider) the layer underneath fills and I would like the color to go from yellow to red via multiple colors.

 

So far I have this code on my fill layer

 

l=thisComp.layer("Fill color controllers");

i=1;

colors=[];

try {

while(l.effect(i)) {

if (l.effect(i)(1).name=="Color") {

colors.push(l.effect(i)(1).value);

}

i++;

}

} catch (e) {}

if (colors.length) {

r=Math.floor(random(colors.length));

colors[r];

} else {

}

 

And a fill color controller layer with 5 different color expression controls. At the moment the code cycles through them randomly, but I would like cycle through the list. I know there are other ways I could do this but I am trying to improve my expression knowledge and hope someone can help me!

 

Cheers!

Wiggle expression - slider control

$
0
0

Hi all

 

I had a solve for this from Dan Ebberts but I seem to have lost that content in the Jive update. I want to use a slider control for a wiggle, but when I have my basic wiggle expression applied to position, then pick whip from that to the slider, I get the below expression.

 

temp = effect("Wiggle Control Sliders")("Slider");

[temp, temp]

 

What is the fix for this/ way to do it right?

 

At the minute I'm using the expression below instead, but I hate not knowing the right way to do something! Using sliders/ creating decay in expressions has always been an issue for me...

 

wiggle(15,effect("Slider control")("Slider"))

 

Any help would be appreciated

 

Thanks!

Expression target multiple layers

$
0
0

hi,

I have several layers, all with the same expression (linked to expression controls)

I wondered if it's possible to have one instance of the expression script to target multiple layers?

Rather than pasting he same expression code on each layer..

Thanks


Start/Stop Time Expression

$
0
0

Hi,

 

I'm new to expressions and I need to start and stop the expression at specific frames.

 

My expression as follows:

 

f = effect("Frequency")(1);

p = effect("Period")(1);

Math.cos(p * textIndex/textTotal + time*f)*50

 

Thanks in advance for all your help!

Expression Get Project Path or Name

$
0
0

Hi,

 

I am new to After Effects as in I have just seen it for the first time today!

 

What I'd like to know is, is it possible to write an expression to return either the current project name or file path?

 

I'm assuming no as I cannot find any reference to this in the language reference. How would I go about integrating a script with the project to return the project name?

 

I have tried something basic like:

 

Expression code:

 

var currpath = $.evalFile(filepath);

 

filepath is the path to my script file, the script is like the below:

 

GetPath()

 

function GetPath() {

 

return app.project.name;

}

 

With this I get an error similar to method name 'Global' not found - not at my work computer so can't remember the exact message.

 

Any help would be appreciated.

 

Thanks,

 

Mark

Expression at a specific time

$
0
0

Hi,

 

when I apply an expression it starts from the beginning of the composition, but if I want to start it, for example, after 10 seconds, how can I?

 

Sorry for my english.

Scale over time expression

$
0
0

I'm trying to have an element scale up and do so through an expression:

 

startScale = 100;

endScale = 300;

scaleUpTime = 5;

 

s = ease(time, inPoint, inPoint + scaleUpTime, startScale, endScale);

[s,s]

 

 

This works but I'd like to modify this is that the endScale is actually a random number between 100 and 300.

I'd also like the whole thing to trigger at a specific time (or frame).

 

I tried random(100,300) but it gives a jittery result not a constant scale up to a random value

Expression Control / Slider Control work with percentage?

$
0
0

For example, I want to make one expression with keyframes, so opted to use "slide control," but the expression is now defined by the "slide control ", if I put the expression wiggle(2,5) and place the 2 on the slide control, know that the value will be replaced by the value of "slide control" if in case the slide control was "10", would look like this: wiggle(10,5)

 

 

But what I want to know is if have how to control the original expression through a percentage and not a replaced, for the slider control value.

 

Thanks!

Can I Animate Individual Characters in a Text Block Using the Wiggle Expression?

$
0
0

I'm new to After Express and just diving in to expressions. I was trying to figure out if there was a simple way to use the wiggle expression in a way that it would wiggle individual characters in a text block independently of each other.

 

Definitely appreciate any help.

Bake Parent Transformations

$
0
0

Hey folks, this is similar to a questions I asked a few weeks ago about baking in motion from a parented camera, but now I'm trying to do it with a footage layer, and I still can't quite get my head around what I need to do.

 

I'm trying to hand off my project from an animatic to a 3D animator, and it doesn't import properly on his system unless the layers aren't parented to anything in after effects.

 

So, my relatively simple (I thought) solution was to use the toWorld expression on layer to look at the old one and generate absolute position, anchor point, and X,Y,Z rotations.  However, repurposing the camera expressions:

 

C = thisComp.layer("Footage Layer");

C.toWorld(C.position)

 

Doesn't seem to do anything correctly. 

 

Just a little info on the project, the layer is the end of a chain of parents, which keyframe position and orientation.  The layer I'm trying to bake the keyframes for also has an animated anchor point.

 

I think I'm going to need expressions to bake in both the position and the anchor point as well as the orientation.

 

If anyone can help me put these expressions together I would be so grateful!  Thanks!

 

Cheers,

Ari

 

 

Dan Ebberts

 


counting numbers expression with commas

$
0
0

I am using the following expression to create a number countdown but I need it to recognize or insert commas in eight digit numbers. Can anyone tell me how to alter it:

 

 

startT = 0;

endT = .5;

beginVal = 12400000;

endVal = 10700000;

t = linear(time,startT,endT,beginVal,endVal);

Math.floor(t) + ''

 

 

P.S. there are also times that I'd like to add dollar signs or percent signs.

Mirroring position

$
0
0

Hello everyone!

 

I have a square in a comp and a circle in other comp. In Main comp, I have a null object to control the position of square and I using the cod bellow, inside the square's comp.


L=comp("man").layer("C_feet_rgt");

P=value+L.toWorld(L.anchorPoint);

parent.fromWorld(P);


When I change the position of square working with the null object in the Main comp, I'd like to circle moves to oposite position of the square.

 

How can I mirror the position of a circle?

 

Thanks

Reference a beginning keyframe in a looping animation

$
0
0

Hi, I have a looping animation with two keyframes, I am using loopOutDuration to repeat this animation over the comp duration. I am wanting however to randomise the starting position of the first keyframe on the x axis. I have written the expression for this, but it applies a randomisation to EACH FRAME of the animation rather than at the beginning (KEYFRAME 1) starting point and sticking to this x position with a constant value.

 

The only solution I can think of right now is to note the duration of loop, allow for this amount of time to pass before before applying a momentary change to the x position, however I suspect that on the following frame when I call Value it will reset to what the keyframe value is rather than that set by the expression. I hope this is clear enough...

 

TLDR;

I want an expression to change the value of an x position on two keyframes. Giving a random but constant value for the duration of a loop.

 

Would I be better off ditching keyframes entirely and doing the whole animation via expressions? Or is there some way to reference them in an expression?

Rotation in a looped composition

$
0
0

Hello,

I'm having trouble and am hoping someone can help me.  How can I have an object that moves about in a looped composition and also continuously rotates?

I've used the expression for rotation value=time*90

Currently, in the main composition, the object rotates but at the end of the loop, it goes back to its original position.

Is there a way to take the time value of the main composition instead of the looped one?

Thanks for any help

Storing a position value from the previous frame

$
0
0

Hey guys,

 

So, I'm trying to assign the X value a null object had at the previous frame so I can continue to subtract a number from it cumulatively. I'm trying to assign it to a variable (prevframe). I'm not sure where I'm going wrong, but the line I'm trying to do it on is written as follows:

 

prevframe = transform.xPosition.valueAtTime(time-(1/24))

 

So in my mind, this should be taking a look at the value of X on the null, then looking back in time to figure out what it's value was on the previous frame (my frame rate is 24, so I'm dividing 1 second in to 24 pieces and telling it to subtract that much from the current time), and assigning whatever that returns to the variable. But it's just returning a static value, even though I'm subtracting from it. I feel like it's not the correct syntax, but I really have no idea.

 

I want to continue to subtract a value which is based on the velocity of another object from this, which I have worked out, I just can't figure out how to reference what this nulls X position was in the previous frame so it always returns the same value until all motion has stopped. The formula the variable is being run through looks like:

 

finalposition = prevframe - camvelocity

 

Which is then assigned to the final X position of the null object.

 

So, I'm not sure where I'm going wrong. I hope I've provided enough information to help someone wrap their head around this and hopefully help me solve it.

 

Thanks in advance,

 

-Seth

Viewing all 47983 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>