-
Variable Expression Control across Multiple Layers
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.