FORUMS: list search recent posts

Variable Expression Control across Multiple Layers

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Brett Schnacky
Variable Expression Control across Multiple Layers
on Oct 2, 2014 at 2:46:54 pm
Last Edited By Brett Schnacky on Oct 2, 2014 at 3:08:02 pm

My current setup:

So I have a scene that contains a camera and a large amount of precomps dispersed in 3d space. I am also using a technique that utilizes beams to create a 3d connection from these precomps to a central point in the scene. This is the expression commonly used.

layer = thisComp.layer("layerName");
layer.toComp([0,0,0]);


Since I have hundreds of layers of beams, I created a null with several expression controls, linked to beam effect properties (ie. Length, Time, Softness, etc.) for master control of all of these layers.

Since I'm using to 2d Beam effect to simulate 3d connections, I have to use this handy expression from Darby Edelen seen here https://forums.creativecow.net/thread/2/945108 in order to create the appearance of perspective on the Beam starting and ending thickness. The expression looks like:

a = thisComp.layer("endnull"); //The end of the beam
cam = thisComp.activeCamera; //The active camera
p = a.toWorld(a.anchorPoint); //The world position of the end of the beam
c = cam.toWorld([0,0,0]); //The world position of the camera
v = p - c; //The vector between the camera and the end of the beam
cv = cam.toWorldVec([0,0,1]); //A unit vector pointing down the z-axis of the beam
d = dot(v, cv); //The vector between the camera and the end of the beam projected onto the vector pointing down the z-axis of the beam (d is the distance along the camera's z-axis to the plane that the end null resides on)
value * cam.zoom / d; //Multiply the current size value by the ratio of the camera's zoom property to the distance from the camera (as d, the distance between the camera and the null, increases the size decreases)


Furthermore, since all of my beam layers have the starting thickness and ending thickness properties connected to a starting thickness master slider and an ending thickness master slider, (both of which are located in my master control null layer) I cannot apply the above expression since it is layer name specific.

The problem is with the layer referencing portion of the expression. a = thisComp.layer("endnull")

Now to my question:

Is there a way that I can write the expression so that the incoming connection from a beam layer will maintain its reference for the layer name specific portion of the expression? a = thisComp.layer("????")

Right now it's looking like I'll have to manually apply the perspective beam expression to each beam layer and update the ("layer name") manually.

Any help would be much appreciated.


Return to posts index

Kevin Camp
Re: Variable Expression Control across Multiple Layers
on Oct 2, 2014 at 5:29:40 pm

the answer to the question of how to tell darby's expression to reference a specific layer, would be to use the same method of referencing the layer in your first expression. if you typed in a layer name for each beam effect end point to reference an specific layer, then you'll need to do the same for darby's expression.

you can specify a layer by index rather than name, so you could use the index of the layer with the expression to specify a layer that is relative to it's index... ex: you could specify to use the layer bellow the expression layer with an expression like this:

layerBellow = thisComp.layer(index+1);

or

layerAbove = thisComp.layer(index-1);


but that may mean that you need to restructure your current comp, so i don't know if that helps you out much.

or you could use a layer control (in the expression controls effects)on the beam layers to pick a specific layer, and link both expression the end point expression and the thickness expression to that control. the expression would look something like this:

selectedLayer = effect("Layer Control")("Layer");

but again, this requires some reworking of what you have.

regardless of how you choose the layer, there is a change that you need to make in darby's expression so that it will reference the thickness value of your slider.

you need to add a variable to point at the value of the slider and then replace 'value' in the last line to the name of the variable. it could look something like this:

endThickness = thisComp.layer('Control').efect('Slider Control')('Slider');

// last line
endThickness * cam.zoom / d;

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

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