Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Layer transparency based on distance to camera…

  • Layer transparency based on distance to camera…

    Posted by Barend Onneweer on February 17, 2007 at 2:11 pm

    Hi all,

    I’m trying to do the following.

    I have a bunch of layers, and I need their transparency to be linked to the camera position. Thus far no problem. But what I want is to have them be fully opague at the focus point of the camera. And have their transparency fall off when they get closer or further away.

    Ideally I’d use an expression control slider to control the focus distance, and the fallof amount…

    I think I need to bits:

    The exact position in 3D space of the focus point (not the same as the point of interest).

    Based on camera position and orientation, I could probably add the focus distance value with some vector math to figure out the camera focus point position.

    Then second I need to get the layers’ distance to this focus point using length.

    Finally using a linear mapping expression I’d map the distance values to a usable 0 to 100 scale…

    But after spending three hours on this, I’d love to see what you guys can come up with.

    Thanks in advance…

    Raamw3rk – digital storytelling and visual effects

    Noah Campeau replied 11 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Barend Onneweer

    February 17, 2007 at 2:31 pm

    Sheesh, I got it.

    I used a null layer parented to the camera to mark the focus point, and used bits of the expression two threads down to link layer transparency to their distance to the null object.

    Then I tied camera focus distance to the camera’s distance to the null object:

    L = thisComp.layer(“focus point”);
    P1 = L.position – position;
    P2 = toWorldVec([0,0,1]);
    dot(P1,P2);

    Since the null layer is parented to the camera with x and y values being 0, it’s easy to link it’s relative Z-depth to a slide, so now I can control focus distance and falloff with sliders on a separate layer…

    Phew…

    It’s probably possible to do this without the null object, but since it’s controlled by a slider, I can set the layer to shy and forget its existence.

    Thanks anyway.

    Barend

    Raamw3rk – digital storytelling and visual effects

  • Noah Campeau

    June 20, 2014 at 10:34 am

    Bit of a long shot, but do you still have your project files? Really want to know how to do this but can’t crack it

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