Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression Motion Blur

  • Expression Motion Blur

    Posted by Chris Zinner on April 25, 2016 at 9:52 pm

    Hi there,

    im stupid and can’t script and i was lucky that i’ve found the following expression to move text up the screen in constant increments:

    f = timeToFrames(time);
    line = Math.floor(f/25);
    pix = Math.min(f%25,10);
    pixe = ease(pix, 0, 10, 0, 60);
    value – [0, line*60+pixe]

    Now i’ve got some questions about that expression.

    I’ve figured out that “60” is the amount of pixels the layer is moved.
    I’ve also figured out that if i raise both of the “25” values to lets say 50, it moves the layer every 2 seconds instead of 1.

    But how can adjust the time it takes for the move?

    Maybe somebody can explain in simple words what the lines of the script do so i can understand better what’s going on here.

    Another thing is motion blur, it acts weird when turned on.
    I’ve put the script on a null.
    That null drives a text layer, much like a title scroller but it moves in increments.
    When i turn on motion blur for that text layer it looks like the layer gets copied and made half transparent.
    But there is no blur.
    Must’ve something to do with the way AE calculates the movement controlled by the expression.

    Is there a way to make motion blur work with that expression or do i need a different expression for that?

    Thank’s a lot,
    cheers,
    Chris

    f = timeToFrames(time);
    line = Math.floor(f/25);
    pix = Math.min(f%25,10);
    pixe = ease(pix, 0, 10, 0, 60);
    value - [0, line*60+pixe]

    Chris Zinner replied 10 years ago 2 Members · 5 Replies
  • 5 Replies
  • Ross Klettke

    April 25, 2016 at 10:48 pm

    Hey, you might find this simplified version helpful (I’ve added some explanatory comments):

    movementDuration = .5; // in seconds
    movementAmount = -200;

    //here the ease function reads the current time and compares it to the next 2 parameters: 0 and movementDuration. If the time is 0, then the ease function outputs 0 (the 4th parameter). If the time is equal to movementDuration, then the ease function outputs movementAmount (the 5th parameter).
    yValueChange = ease(time, 0, movementDuration, 0, movementAmount);

    //finally, we take the initial position of the layer and modify it with what the ease function gave us
    value + [0, yValueChange];

    ————-

    The weird motion blur thing is a byproduct of using the frameNumber as input to the ease function. Basically — to create motion blur, After Effects renders a bunch of images of your composition at times that are slightly off your current time. Then it merges these images into the final motion-blurred image that you see.
    Most of these “slightly off in time” images don’t fall on a whole-frame number. Example: If you are trying to render Frame 15 with motion-blur, then AE might be combining the images at Frame 15 and Frame 14.8 and Frame 14.6 and 14.4 and 14.2 and 14… etc

    Because the initial expression you have uses just the whole frameNumber (not allowing any of the 14.8, 14.6, etc), when AE tries to render frame 14.8, the expression is actually just telling AE about the layer’s position at Frame 14.

    The easy way to fix the motion blur, as the attached script does, is to just use seconds instead of frames. Using “time” gives you seconds and includes partial seconds (example: 1.255 seconds)

    Hope that helps!

    movementDuration = .5;
    movementAmount = -200;

    yValueChange = ease(time, 0, movementDuration, 0, movementAmount);

    value + [0, yValueChange];

  • Ross Klettke

    April 26, 2016 at 12:34 am

    Oh, I forgot to mention: The expression I attached doesn’t have the on/off movement of your original expression (currently, it only includes the upwards y motion with a duration) but it is a nice simple platform for adding that functionality if you want.

  • Chris Zinner

    April 28, 2016 at 10:56 am

    Thank you very much for your time.

    Your are right, with the expression i posted there’s a stop after each y movement.

    It would be great if i could also adjust for how long the movement stops before it starts to move again in y.

    Could you add that to the expression, would be perfect then.

    Thank’s a lot!

  • Ross Klettke

    April 28, 2016 at 3:55 pm

    Sure, expression attached

    movementDuration = .5;
    pauseDuration = .5;
    movementAmount = -50;

    ////////////////

    sequenceDuration = movementDuration + pauseDuration;
    whichIteration = Math.floor(time / sequenceDuration);

    seqStartTime = whichIteration * sequenceDuration;
    moveEndTime = seqStartTime + movementDuration;

    startYPos = whichIteration * movementAmount;
    endYPos = (whichIteration + 1) * movementAmount;

    yValueChange = ease(time, seqStartTime, moveEndTime, startYPos, endYPos);

    value + [0, yValueChange];

  • Chris Zinner

    April 30, 2016 at 1:17 am

    Works perfectly, and it’s really easy to adjust the timing now!

    I now understand why the other expression did not work well with motion blur.

    Thank’s a lot, you just saved my project which is going to be screened in a big arena with about 8000 visitors next week!
    PM me and i’ll paypal you a beer or two. 😉

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