Adjusting the shape of the mask – Working with Masks

The neighboring objects should cast a shadow, but it shouldn’t affect the entire screen. You’ll use the Pen tools to reduce the mask to cover only the lower right section of the screen.

  1. Select the Delete Vertex tool (Delete Vertex tool icon), hidden beneath the Convert Vertex tool in the Tools panel.
  2. Click the upper left vertex to delete it.
  1. Select the Selection tool ( ) in the Tools panel, and then drag the lower left and upper right vertices closer to the lower right corner of the screen, as in the following image.
  1. Select the Add Vertex tool ( ), hidden beneath the Delete Vertex tool in the Tools panel.
  2. Add vertices to the upper path (currently a diagonal line), and then use the Convert Vertex ( ) and Selection tools to position and shape the path into a curve similar to the following images.

Feathering the edges of the shadow
Shadows rarely have sharp edges. You’ll adjust the feather for the mask so that the shadow fades into the rest of the screen.

  1. Go to 3:15.
  2. Select the Mask Feather tool ( ), hidden beneath the Convert Vertex tool ( ) in the Tools panel.
    You used the Mask Feather property to adjust the width of the feather the same amount all the way around the original mask. However, the Mask Feather tool gives you more flexibility, letting you vary the feathering width at points you define on the closed mask.
  3. In the Timeline panel, select the Shadow layer. Then, in the Composition panel, click the lower left vertex to create a feather point.
  4. Click the feather point again, and without releasing the mouse button, drag that feather point outward to increase the feathering margin for the entire mask.

Currently the feather, represented by dashed lines, extends evenly across the mask. You’ll add more feather points for greater flexibility.

  1. Click the vertex on the right side of the sea urchin.

A feathering point is created, and the feather shrinks back to the mask edge on the lower and right sides of the screen, but the feathering remains on the upper side of the mask. The objects that are casting the shadow shouldn’t be shadowed.

  1. Click the dashed line just under the vertex on the left side of the sea urchin, and drag the feathering boundary up to the screen.
  1. (Optional) Adjust the feathering elsewhere by creating a feather point on the boundary and dragging it.
    Now the shadow doesn’t appear on any of the objects.
    The shape of the shadow is good, but it’s obscuring the image. You’ll change the opacity to reduce its effect.
  2. Select the Shadow layer in the Timeline panel, and then change its Opacity value to 20% in the Properties panel.

9. Hide all properties in the Timeline panel, and then press F2 or click an empty area in the Timeline panel to deselect all layers.

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.

Getting started – Working with Masks

In this lesson, you will create a mask for the screen of a tablet and replace the screen’s original content with a movie. Then you’ll adjust the positioning of the new footage so that it fits the perspective of the shot. Finally, you’ll polish the scene by adding a shadow and creating a vignette effect.
Begin by previewing the movie and setting up the project.

  1. Make sure the following files are in the Lessons/Lesson07 folder on your hard disk, or download them from peachpit.com now:
    • In the Assets folder: SeaTurtle.mov, TabletVideo.mov
    • In the Sample_Movie folder: Lesson07.mp4
  2. Open and play the Lesson07.mp4 sample movie in Windows Movies & TV or QuickTime Player to see what you will create in this lesson. When you are done, close Windows Movies & TV or QuickTime Player. You may delete the sample movie from your hard disk if you have limited storage space.
    When you begin the lesson, restore the default application settings for After Effects. See “Restoring default preferences” on page 3.
  3. Start After Effects, and then immediately hold down Ctrl+Alt+Shift (Windows) or Command+Option+Shift (macOS) to restore default preferences settings. In the Startup Repair Options dialog box, click Reset Preferences. Then, click New Project in the Home window.
    After Effects opens to display a new, untitled project.
  4. Choose File > Save As > Save As, and navigate to the Lessons/Lesson07/Finished_Project folder.
  5. Name the project Lesson07_Finished.aep, and then click Save.

Creating the composition
You’ll import two footage items for this exercise. Then, you’ll create the composition based on the aspect ratio and duration of one of the footage items.

  1. Double-click an empty area of the Project panel to open the Import File dialog box.
  2. Navigate to the Lessons/Lesson07/Assets folder, Shift-click to select the SeaTurtle.mov and TabletVideo.mov files, and then click Import or Open.
  3. Deselect both files in the Project panel. Then select the TabletVideo.mov footage item, and drag it onto the Create A New Composition button ( ) at the bottom of the Project panel.

After Effects creates a composition named TabletVideo and opens it in the Composition and Timeline panels.

  1. Choose File > Save to save your work so far.

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.

Adding Easy Ease – Animating Layers

You’ll soften the shift in time that occurs when the lights blink with Easy Ease.

  1. Click to select the keyframe at 1:00, and then click the Easy Ease icon (Easy Ease icon) at the bottom of the Graph Editor. This slows the shift into reverse so that the lights stay bright just a little longer.
  2. Click to select the keyframe at 3:00, and apply Easy Ease for the same effect.

Notice that there are Bezier handles where you added ease. You can refine the amount of ease on a transition further by dragging the Bezier handle. If you drag the handle further from the keyframe, the transition is softer; if you drag it down or closer to the keyframe, the transition is more pronounced.

  1. Go to the beginning of the time ruler, and preview the entire movie.
  1. Choose File > Save to save the final project.

Congratulations. You’ve completed a complex animation, including shifts in time. You can render and export the time-remap project if you’d like. See Lesson 15, “Rendering and Outputting,” for detailed instructions on rendering and exporting a composition.

Review questions
1 Why would you import a layered Photoshop file as a composition?
2 What is the pick whip, and how do you use it?
3 What is a track matte, and how do you use it?
4 How do you remap time in After Effects?

Review answers

1 When you import a layered Photoshop file into After Effects as a composition, 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.

2 The pick whip creates expressions that link the values of one property or effect to another layer. The pick whip is also a way to create parenting relationships. To use the pick whip, simply drag the pick whip icon from one property to another.

3 When you want one layer to show through a hole in another layer, you can use a track matte. To create a track matte, you need two layers: one to act as a matte, and another to fill the hole in the matte. You can animate either the track matte layer or the fill layer. When you animate the track matte layer, you create a traveling matte.

4 There are several ways to remap time in After Effects. Time remapping lets you dynamically speed up, slow down, stop, or reverse footage. When remapping time, you can use the values in the time-remap graph in the Graph Editor to determine and control which frame of the movie plays at which point in time. When you enable time remapping for a layer, After Effects adds a Time Remap keyframe at the start and end points of the layer. 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.

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.

Remapping time – Animating Layers

You’re ready to manipulate the speed and direction of time in your project.

  1. With the Pre-comp 1 layer selected in the Timeline panel, choose Layer > Time > Enable Time Remapping.

After Effects adds two keyframes, at the first and last frames of the layer, visible in the time ruler. A Time Remap property also appears under the layer name in the Timeline panel; this property lets you control which frame is displayed at a given point in time.

  1. With the Pre-comp 1 layer active, choose Layer > Open Layer to open it in the Layer panel.

The Layer panel provides a visual reference of the frames you change when you remap time. It displays two time rulers: The time ruler at the bottom of the panel displays the current time. The Source Time ruler, just above the time ruler, has a remap-time marker that indicates which frame is playing at the current time.

  1. Press the spacebar to preview the layer, and notice that the source-time and current-time markers in the two Layer panel rulers are synchronized. That will change as you remap time.
    Over the first four seconds, the lights come on slowly. You’ll speed that section up so that the lights come on twice as fast.
  2. Go to 2:00, and change the Time Remap value to 4:00.
    This remaps time so that frame 4:00 plays at 2:00. In other words, the clip now plays back at twice the speed for the first two seconds of the composition.
  1. Press the spacebar to preview the animation. The composition now runs at double-speed until 2:00, and at a slower speed thereafter. Press the spacebar again when you have finished previewing the animation.

Viewing time remapping in the Graph Editor
Using the Graph Editor, you can view and manipulate all aspects of effects and animations, including effect property values, keyframes, and interpolation. The Graph Editor displays changes in effects and animations as a two-dimensional graph, with playback time represented horizontally (from left to right). In layer bar mode, in contrast, the time ruler represents only the horizontal time element, without a graphical display of changing values.

  1. Make sure the Time Remap property is selected for the Pre-comp 1 layer in the Timeline panel.
  2. Click the Graph Editor button ( ) to display the Graph Editor.

The Graph Editor displays a time-remap graph that shows a white line connecting the keyframes at 0:00, 2:00, and 10:00. The angle of the line is steep up to 2:00, and then becomes shallower. The steeper the line, the faster the playback time.