Repositioning and resizing the clip – Working with Masks

The sea turtle clip is a little too big for the tablet screen and it’s not quite the right angle. You’ll convert it to a 3D layer, which will give you more control over its shape and size.

  1. Still at 2:07, select the SeaTurtle.mov layer.
  2. With the SeaTurtle.mov layer selected in the Timeline panel, click the 3D switch (3D switch icon) for the layer.

The 3D Transformation Gizmo appears in the Composition panel, and the Properties panel includes the Orientation property and multiple Rotation properties. Most properties in the Properties panel now have three values: From left to right, they represent the x, y, and z axes of the image. The z axis controls the depth of the layer. These axes are represented in the 3D Transformation Gizmo.
Note
You’ll learn more about 3D layers in Lessons 12, “Using 3D Features,” and 13, “Working with the 3D Camera Tracker.”

  1. In the Properties panel, change the Scale to 90%.
  2. Make sure the Selection tool is selected, and then use the 3D Transformation Gizmo in the Composition panel to adjust the position of the video in the screen.
    Drag the red arrow to move the layer horizontally, the green arrow to move it vertically, and the blue arrow to change the depth. Drag the ball along the curved red line to rotate the layer around the x axis; drag the green ball along the curved green line to rotate it around the y axis; and drag the blue ball along the curved blue line to rotate it around the z axis.
  3. Make any additional adjustments, including changes to the Rotation values, so that your composition resembles the following image. Your values may not match ours, depending on how you shifted the SeaTurtle layer earlier.

Tip
To specify whether the 3D Transformation Gizmo affects Rotation or Orientation values, select the Rotation tool in the Tools panel and choose an option from the Set menu. You can also type values directly in the Properties panel instead of dragging in the Composition panel.

  1. Choose File > Save to save your work.

Adjusting the opacity
The video appears abruptly. You’ll smooth its appearance by adjusting the opacity at the beginning.

  1. Make sure you are still at 2:07 in the time ruler and the SeaTurtle.mov layer is selected.
  2. In the Properties panel, change the Opacity to 0%, and then click the stopwatch icon ( ) to create an initial keyframe.
  3. Go to 3:15, and change the Opacity to 100%.
  4. Hide properties for all layers in the Timeline panel, and deselect all layers.
  5. Press the Home key or move the current-time indicator to the beginning of the time ruler, and then press the spacebar to preview your work. Press the spacebar again when you’re done.

Adding a shadow

The masked image looks convincing, but you can make it look even more realistic by adding a shadow to the screen.

  1. Click an empty area in the Timeline panel to deselect all layers, and then choose Layer > New > Solid.
  2. In the Solid Settings dialog box, name the layer Shadow, click the Make Comp Size button, choose a dark gray color (we used R=34, G=34, B=34,), and then click OK.
    Instead of trying to exactly re-create the shape of the TabletVideo.mov layer’s mask, it’s easier to copy it to the Shadow layer and adjust it.
  3. Press the Home key or move the current-time indicator to the beginning of the time ruler.
  4. Select the TabletVideo.mov layer in the Timeline panel, and press the M key to display the Mask Path property for the mask.
  5. Select Mask 1, and then choose Edit > Copy or press Ctrl+C (Windows) or Command+C (macOS).
  6. Select the Shadow layer in the Timeline panel, and then choose Edit > Paste or press Ctrl+V (Windows) or Command+V (macOS).
  7. Hide the properties for the TabletVideo.mov layer.
    This time, you want to keep the area inside the mask opaque and make the area outside the mask transparent.
  8. Select the Shadow layer, and press the F key to reveal the Mask Feather property for the mask.
  1. Change the Mask Feather value to 0 (zero).
  2. Deselect the Inverted option.

The Shadow layer now obscures the SeaTurtle.mov layer.

Creating a Bezier mask – Working with Masks

You used the Convert Vertex tool to change a corner vertex to a smooth point with Bezier handles, but you could have created a Bezier mask in the first place. To do so, click in the Composition panel with the Pen tool where you want to place the first vertex. Then click where you want to place the next vertex, and drag in the direction you want to create a curve. When you are satisfied with the curve, release the mouse button. Continue to add points until you’ve created the shape you want. Close the mask by either clicking on the first vertex or double-clicking the last vertex. Then switch to the Selection tool to refine the mask.

Feathering the edges of a mask

The mask looks good, but the edge of the screen looks a little too sharp and unrealistic. To address this, you’ll feather, or soften, the edges.

  1. Select the TabletVideo.mov layer in the Timeline panel, and press the F key to display the Mask Feather property for the mask.
  2. Increase the Mask Feather amount to 3.0, 3.0 pixels.
  1. Hide the properties for the TabletVideo.mov layer, and then choose File > Save to save your work.

Replacing the content of the mask
You are now ready to replace the background with the video of a sea turtle and blend it with the overall shot.
Tip
In effects that reference layers, you can use masks for greater control over the effect’s influence. You can also use expressions to animate mask points.

  1. In the Project panel, select the SeaTurtle.mov file and drag it to the Timeline panel, placing it below the TabletVideo.mov layer.
  1. Choose Fit Up To 100% from the Magnification Ratio pop-up menu at the bottom of the Composition panel so that you can see the whole composition.
    Note
    If you’re using a Mac with Retina display, you’ll see Fit Up To 200%.
  2. Select the Selection tool ( ), and then drag the SeaTurtle.mov layer in the Composition panel slightly to the left, centering it in the tablet screen.
  3. Go to 2:07. In the Timeline panel, drag the entire SeaTurtle.mov layer to the right so that it begins at 2:07 and ends at the same time as the TabletVideo.mov layer.

Zooming and panning by touch

If you’re using a touch-enabled device, such as a Microsoft Surface, Wacom Cintiq Touch, or multi-touch trackpad, you can use your fingers to zoom and pan. Touch gestures let you zoom and pan in the Composition, Layer, Footage, and Timeline panels.

To zoom: Pinch two fingers closer together to zoom in, or move them further apart to zoom out.

To pan: Move two fingers in unison to pan up, down, left, or right in the panel’s current view.

Inverting the mask – Working with Masks

For this project, you need everything inside the mask to be transparent and everything outside the mask to be opaque. You’ll invert the mask now.

  1. Select the TabletVideo.mov layer in the Timeline panel, and press the M key to see the Mask Path property for the mask.

Tip
Pressing the M key twice in quick succession displays all mask properties for the selected layer.
There are two ways to invert this mask: by choosing Subtract from the Mask Mode pop-up menu, or by selecting the Inverted option.

  1. Select the Inverted option for Mask 1.

The mask inverts.

  1. Press F2 or click an empty area of the Timeline panel to deselect the TabletVideo.mov layer.

Creating curved masks
Curved or freeform masks use Bezier curves to define the shape of the mask. Bezier curves give you the greatest control over a mask’s shape. With them, you can create straight lines with sharp angles, perfectly smooth curves, or a combination of the two.
You’ll use Bezier curves to adjust the mask’s edges around the fabric, red ball, and sea urchin shell that obscure part of the screen.

  1. In the Timeline panel, select Mask 1, the mask for the TabletVideo.mov layer. Selecting Mask 1 makes the mask active and also selects all the vertices.
  2. In the Tools panel, select the Add Vertex tool (Add Vertex tool icon), which is hidden behind the Pen tool.
  3. With the Add Vertex tool, click along the bottom edge of the mask to add a vertex.
  4. Drag the new vertex down to the point where the red ball intersects with the screen.
  5. Add another vertex next to the fabric, and drag it down to the point where the fabric and red ball intersect.
  6. Add vertices at the two points where the sea urchin shell intersects the bottom edge of the screen.
  1. In the Tools panel, select the Convert Vertex tool ( ), which is hidden behind the Add Vertex tool.
  2. In the Composition panel, click the vertex where the fabric and red ball intersect. The Convert Vertex tool changes the corner vertex to smooth points.
  3. Adjust the direction handles until the mask follows the contour of the fabric and the red ball.
  1. Deselect the TabletVideo.mov layer in the Timeline panel to check the edge of your mask. If you need to make adjustments, select Mask 1 in the TabletVideo.mov layer, and use the Convert Vertex tool to fine-tune the shape of the mask.
  2. Choose File > Save to save your work.

Creating a mask with the Pen tool – Working with Masks

The tablet screen is currently blank. To fill it with the video of a sea turtle, you need to mask the screen.

Tip

You can also create a mask using the Mocha effect. To learn more about using the Mocha effect, see After Effects Help.

  1. Go to 2:00, where the video is in full color.
  2. Make sure the TabletVideo.mov layer is selected in the Timeline panel, and then select the Pen tool (Pen tool icon) in the Tools panel.

The Pen tool creates straight lines or curved segments. The tablet screen itself is rectangular, so you’ll try using straight lines first.

  1. Click the lower left corner of the tablet screen to place the first vertex.
  2. Click the upper left corner of the tablet screen to place the second vertex. After Effects connects the two points with a segment.
  3. Click to place a third vertex in the upper right corner of the tablet screen, and then click to place a fourth vertex where the fabric intersects with the right edge of the screen.
  4. Move the Pen tool over the first vertex you created (in the lower left corner). When a circle appears next to the pointer (as in the image on the right below), click to close the mask path.

Tips for creating masks

If you have worked with Adobe Illustrator or Photoshop, or similar applications, you’re probably familiar with masks and Bezier curves. If not, here are a few additional tips to help you create them effectively:

  • Use as few vertices as possible.
  • You can close a mask by clicking the starting vertex. To open a closed mask, click a mask segment, choose Layer > Mask And Shape Path, and deselect Closed.
  • To add points to an open path, press Ctrl (Windows) or Command (macOS), and click the last point on the path with the Pen tool. When the point is selected, you can continue adding points.

About mask modes

Blending modes for masks (mask modes) control how masks within a layer interact with one another. By default, all masks are set to Add, which combines the transparency values of any masks that overlap on the same layer. You can apply one mode to each mask, but you cannot change a mask’s mode over time.

The first mask you create interacts with the layer’s alpha channel. If that channel doesn’t define the entire image as opaque, then the mask interacts with the layer frame. Each additional mask that you create interacts with masks located above it in the Timeline panel. The results of mask modes vary depending on the modes set for the masks higher up in the Timeline panel. You can use mask modes only between masks in the same layer. Using mask modes, you can create complex mask shapes with multiple transparent areas. For example, you can set a mask mode that combines masks and sets the opaque area to the regions where the masks intersect.

Editing a mask

Instead of masking the information inside the tablet, the mask has removed everything outside the tablet. You need to invert the mask. You’ll also use Bezier curves to create a more accurate mask.

About masks – Working with Masks

Lesson overview

In this lesson, you’ll learn how to do the following:

  • Create a mask using the Pen tool.
  • Change a mask’s mode.
  • Edit a mask shape by controlling vertices and direction handles.
  • Feather a mask edge.
  • Replace the contents of a mask shape.
  • Adjust the position of a layer in 3D space to blend it with the rest of a shot.
  • Create a shadow effect.
  • Create a vignette.

This lesson will take about an hour to complete. If you haven’t already done so, download the project files for this lesson from peachpit.com/AfterEffectsCIB2024, following the instructions in the Getting Started section under “Accessing the lesson files and Web Edition.”

PROJECT: SEQUENCE FROM A COMMERCIAL

There will be times when you won’t need (or want) everything in a shot to be included in the final composite. Use masks to control what appears.

About masks

A mask in Adobe After Effects is a path, or outline, that is used to modify layer effects and properties. The most common use of masks is to modify a layer’s alpha channel. A mask consists of segments and vertices: Segments are the lines or curves that connect vertices. Vertices define where each segment of a path starts and ends.

A mask can be either an open or a closed path. An open path has a beginning point that is not the same as its end point; for example, a straight line is an open path. A closed path is continuous and has no beginning or end, such as a circle. Closed-path masks can create transparent areas for a layer. Open paths cannot create transparent areas for a layer, but are useful as parameters for an effect. For example, you can use an effect to generate a running light around a mask.

A mask belongs to a specific layer. Each layer can contain multiple masks.

You can draw masks in common geometric shapes—including polygons, ellipses, and stars—with the shape tools, or you can use the Pen tool to draw an arbitrary path. If you draw a shape when a layer is selected, the shape becomes a mask for that layer; the cursor displays a masked box (Cursor with masked box icon) as you start to draw. If you draw a shape when no layer is selected, After Effects creates a shape layer; the cursor displays a star (Cursor with star icon) as you start to draw.

Using the Graph Editor to remap time – Animating Layers

When remapping time, you can use the values in the time-remap graph to determine and control which frame of the movie plays at which point in time. Each Time Remap keyframe has a time value associated with it that corresponds to a specific frame in the layer; this value is represented vertically on the time-remap graph. When you enable time remapping for a layer, After Effects adds a Time Remap keyframe at the start and end points of the layer. These initial Time Remap keyframes have vertical time values equal to their horizontal positions.

By setting additional Time Remap keyframes, you can create complex motion effects. Every time you add a Time Remap keyframe, you create another point at which you can change the playback speed or direction. As you move the keyframe up or down in the time-remap graph, you adjust which frame of the video is set to play at the current time.

You’ll have some fun with the timing of this project.

Tip

Watch the Info panel as you drag to see more information as you adjust the keyframe.

  1. Select the Selection tool in the Tools panel.
  2. In the Timeline panel, go to 3:00.
  3. In the time-remap graph, Ctrl-click (Windows) or Command-click (macOS) the line at 3:00 to create a new keyframe.
  1. Drag the new keyframe down to 0 seconds.
  1. Go to 0:00, and then press the spacebar to preview the results. Watch the time ruler and Source Time ruler in the Layer panel to see which frames are playing at any given point in time.
    The animation progresses rapidly over the first two seconds of the composition, and then plays in reverse for a second, and the lights go out. The entire animation plays again.
  2. Press the spacebar to stop the preview.
    Having fun yet? Keep going. You’ll adjust the timing so that the lights blink twice before coming on permanently.
  3. Drag the keyframe from 2:00 to 1:00, so that the lights come on in the first second. Then move the next keyframe to 2:00, so that the lights blink off.

Shifting the keyframe affects the timing for the rest of the clip as well. Currently, it’s set to play the 10-second point in the composition at ten seconds, so the angle of speed adjusts accordingly.
You’ll set the lights to blink one more time before continuing the animation. Notice how the angle for the rest of the animation changes as a result; it becomes steeper because there is more animation to cover in less time.

  1. Ctrl-click (Windows) or Command-click (macOS) the line to create additional keyframes at 3:00 and 4:00, moving them to the 4-second and 0-second marks, respectively, so that the lights blink on and off again before the animation begins to play in full.
    Tip
    You can scale the entire animation in time: Click the Time Remap property name to select all of its keyframes, so that you see a free-transform selection box. Then resize the selection box.
  1. Press the spacebar to preview the animation, and press it again to stop it.
    The lights blink on and off, but the text scrolls across the ticker too quickly. You’ll adjust the timing so that it moves more slowly, even though it means the entire text won’t appear before the end of the clip.
  2. Go to 10:00. Then enter 7:00 for the Time Remap value.
  1. Press the Home key or move the current-time indicator to the beginning of the time ruler, and then press the spacebar to preview the animation. Press the spacebar again when you’re done.
    The clip plays for ten seconds, but it ends at the 7-second point in the composition. Now the text moves more slowly—and much more realistically—across the ticker.
  2. Choose File > Save to save your work so far.

Simulating a darkening sky – Animating Layers

The lights come on, but the sky and building remain in daylight. The background should darken as the marquee lights up, showing off the marquee contents and creating a sense of excitement. You’ll use a mask, a solid layer, and a blending mode to provide the contrast.

Creating a mask
You want darkness to fall on the building and sky behind the theater sign. You’ll duplicate the layer, and then create a mask to isolate the area you want to darken.

  1. Press the Home key or move the current-time indicator to the beginning of the time ruler.
  2. In the Timeline panel, select the Lit marquee layer.
  3. Choose Edit > Duplicate. After Effects adds a Lit marquee 2 layer to the layer stack, immediately above the Lit marquee layer.
  4. Select the Pen tool ( ) in the Tools panel.
  5. With the Lit marquee 2 layer selected in the Timeline panel, click the upper left corner of the marquee to start drawing.
  1. Click additional points to continue the mask around the left edge of the marquee, the left and upper edge of the background, and the theatre sign, as in the image below. You’ll need to create some points of the mask on the pasteboard outside the image.
  1. Continue around the theatre sign, and then click your starting point again to close the mask.

Adding a solid layer

Now that you’ve masked the background, you’ll add the layer that will affect it, and then animate the opacity of that layer.

  1. Select the Lit marquee layer in the Timeline panel.
  2. Choose Layer > New > Solid.
  3. In the Solid Settings dialog box, make sure a dark gray color is selected, click Make Comp Size, and then click OK. After Effects adds a layer named Dark Gray Solid 1 between the Lit marquee and Lit marquee 2 layers.

With the current-time indicator at the beginning of the time ruler, most of the image will darken, because neither the Lit marquee layer nor the Lit marquee 2 layer (with its mask) are visible yet. Don’t worry; you’ll animate the solid layer’s opacity to account for that.

  1. Select the Lit marquee 2 layer, and press M if the Mask property isn’t already displayed.
  2. Choose Darken from the Mask Mode menu, and select Inverted.
    You drew around the background, but that’s the area you want to remain unmasked. When you invert the mask, the unselected area becomes masked instead.
  1. Select the Dark Gray Solid layer. Make sure the current-time indicator is at the beginning of the time ruler (0:00). Then, change the Opacity value to 0% in the Properties panel, and click the stopwatch icon ( ) to create an initial keyframe.
  1. Go to 1:23, and change the Opacity to 5%.
  2. Go to 4:09, and click the Add Or Remove Keyframe button to create an additional keyframe with Opacity at 5%.

9. Go to 7:00, and change the Opacity to 75%.

  1. Press the Home key or move the current-time indicator to the beginning of the time ruler. Press the spacebar to preview the animation. When you’re done, press the spacebar again.

As the lights brighten and the text begins to move, the surrounding building and sky gradually darken. Your scene is complete.

  1. Hide the properties for all layers, and save your work.

Adding motion blur – Animating Layers

The text’s movement will look more authentic if it includes motion blur. You’ll add the motion blur and then set the shutter angle and phase, which control the intensity of the blur.

  1. Go to 8:00, so you can see the scrolling text well.
  2. Click Toggle Switches/Modes at the bottom of the Timeline panel.
  3. Click the Motion Blur ( ) switch for the Scroll text layer.
    After Effects enables Motion Blur for the entire composition, and the text layer appears less sharp in the Composition panel.
  4. Choose Composition > Composition Settings.
  5. In the Composition Settings dialog box, click the Advanced tab, and reduce the Shutter Angle to 90 degrees.
    The Shutter Angle setting imitates the effect of adjusting a shutter angle on a real camera, which controls how long the camera aperture is open, gathering light. Larger values create more motion blur.
  6. Change the Shutter Phase to 0 degrees, and then click OK.

Animating using the Corner Pin effect

The marquee is looking pretty good, but the starburst isn’t terribly noticeable. You’ll use the Corner Pin effect to distort it over time and draw attention to it.

Using the Corner Pin effect is similar to animating with the Free Transform tool in Photoshop—the effect distorts an image by repositioning each of its four corners. You can use it to stretch, shrink, skew, or twist an image, or to simulate perspective or movement that pivots from the edge of a layer, such as a door opening.

  1. Go to 4:00.
  2. In the Timeline panel, click the Solo switch (Solo switch icon) for both the Show title and Starburst layers.

Soloing the layers isolates them to speed animating, previewing, and rendering.

  1. Select the Starburst layer in the Timeline panel, and then choose Effect > Distort > Corner Pin. Small circles appear around the corner points of the Starburst layer in the Composition panel.
    Note
    If you don’t see the controls, choose View Options from the Composition panel menu. In the View Options dialog box, select the Handles and Effect Controls options, and then click OK.
    You’ll start by creating initial keyframes at their current locations.
  2. If the Effect Controls panel isn’t already open, choose Window > Effect Controls.
  3. In the Effect Controls panel, click the stopwatch icon ( ) next to each of the pins—Upper Left, Upper Right, Lower Left, and Lower Right—to set initial keyframes.
  1. Go to 6:00, and then drag each of the four corner-pin handles outward. With the Corner Pin tool, you can move each handle a different amount. Notice that the x and y coordinates update in the Effect Controls panel. After Effects adds keyframes.
    Instead of dragging the handles, you can manually enter the values shown in the following figure.
  1. Go to 8:00, and then drag the corner-pin handles so that the text is tilted at an angle. Your corner-pin locations should be similar to those in the figure below. After Effects adds keyframes.
  1. Click the Solo switches ( ) for the Show title and Starburst layers to restore the view of the other layers.
  2. Press the Home key or move the current-time indicator to the beginning of the time ruler. Press the spacebar to preview the entire animation, including the corner-pin effect. When you’re done, press the spacebar again.

10. Choose File > Save to save your project.

About expressions – Animating Layers

When you want to create and link complex animations, such as multiple car wheels spinning, but want to avoid creating tens or hundreds of keyframes by hand, you can use expressions instead. With expressions, you can create relationships between layer properties and use one property’s keyframes to dynamically animate another layer. For example, if you set rotation keyframes for a layer and then apply the Drop Shadow effect, you can use an expression to link the Rotation property’s values with the Drop Shadow effect’s Direction values; that way, the drop shadow changes with the layer as it rotates.

You work with expressions in the Timeline panel or the Effect Controls panel. You can use the pick whip to create expressions, or you can enter and edit expressions manually in the expression field—a text field in the time graph under the property.

Expressions are based on the JavaScript language, but you don’t need to know JavaScript to use them. You can create expressions using the pick whip, by using simple examples and modifying them to suit your needs, or by chaining objects and methods together.

For more information about expressions, see After Effects Help.

Using a track matte to confine animation

Text should scroll across the bottom of the marquee, but only in the black field. You’ll animate the text, and then create a track matte to confine it to the designated area, so that it appears to be an electronic ticker.

Animating the text

The text should start scrolling after the marquee lights up, and it should continue scrolling until the end of the clip.

  1. In the Timeline panel, select the Scroll text layer.
  2. Go to 4:10.
  3. Press Alt+[ (Windows) or Option+[ (macOS) to set the In point to 4:10.

The text will appear on screen at 4:10, shortly after the marquee is fully lit.

  1. With the Scroll text layer selected, change the Position property in the Properties panel to 4994, 1106.
    Only the first character of the text appears in the black ticker area.
  2. Click the stopwatch icon ( ) to create an initial keyframe.
  1. Go to 9:29, the last frame in the clip.
  2. Change the Position property to 462, 2121.

After Effects creates a keyframe. The last character in the text is visible in the ticker field.

  1. Press the spacebar to preview the scrolling text. Press the spacebar again to end the preview.

Importing the footage – Animating Layers

You need to import one source item for this lesson.

  1. Double-click an empty area of the Project panel to open the Import File dialog box.
  2. Navigate to the Lessons/Lesson06/Assets folder on your hard disk, and select the marquee.psd file.
  3. Choose Composition – Retain Layer Sizes from the Import As menu, so the dimensions of each layer will match the layer’s content. (In macOS, you may need to click Options to see the Import As menu.)
  4. Click Import or Open.
  1. In the marquee.psd dialog box, make sure Editable Layer Styles is selected in the Layer Options area, and click OK.
    Before continuing, take a moment to study the layers of the file you just imported.
  2. In the Project panel, expand the marquee Layers folder to see the Photoshop layers. Resize the Name column to make it wider and easier to read, if necessary.

Each of the elements you’ll animate in After Effects—such as the starburst—is on a separate layer. In addition, there is one layer representing the initial marquee with plain light bulbs (Unlit marquee) and a second layer that represents the final marquee with the bulbs brightly lit (Lit marquee).

After Effects preserves the layer order, transparency data, and layer styles from the source Photoshop document. It also preserves other features, such as adjustment layers and type, which you don’t happen to be using in this project.

Preparing layered Photoshop files

Before you import a layered Photoshop file, name its layers carefully to reduce preview and rendering time, and to avoid problems importing and updating the layers:

  • Organize and name layers. If you change a layer name in a Photoshop file after you have imported the file into After Effects, After Effects retains the link to the original layer. However, if you delete a layer in a Photoshop file after you have imported the file into After Effects, After Effects will be unable to find the original layer and will list it as missing in the Project panel.
  • To avoid confusion, make sure that each layer has a unique name.