Activity › Forums › Adobe After Effects Expressions › layer transparency distance from camera
-
layer transparency distance from camera
Stuart Simpson replied 8 years, 5 months ago 9 Members · 21 Replies
-
Stuart Simpson
November 28, 2017 at 12:59 pmOkay this seems to work, although I’m sure it can be made more elegant!
Basically, only the z depth seems to affecting the opacity now, not any of the other position coordinates.
I’ve added my own novice understanding of what’s happening so please feel free to correct and improve for the benefit of others 🙂
// SETTING THE CONTROLS //
startFade = thisComp.layer("opacity controller").effect("start")("Slider");
endFade = thisComp.layer("opacity controller").effect("end")("Slider");// CONVERTING THE COORDIANTES //
C = comp("MASTER").activeCamera; // SELECTS THE CAMERA LAYER IN THE MASTER COMP //
CL = comp("MASTER").layer(thisComp.name); // SELECTS THE PRE-COMP IN THE MASTER COMP //
CLTRANS = CL.toWorld(toWorld(anchorPoint)); // CONVERTS THE PRE COMP LAYER ANCHOR TO WORLD COORDINATES //
CTRANS = C.toWorld([0,0,0]); // CONVERTS THE CAMERA LAYER POSITION TO WORLD COORDINATES //// CALCULATING THE FADE //
ZONE = CLTRANS[2];
ZTWO = CTRANS[2];
d = length(ZONE, ZTWO);
linear(d,startFade,endFade,0,100)
Reply to this Discussion! Login or Sign Up