Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions round 2 with a distance fade

  • round 2 with a distance fade

    Posted by Chris Dc on July 19, 2007 at 9:12 pm

    sorry, reposting this because it got buried in a preivous thread…

    i’ve revamped the script to make it more malleable. strange things happen though when i scale an object. it inversely effects the end result of the script, ie. scale up, the effect lessens, scale down the effect increases. here’s the current script.

    Q=thisComp.layer(“atmopheric master control”); // Effect control null
    startFade = Q.effect(“Start Close Up”)(“Slider”); // Effect begins at this distance from cam
    endFade = Q.effect(“End Close Up”)(“Slider”); //Effect ends at this distance from cam

    C = thisComp.activeCamera.toWorld([0,0,0]); // Cam position
    x = thisComp.activeCamera.position[0]; // Cam x position
    y = thisComp.activeCamera.position[1]; // Cam y position
    z = anchorPoint[2]; // Object z position
    P = toWorld([x,y,z]); // Object relative position on the z-axis from Cam
    d = length(C,P); // Distance Calculation
    easeOut(d,startFade,endFade,Q.effect(“Color Balance (HLS) Zoom”)(“Saturation”),0) // Actual effect based on startFade & endFade parameters

    i base the distance from the object to the cam only on the z axis because i have a bunch of off centered anchor points for animation and it reads the distances further away compared to two objects on the same plane.

    …er, yeah.

    so why is scale coming into effect here? is it because i’m using toWorld?

    thanks
    chris d-_-b

    Darby Edelen replied 18 years, 9 months ago 2 Members · 5 Replies
  • 5 Replies
  • Darby Edelen

    July 20, 2007 at 6:24 am

    [chris dc] “P = toWorld([x,y,z]); // Object relative position on the z-axis from Cam”

    I must admit that I’m not as familiar with the layer space transformation functions as I’d like to be, but this takes the Camera’s X and Y position values and the current layer’s anchor point Z value and transforms them from the current layer’s layer space to world space, right? Is there a reason you don’t use the current layer’s Z position instead? Again, I’m not entirely comfortable with space transformations… but using the anchor point kind of throws me for a loop.

    Darby Edelen
    DVD Menu Artist
    Left Coast Digital
    Aptos, CA

  • Chris Dc

    July 20, 2007 at 6:13 pm

    y’know, i’m not sure why i try to make something more complicated than it needs to be.

    scraping toWorld and just using position.value[2] works.
    still confused exactly why scale effects toWorld though…

    btw, thank you to creative cow and this forum. learned alot (i.e. almost everything) from reading these posts.

    chris d-_-b

  • Chris Dc

    July 24, 2007 at 12:28 am

    GAH! new snag,
    the expression is reading the position value of parented layers as relative to the parent layer, so things are messed up.

    again.

    so
    if i use toWorld ae for some reason puts scale into the equation skewing scaled layer position information,

    if i use position[2], parented layers give relative position information of the parent layer,

    is there some way to get actual z space info on a layer that is absolute and will not be effected by scale so i can compare it to the camera distance.

    this is driving me the crazy.

    chris d-_-b

  • Darby Edelen

    July 24, 2007 at 1:33 am

    Does this work?


    Q=thisComp.layer("atmopheric master control"); // Effect control null
    startFade = Q.effect("Start Close Up")("Slider"); // Effect begins at this distance from cam
    endFade = Q.effect("End Close Up")("Slider"); //Effect ends at this distance from cam

    C = thisComp.activeCamera.toWorld([0,0,0]); // Cam position
    x = thisComp.activeCamera.position[0]; // Cam x position
    y = thisComp.activeCamera.position[1]; // Cam y position
    z = position[2]; // Object z position
    P = toWorld([x,y,z]); // Object relative position on the z-axis from Cam

    d = length(C,P); // Distance Calculation
    easeOut(d,startFade,endFade,Q.effect("Color Balance (HLS) Zoom")("Saturation"),0) // Actual effect based on startFade & endFade parameters

    Darby Edelen
    DVD Menu Artist
    Left Coast Digital
    Aptos, CA

  • Darby Edelen

    July 24, 2007 at 1:41 am

    Alternatively, you could just convert the layer’s position toWorld() before you use the Z-value:

    z = toWorld(position)[2];

    Darby Edelen
    DVD Menu Artist
    Left Coast Digital
    Aptos, CA

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