Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Fade opacity of a 3D shape layer based on distance from another layer

  • Fade opacity of a 3D shape layer based on distance from another layer

    Posted by Kevin Lamb on March 1, 2011 at 2:01 am

    Hi.

    I have a grid of images roughly 16×16, and a Line (shape layer) snaking through the vertical and horizontal gaps of the grid until it drops out the bottom.

    I am trying to get my head around a script that would change the opacity of the images as the line passed between them, so as the line moves past the images, they would appear.

    I found the script below on the adobe website which changes the opacity of a layer depending on the distance from the camera, I tried to use a Null instead of a camera that followed the line, but with no success,

    Anyone any ideas?

    Thanks

    K

    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)

    Trent Armstrong replied 15 years, 6 months ago 2 Members · 1 Reply
  • 1 Reply
  • Trent Armstrong

    March 8, 2011 at 7:32 pm

    First, make sure to apply this to the Opacity of each layer that will appear/disappear.

    Then make sure it’s looking for the Null instead of a Camera.

    Lastly, you’ll need to make sure your distances are appropriate and not too close or too far. Something like StartFade = 150 and endFade = 50. You can judge that or hook up some Expression Control Sliders.

    startFade = 150; // Start fade 300 pixels from Null 1
    endFade = 50; // End fade 150 pixels from Null 1
    try{ // Check whether there is a Null 1
    C = thisComp.layer("Null 1").toWorld([0,0,0]);
    }catch(err){ // No Null 1

    C = [thisComp.width * .5, thisComp.height * .5] // Centers effect around middle of Comp

    }
    P = toWorld(anchorPoint);
    d = length(C,P);
    linear(d, startFade, endFade, 100, 0)

    Trent Armstrong – Creative Cow Leader
    https://www.dallasaeug.com

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