Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions atmospheric fade expression

  • atmospheric fade expression

    Posted by Chris Dc on July 9, 2007 at 6:41 pm

    hey,

    i’ve been working on an expression to create a styled atmospheric fade in after effects 3d. based on dan’s light falloff expression i retooled it to give a percentage value based on the distance between an object and the camera using the zoom length as the falloff point. i then use a linear interpolation so i can pump the percent value into any variable, in this case an individual levels input white point.

    i was hacking the script in a the rotation variable in a null layer and was getting the values i was looking for, a value between 144 and 255.

    when i copied and pasted the script into levels input white point it gave me a static 36720.

    which i have no idea how that happened.

    can someone help me clean up this expression?

    decay = .05;
    noFalloff = thisComp.layer(“Camera 1”).cameraOption.zoom;

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

    d = length(L.transform.position,transform.position);
    if (d < noFalloff){ x = 0; }else{ x = Math.exp((d - noFalloff)*decay); } if (x > 100){
    100;
    }else{
    x;
    }
    linear(x, 0, 100, 144, 255)

    you’ll need a 3d layer and a camera called “Camera 1” default stuff here.

    thanks,
    chris d-_-b

    Chris Dc replied 18 years, 9 months ago 3 Members · 6 Replies
  • 6 Replies
  • Filip Vandueren

    July 9, 2007 at 7:00 pm

    Hi there,

    Levels are expressed in percentages. so a whitepoint of 255 is actualy 1.0 when you set it with an expression.

    this would work:

    linear(x, 0, 100, 144/255, 1)

  • Chris Dc

    July 9, 2007 at 10:26 pm

    PERFECT!

    thanks so much. wondering if there’s a list for how effect variables are interpolated somewhere. are all 0 to 255 value ranges actually percentages?

    love for expressions rising.

  • Filip Vandueren

    July 9, 2007 at 10:38 pm

    Well, off the top of my head, I can’t think of another plugin that actually operates on colourchannels in a numerical way.
    Perhaps “Threshold”, but I think that one actually doesn’t work with 0-1.

    Effects that have a colour-swatch input, however, should also be set with an array of 0-1 values for RGB (and often Alpha):

    [1, 0.8, 0.1, 1] would be an orange colour, with full alpha.
    in 32bits mode colours can go beyond 0 and 1 (floating point)

    When in doubt:

    create a text-layer, and twirl open the sourceText property.
    Give it a pickwhip-expression to the property you’re curious about,
    and you’ll see it’s value on screen.

    I use that all the time.

  • Craig Wall

    July 13, 2007 at 12:19 am

    Philip, I love that tip with pick whipping the value into a text field.

    That (inherently?) won’t work with arrays, will it?

  • Filip Vandueren

    July 13, 2007 at 12:56 am

    When you get something weird,
    you can allways add .value or .toString() after the pickwhipped expression.

    for example:

    thisComp.layer(“test”).transform.opacity.value;

    the first one should be necessary: if you’re just pickwhipping to opacity, you’re actually referencing the ‘concept’ of that layer’s opacity: the property itself if you will…
    However, After Effects motionscript is usually clever enough to figure out you actually want the value.

    I have had a few occasions where it was necessary though, most notably in “scale”: a property containg an array. After pickwhipping, the textlayer will just say “[Object Property]”. Indeed Scale is an Object Property, but we want to know it’s value,

    so adding .value at the end of the line will work !

    thisComp.layer(“test”).transform.scale.value;

    Some stuff like the curve of a Curves effect, or the histogram of a Levels effect, or the gradient in a fill, are custom datatypes: they are objects that can’t be converted to strings.

  • Chris Dc

    July 18, 2007 at 9:39 pm

    hey again,

    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

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