Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Drop Shadow Expression Question

  • Drop Shadow Expression Question

    Posted by Pat Bray on November 10, 2011 at 4:41 pm

    Hi

    I wondered, is there an expression that could be applied to a drop shadow’s distance and/or direction, which would alter the effect as a layer is moved? Basically, I want to give the illusion that a layer has some depth to it, preferably without duplicating it and moving the copy back and colour correcting (keeping the amount of layers in my comp to a minimum), so as the layer is moved the drop shadow would shift a little to match the perspective, nothing drastic, just enough to give the impression that the layer has a little depth.
    Would it be possible to say, Drop Shadow distance & direction = 0 when layer is in the centre of the comp, and then distance = 4 (for example) on the edge of the comp, and the direction depends on which edge the layer has moved towards?

    Dan Ebberts
    replied 14 years, 5 months ago
    2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    November 10, 2011 at 5:23 pm

    I assume you’re talking about the Layer Style Drop Shadow. Try this for Angle:

    center = [thisComp.width,thisComp.height]/2;
    delta = center – toComp(anchorPoint);
    -radiansToDegrees(Math.atan2(delta[1],delta[0]));

    and this for distance:

    center = [thisComp.width,thisComp.height]/2;
    delta = center – toComp(anchorPoint);
    linear(length(delta),0,thisComp.width/2,0,4)

    Dan

  • Pat Bray

    November 10, 2011 at 6:06 pm

    Thanks for the help Dan, it’s almost there although the angle isn’t quite working. It looks right when the layer is in the top right side, so the shadow is bottom left, but in the other corners of the comp the shadow isn’t pointed toward the centre….

  • Dan Ebberts

    November 10, 2011 at 6:14 pm

    You want the shadow to point towards the center? Try changing the last line of the Angle expression to this:

    180-radiansToDegrees(Math.atan2(delta[1],delta[0]));

    Dan

  • Pat Bray

    November 11, 2011 at 10:54 am

    Hi there, I tried that and it works in the top left and bottom right but not the other areas, the drop shadow moves outwards rather than pointing in towards the centre.

  • Dan Ebberts

    November 11, 2011 at 6:02 pm

    You must be using the drop shadow effect, not the layer style. Try changing the last line to this:

    90 + radiansToDegrees(Math.atan2(delta[1],delta[0]));

    Dan

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