Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Made a direction & velocity-based effect but need to modify it to work on parented layers/comp space.

  • Made a direction & velocity-based effect but need to modify it to work on parented layers/comp space.

    Posted by Tim Drage on June 24, 2013 at 10:28 pm

    Hi all,

    I’m designing a a kind of stylised cel-animation-ish motion blur/smear effect using expressions controlling ‘Wave Warp’.

    The way it works is that the Warp Amount depends on how fast the layer is moving and the Warp Direction depends on on the direction it is moving in. On a normal keyframed layer It’s already working surprisingly nicely based on my bodged half-understood edits of an obsolete corner-pin motion blur workaround 🙂 but since i will ultimately use it for character’s limbs etc parented to other moving objects, I need to alter it to work in relation to comp space somehow (& also, if manage to modify it for 3D layers, so that it can happen in relation to camera movement.)

    Here’re my expressions:

    WARP AMOUNT:
    minblur = 130// warp turns off (these first lines limit the warp so it only happens when the object is moving really fast);
    maxblur = 400//warp at highest intensity;
    minamount = 0;
    maxamount = 700;
    var vx=position.velocity[0];
    var vy=position.velocity[0];
    bluramount = Math.sqrt(vx*vx+vy*vy)/20;
    ease(bluramount, minblur, maxblur, minamount, maxamount)

    WARP DIRECTION:
    var pt1=position.valueAtTime(
    time-thisComp.frameDuration/2);
    var pt2=position.valueAtTime(
    time+thisComp.frameDuration/2);
    deltaX = pt1[0] – pt2[0];
    if (deltaX == 0) { deltaX = 1; }
    deltaY = pt1[1] – pt2[1];
    sign = (-deltaX / Math.abs(deltaX)) ;
    radians_to_degrees(Math.atan(deltaY/deltaX)) + sign

    I’ve fiddled about trying to figure out how i’d incorporate toComp or something but don’t really understand Layer Space Transforms well enough yet.

    Any help much appreciated, I hope I managed to explain it OK, pretty tired. 🙂
    Thanks!!

    Tim Drage replied 12 years, 10 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    June 24, 2013 at 11:53 pm

    I’ve only looked at your code briefly, but if the layer is parented, try this for you comp-relative motion:

    var pt1=toComp(anchorPoint,time-thisComp.frameDuration/2);
    var pt2=toComp(anchorPoint,time+thisComp.frameDuration/2);

    You would substitute toWorld() for world-relative.

    Dan

  • Tim Drage

    June 25, 2013 at 10:35 am

    Thanks very much for the quick reply!

    That works a treat for the direction expression thanks, but I’m still not sure how to apply toComp to the warp amount.
    I tried:

    var vx=toComp(anchorPoint.velocity[0]);
    var vy=toComp(anchorPoint.velocity[0]);

    But that gives me “Bad argument: First argument to toComp must be a vector of length 2 or 3.”

    Will keep trying to figure it out. 🙂

  • Dan Ebberts

    June 25, 2013 at 1:29 pm

    I think you’ll have to do it the same way you do the direction calculation–get 2 points, half a frame before and after the current time and use that to calculate the velocity.

    Dan

  • Tim Drage

    June 25, 2013 at 3:01 pm

    Thanks for the pointer. I copied that part of the expression from a tutorial so I shall have to actually learn how it quite works ha. 🙂 Pasting the direction expression in there actually kind of ‘works’ tho gives weird results presumably due to the angle calculating stuff. Hopefully I can get my head around it!

  • Tim Drage

    June 28, 2013 at 12:27 pm

    OK I’m getting somewhere, learned something about calculating distance between two points. 🙂 This expression – modified from one on https://www.jjgifford.com/expressions/geometry/length.html – seems to be getting me there.

    // Pick 2 points
    point1=toComp(anchorPoint,time-thisComp.frameDuration/2);
    point2=toComp(anchorPoint,time+thisComp.frameDuration/2);
    // Find the vector between them
    delta=sub(point1, point2);
    X=delta[0];
    Y=delta[1];
    // Now find the length
    distance=Math.sqrt(X*X+Y*Y);

    Not quite got my head around whether I’m even getting ‘velocity’ per se but it will work for my purposes once i add controls to limit the amount and threshold.

    Thanks again for your help 🙂

  • Tim Drage

    June 28, 2013 at 12:47 pm

    something like this, will change the values to sliders controls.

    minblur = 42// warp turns off (these first lines limit the warp so it only happens when the object is moving really fast);
    maxblur = 100//warp at highest intensity;
    minamount = 0;
    maxamount = 500;
    // Pick 2 points
    point1=toComp(anchorPoint,time-thisComp.frameDuration/2);
    point2=toComp(anchorPoint,time+thisComp.frameDuration/2);
    // Find the vector between them
    delta=sub(point1, point2);
    X=delta[0];
    Y=delta[1];
    // Now find the length
    bluramount =Math.sqrt(X*X+Y*Y)/4;
    ease(bluramount, minblur, maxblur, minamount, maxamount)

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