Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions layer transparency distance from camera

  • Stuart Simpson

    November 28, 2017 at 12:59 pm

    Okay 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)

Page 3 of 3

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy