Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Ramp up opacity with Z position

  • Ramp up opacity with Z position

    Posted by Bram Rusman on May 14, 2012 at 3:04 pm

    Hi there,

    I have a bunch of solids placed in z space. I want to animate them like the Apple Time Machine effect.
    The part that does the z-space animation is obvious. But when a layer is at position 0 in z-space I want that layer to become at 100% opacity. When it crosses the 0 point it fades out to 0% opacity. So: all the layers are behind the layer that is on 0, they are at let’s say 50% opacity. When the layers move towards the camera the opacity changes.

    A good example is the Dock Effect expression. But instead of scale, i want to use opacity.
    Like the expression below.

    f = 2; //factor to increase scale by
    min = 0; //distance in pixels from the center where the layer is at full scale
    max = 300; //distance in pixels from the center where the layer is at 'normal' scale
    c = [thisComp.width / 2, thisComp.height / 2]; //center of the composition
    p = toComp(anchorPoint); //location of the current layer in the composition
    d = Math.abs((p - c)[0]); //distance from the center along the x-axis
    ease(d, min, max, f * value, value);

    Kevin Camp replied 14 years ago 2 Members · 3 Replies
  • 3 Replies
  • Kevin Camp

    May 14, 2012 at 6:43 pm

    a simple one using ease could be something like this:

    maxZ = 500; // this would be the z position where the layer would not be visible
    ease(Math.abs(position[2]), maxZ, 0, 100, 0)

    if you wanted more control over the fade falloff and the amount of distance that the layer could stay at 100% opacity, then this might be better:

    noFalloff = 200; // this would be the ‘zone’ where the layer would be 100%
    decay = .005; // use this to adjust how quickly the layer fades in/out
    d = Math.abs(position[2]);
    value/Math.exp((d-noFalloff)*decay)

    — the later expression is is based on dan ebbert’s light falloff expression here, if you’d like a full description of what it’s doing:

    https://www.motionscript.com/design-guide/falloff.html

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Bram Rusman

    May 15, 2012 at 8:07 am

    Hey Kevin,

    Thanks for your information! I was wondering if it was possible to set the opacity of the layers behind could set to 50% opacity (like a stack of solids). The layer what’s on the zero point always is 100%, when it crosses that point towards the camera, it goes to 0%.
    Again, thanks for for help!

    Bram

  • Kevin Camp

    May 15, 2012 at 3:24 pm

    i missed that part in you original post…

    the first expression would be easiest to work in a conditional… like this:

    maxZ = 500;
    z = position[2];
    if (z > 0) minO = 50 else minO = 0;
    ease(Math.abs(z), maxZ, 0, 100, minO)

    you could potentially have different maxZ values too, one for where the layer starts to become more opaque and another for when the layer goes to zero opacity.

    z = position[2];
    if (z > 0){
    minO = 50;
    maxZ = 800;
    }else{
    minO = 0;
    maxZ = -200;
    }
    ease(Math.abs(z), maxZ, 0, 100, minO)

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

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