Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Far Vanish and Near Vanish AE Layers

  • Far Vanish and Near Vanish AE Layers

    Posted by Stephen Moore on August 13, 2019 at 8:37 am

    Hi All,

    I have a camera moving along the Z axis through a series of AE layers and I’d dearly love to be able to Far Vanish/Far Start Fade and Near Start Fade/Near Vanish those layers like in the Visibility tab in Trapcode Form.

    I’ve Googled around and found on (this essentially shows my scene)…

    https://macprovideo.com/article/after-effects/using-distance-from-camera-to-animate-in-after-effects

    …this code…

    start = comp(“Fade”).layer(“Control”).effect(“FadeStart”)(“Slider”);

    end = comp(“Fade”).layer(“Control”).effect(“FadeEnd”)(“Slider”);

    CameraPos = thisComp.activeCamera.toWorld([0,0,0]);

    LayerPos = toWorld(anchorPoint);

    Difference = length(CameraPos, LayerPos);

    linear(Difference, start, end,0,100);

    …which works for the Near Fade and this code…

    startFade = 500; // Start fade 500 pixels from camera.
    endFade = 1500; // End fade 1500 pixels from camera.
    try{ // Check whether there’s a camera.
    C = thisComp.activeCamera.toWorld([0,0,0]);
    }catch(err){ // No camera, so assume 50mm.
    w = thisComp.width * thisComp.pixelAspect;
    z = (w/2)/Math.tan(degreesToRadians(19.799));
    C = [0,0,-z];
    }
    P = toWorld(anchorPoint);
    d = length(C,P);
    linear(d,startFade,endFade,100,0)

    …which works for the Far Fade.

    Does anyone know how to combine the two? That would be brilliant!

    Many thanks in advance…

    Stephen

    Daniel Poffley replied 10 months, 3 weeks ago 3 Members · 2 Replies
  • 2 Replies
  • Cassius Marques

    August 13, 2019 at 2:25 pm

    Sure:startFadeNear = 300;
    endFadeNear = 600;
    startFadeFar = 800;
    endFadeFar = 1500;

    C = thisComp.activeCamera.toWorld([0,0,0]);
    P = toWorld(anchorPoint);
    e = length(C,P);

    if (e<600)

    linear(e,startFadeNear,endFadeNear,0,100)
    else{
    linear(e,startFadeFar,endFadeFar,100,0)
    }

    Cassius Marques
    http://www.zapfilmes.com

  • Daniel Poffley

    May 25, 2023 at 7:54 pm

    Hello. I am struggling to get this code to work.

    The far-fade is working perfectly, but the near-fade doesn’t seem to do anything. Does this code require any updating?

    Thank you in advance.

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