Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › AE7 linking opacity of layer to camera

  • AE7 linking opacity of layer to camera

    Posted by Purplepixel on September 28, 2006 at 11:10 am

    This is probably a very easy problem for an advanced expression user, but difficult for me! Basically I want to link the opacity of layers in 3d space to the position (z depth) of the camera, so that the further away the camera, the lower the opacity of the layers.

    Any help with this would be a great help…

    Purplepixel replied 20 years ago 2 Members · 2 Replies
  • 2 Replies
  • Mike Clasby

    September 28, 2006 at 5:02 pm

    Here are two previous posts from Dan, the first tying opacity to Z distance from camera. The second doesn’t effect the opacity but makes the layer get darker with distance from the camera and is actually a much neater solution, avoiding seeing through layers at a distance, when layers overlap their lowered opacity and seeing though one layer can be a bit strange looking .

    Name: Dan Ebberts

    Date: Jun 22, 2006 at 12:26:11 pm

    Subject: Re: An Expression for Opacity

    Sure. For reference, here’s the expression again

    startFade = 1000;

    endFade = 2000;

    d = position[2] – thisComp.layer(“Camera 1”).position[2];

    linear(d,startFade,endFade,100,0)

    The first two lines just set the z distance from the camera for the fade to start and end. The third line calculates the z distance from the camera.

    In English, the forth line just says “as d varies from 1000 to 2000, ramp opacity from 100 to 0”. At distances less than 1000 the opacity will be 100 at distances greater than 2000 the opacity will be 0.

    Instead of linear() you could try easeIn() and easeOut()

    Hope that helps.

    ——————————–

    Name: Dan Ebberts
    Date: Aug 24, 2006 at 2:36:30 pm
    Subject: Re: Wow. That’s intense. Ok, Thanks! errr…I think I’ll go with Buena-Plugin.

    A little late to the party, but here’s a fun thing to try. Add this expression to the diffuse and specular material options of your 3D layer:

    decay = .001; // speed of falloff
    d100pct = 200; // distance from light where falloff begins

    L = thisComp.layer(“Light 1”);

    d = length(L.position,position);
    if (d < d100pct){ value; }else{ value/Math.exp((d-d100pct)*decay); } The first parameter has the most effect on how fast layers get dark as they move away from the light. The advantages of this approach are that the layers don't become transparent and the effect is independent for each layer since the intensity of the light itself is not affected. Dan

  • Purplepixel

    September 29, 2006 at 9:02 am

    thanks, that works well and the light option is useful for more realistic animations. That would have saved me hours of work on my last job!

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