Tuesday, 19 April 2016

My New Favorite Expression in Adobe After Effects

There’s a tough lesson that all us motion graphics designers must learn and that’s maintaining a clean and organized workflow. But simply defining a labeling system for project files, comps and comp layers is the bare minimum. It’s imperative that we rig our scenes in a manner that allows for quick revisions as well as a smooth transfer to teammates. As we design and animate, we have to constantly ask ourselves, “If I can’t come in to work tomorrow, could somebody else pick this up easily?” or, “If the client doesn’t care for this, how quickly could I modify or reverse it?”

Working in a collaborative and client-based work environment, I’m constantly researching new tactics in order to help anticipate both scenarios. Most of these tactics involve using expressions in After Effects in lieu of excessive keyframing. Lately, I’ve come to particularly favor interpolation expressions. These can be used to have one object’s animation drive another (similar to parenting but with better precision). I used these expressions almost exclusively for a lower third template I developed recently for a virtual tour. This template is a great example of how expressions can be used to simplify a scene for yourself and your fellow designers.

My objective was to have the element, in this case, a cross, enter the scene and do a wipe reveal of the text.

Of course, from an animation standpoint, this is a very simple task to complete. However, this scene was going to be reused several times for a variety of phrases. These phrases would more than likely have to be modified without losing consistency. Hence, the layout had to be simple not just from an animation standpoint but from a user experience standpoint as well.

I began by animating the scale, rotation, and position of the cross. This was done with basic key framing. 

For the position, I knew I wanted the cross to end up on screen left no matter what. Its starting point, however, would depend on the length of the text inserted. I wanted the user to be able to adjust the text box’s length to match the width of the text without having to modify the cross’s keyframes. Thus, I had to write an expression that would allow the starting value of the cross’s position to change but the end value to stay constant. In other words, as the scene progressed from keyframe 1 to keyframe 2, the cross would move from point A to point B, with point A being the right end of the text box and point B being the left end of the text box (which would never change).

With these four variables in mind, I could proceed to create my interpolation expression.

Before writing my code, I first created a null object and positioned it to the right of the screen (at this point it didn’t have to be anywhere in particular). The position of this null object was to be my reference point for the cross’s starting value.

Next, I loaded my expression from the expression language menu.

Now, before we dive in and start plugging in numbers, I’m going to explain what we’re looking at here. Let’s not worry about the easeOut for now and move on to t, t1, and t2. “t” is the variable that this particular property (the cross’s position) is referencing. “t1” and “t2” are the minimum and maximum values of that reference.

“Value1” and “Vaule2” correspond to the property containing the expression, in this case the cross’s position. These need to be set to the desired minimum and maximum values of the containing property.

Hence, while our reference property “t” is progressing from “tMin” to “tMax”, the property in which the expression is contained, in this case, the cross’s position, will progress from “Value1” to “Value2.” The easeOut at the beginning is to clarify the interpolation of the cross’s movement. In this case, I desired the cross to ease into its final position. Now all I had to do was define “t”.

Again, my objective was to have the cross move from the point of the null object to its value at keyframe 2 over the same time frame that both keyframes were set. Hence, “t” would represent time and “tMin” and “tMax” would represent the cross’s position keyframes that I had already created.

I also needed to define the starting value of the cross’s position. So I created another variable called “p1” (though it could have been anything) and pick-whipped it to the null’s X position (for clarity, I renamed the null to “Starting Position”.

Now I could replace “Value1” with “p1”.

Value2 was going to be the constant value of the second keyframe. Hence, I replaced it to read “ValueAtTime(tMax).”

Now, no matter where I placed the null object the cross would begin its animation at its position but always finish at the value of the second keyframe.

I used the same type of expression to program the rest of the scene. Both the scale of the textbox and the transition of its reveal (which I completed using a stencil matte with a linear wipe) had to be synced up with the cross. This proved very simple once I determined the minimum and maximum values of each property.

I’m not going to explain these expressions in great detail but I’m going to point out a couple of things. First of all, I set both of these to linear so that they would lock onto the cross for its entire movement. Also, for the background’s scale, I had to specify the value for both X and Y. Since it was just scaling horizontally, I set the interpolation expression to x and left y as a constant value.

As a final touch, I programmed a slider control to adjust the position of the null (or “Starting Position” and placed it into a layer called “Master Control.”

Now, whenever anybody had to create a lower third, all they had to do was enter the text and adjust the slider’s value. Hence, with just a little bit of code, a template was created that allowed for quick modification and could be easily transitioned to my teammates.

While it may seem on the surface that manually adjusting keyframe values may be simpler than programming code, hopefully, my fellow motion graphics designers will find that, in the long run, taking the extra time to setup a few expressions will help save time and reduce inconsistencies in their work. If any of this seems a little overwhelming, you’re not alone. I too used to be confused by expressions and, to this day, have only scratched the surface of their capabilities. I strongly urge any motion graphics designer to at least try them out. For me, they have opened many doors in terms of creating cleaner project files and grasping a better understanding of the backroads in programming animation. Are you interested in a motion graphics project? Our team is here to assist you. Give us a call at 832-831-7592!

No comments:

Post a Comment