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

  • Franky Torres

    October 15, 2007 at 4:17 pm

    currently I believe their opacity is determained by distance from camera in z space

  • Dan Ebberts

    October 15, 2007 at 7:32 pm

    Well, I’m lost. What I’m picturing doesn’t make any sense. Maybe somebody else (with more imagination) can jump in and help out.

    Dan

  • Sam Moulton

    November 22, 2007 at 6:52 am

    From what I understand you want to pull back through a tunnel of images and as they get a certain distance from the camera you want them to fade out.

    The part I don’t understand is why visibility matters if the layers are behind the camera, because you can’t see them when they are behind the camera. Dan’s expression should work just fine if you establish the proper distances for the images to start and end their fade out.

  • Chad Smith

    January 16, 2009 at 4:48 am

    Would a similar setup work for applying a Fast Blur to a layer based on distance(fake DOF) and if so what would that expression look like? Thanks in advance for any help you can offer.

  • Jim Darski

    October 4, 2012 at 8:31 pm

    Thanks so much. This works very well.
    My question is: is there a way to adjust this expression to fade in when close to the camera in addition to fading out when away from the camera? For example: the object is transparent when closer than 50 from camera. From 100 to 200 its transparency goes from 0 to 100. And then 500 to 1500 it fades out as you have it now.
    I was trying to put additional startFade and endFade commands, but it didn’t work.

    jim

  • Dan Ebberts

    October 4, 2012 at 8:53 pm

    I don’t understand the closer than 50 part (it seems like that’s covered by the 100 to 200 range) but here’s one way to do two ranges:

    C = thisComp.activeCamera;
    startFade1 = 100;
    endFade1 = 200;
    startFade2 = 500;
    endFade2 = 1500;
    d = length(toWorld(anchorPoint),C.toWorld([0,0,0]));
    if (d < (endFade1+startFade2)/2)
    linear(d,startFade1,endFade1,0,100)
    else
    linear(d,startFade2,endFade2,100,0)

  • Jim Darski

    October 4, 2012 at 9:02 pm

    This is exactly what I need! I made a mistake and should have said closer than 100… But you got it. Basically I tried to say that I need to set up 2 ranges.
    Thanks so much!
    j.

  • Nelson Rayner

    January 27, 2016 at 12:10 pm

    Hey Everyone!

    I have several layers (in the Z axis) of pre-composed image grids (with some images missing), that a camera is moving through and around.

    What I’m trying to do is move around and focus on some of these images whilst the layers in the background are more transparent as to make the composition less busy and to focus on the images in the foreground. Also, as the camera moves through the images, the grids become transparent just before they hit the camera.

    I’m having trouble with Dan’s script as when the camera is moving through and around the grids, obviously the anchor point of each becomes further away from the camera and the grids become less opaque.

    What I’m wondering is….if there a way to let the script reference the z position of the layer rather than the anchor point position so as to negate this issue?

    Thanks in advance for helping!

  • Adam Nelson

    September 28, 2016 at 7:10 pm

    Awesome expression, Dan! This really got me out of a jam today on a quick turnaround and it makes me want to learn a lot more about the toWorld command.

    Thanks!

  • Stuart Simpson

    November 28, 2017 at 12:05 pm

    Hi all,

    If I’m reading this correctly I have the same issue. I’ve been using this Dan’s expression (below) for the opacity of a series of layers. With the camera in a master comp and the 3D layers in a pre-comp within the Master comp (the pre-comp is a 3D layer in the master comp with transformations collapsed).

    The problem is the x-position seems to be affecting the opacity and I need just the z position. Any ideas greatly appreciated! 🙂

    startFade = thisComp.layer("opacity controller").effect("start")("Slider");
    endFade = thisComp.layer("opacity controller").effect("end")("Slider");
    C = comp("MASTER").activeCamera;
    CL = comp("MASTER").layer(thisComp.name);
    CL.toWorld(toWorld(anchorPoint));
    d = length(CL.toWorld(toWorld(anchorPoint)),C.toWorld([0,0,0]));
    linear(d,startFade,endFade,100,0)

Page 2 of 3

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