We've talked about making selections; we've talked about saving channels; now it's time to delve into masksspecifically: transparency masks, layer masks, and using layers as a mask. But as you read the following pages, don't forget that masks are just channels, which are 8-bit (or 16-bit) grayscale images. (Photoshop also lets you build a hard, vector-edged mask that is not based on a channel, called a layer clipping path; we'll discuss this in "Paths," in Chapter 12, Essential Image Techniques.)
Most of the time when you create a new layer, the background is transparent. When you paint on it or paste in a selection, you're making pixels opaque. Photoshop is always keeping track of how transparent each pixel isfully transparent, partially transparent, or totally opaque. This information about pixel transparency is called the transparency mask (see Figure 8-29).
Figure 8-29. Transparency masks
Remember the analogy we made to masking tape earlier in the chapter? The selection/channel/mask (they're all the same) acts like tape over or around your image. In this case, however, the mask doesn't represent how selected a pixel is; it's how transparent (or, conversely, how visible) it is. You can have a pixel that's fully selected but only 10-percent opaque (90-percent transparent).
Tip: Load the Transparency Mask
You can load the transparency mask for a layer as a selection in the Load Selection dialog box, but it's much faster to Command-click on the layer's tile in the Layers palette. For instance, if you have some text on a type layer and you want to make a selection that looks exactly like the type, Command-click on the type layer's thumbnail. This loads the selection, and you're ready to roll.
It's hard to emphasize in print just how important nondestructive editing is in our workflow. (A future MTV adaptation of this book will show us jumping up and down, rapping, "Yo, this is life-changing!") Perhaps you're compositing several images on a background, or you're retouching an image, or you're adjusting the hue and brightness of a photograph. Whatever the case, you know that after hours of sweat and mouse-burn, when you show the result to your art director, she's going to say, "Move this over a little, and we need a little more of this showing here, and you shouldn't have changed the color of this part . . . ."
Fortunately, you can use layer masks to avoid this sort of nightmare in your work. Layer masks are just like transparency masksthey determine how transparent the layer's pixels arebut you can see layer masks and, more importantly, edit them (see Figure 8-30). If you had used nondestructive layer masks in the example above instead of erasing or editing your original pixels, you would have smiled at your art director and made the changes quickly and painlessly. Here's how you do it.
Figure 8-30. Layer masks
Creating and editing layer masks
You can apply a layer mask to a layer by selecting Add Layer Mask from the Layer menu. When a layer has a mask, it can have only one (or two, if you include layer clipping paths)the Layers palette displays a thumbnail of the mask (see Figure 8-31).
Figure 8-31. Adding a layer mask
Tip: Faster Layer Masks
While there's no built-in keyboard shortcut to add a layer mask (you can assign one if you want), it is a little faster to click on the Add Layer Mask icon in the Layers palette. If you Option/Alt-click on the Add Layer Mask icon, Photoshop inverts the layer mask (so that it automatically hides everything on the layer).
Note that you can make a selection before clicking on the icon. In this case, the program "paints in" the nonselected areas with black for you (on the layer mask). This is usually much easier than adding a layer mask, then using the paint tools to paint away areas. (Of course, Option-clicking on the icon with a selection paints the selected areas with black, so that whatever was selected "disappears.")
At first, it's difficult to tell whether you're editing the layer or the layer mask. But there are two differences: The layer mask thumbnail has a dashed border around it (on a high-resolution screen, the two borders look about the same) and the document title bar says "Layer x Mask." We typically glance at the title bar about as often as we look in our car's rear-view mirror; it's a good way to keep a constant eye on what's going on around us.
Editing a mask is as simple as painting with grays. Painting with black on the layer mask is like adding masking tape; it covers up part of the adjoining layer (making those pixels transparent). Painting with white takes away the tape and uncovers the layer's image. Gray, of course, partially covers the image.
Tip: Paint It In Using Masks
Layer masks let you paint in any kind of effect you want. For example, duplicate the Background layer of an image in the Layers palette, apply a filter to the new layer (like Unsharp Mask), then Option/Alt-click on the Add Layer Mask icon to mask out the entire effect. Now you can paint the effect back in using the Brush tool and nonblack pixels. If you change your mind, you can paint away the effect with black pixels. This flexibility is addictive and you'll soon find yourself using this technique over and over, whether it's painting in texture or sharpening or blurring or whatever.
Tip: Use Gradients for Masks
Another trick you'll find us using daily is placing gradients on a layer mask. Whether you use a linear or radial blend, adding a gradient is a great way to affect just part of an image. For example, on a partially cloudy day, the lighting of a scene may be uneven. You can apply a global tonal adjustment on a separate layer and then draw a gradient across the layer's mask to affect just the part of the image that needs it (we discuss this in detail in the next chapter). If the gradient isn't quite right, open the Levels or Curves dialog box and make adjustments to the layer mask itselfthese tonal adjustments to the mask give you almost infinite control over how your effect is applied.
Tip: Getting Rid of the Mask
As soon as you start editing layer masks, you're going to find that you want to turn the mask on and off, so you can get before-and-after views of your work. You can make the mask disappear temporarily by selecting Disable Layer Mask from the Layer menu. Or, if you need to get your work done quickly, do it the fast way: Shift-click on the Layer Mask icon.
If you want to hide the mask with extreme prejudicethat is, if you want to delete it foreverselect Remove Layer Mask from the Layer menu (or, faster, drag the Layer Mask icon to the Trash icon). Photoshop gives you a last chance to apply the mask to the layer. Note that if you do apply the mask, the masked (hidden) portions of the layer are actually deleted.
One last way to get rid of a mask: All layer masks go away when you merge or flatten layers.
Tip: Layer Mask Keystroke
When you're working on a layer, you can jump to the layer mask (making it active, so all your edits are to the mask rather than the image) by pressing Command-\ (backslash). When you're ready to leave the layer mask, press Command-~ (tilde) to switch back to the layer itself.
If you Option-Shift-click on the Layer Mask icon in the Layers palette (or just press the \ keythat's the backslash), Photoshop displays the mask and the layer, as if you're in QuickMask mode. If you don't like the color or opacity of the layer mask, you can Option-Shift-double-click on the icon to change the mask's color and opacity. Then, when you're ready to see the effects of your mask editing, Option-Shift-click on the icon again to "hide" it (or press backslash again). If you want to see only the layer mask (as its own grayscale channel), Option-click on its icon. This is most helpful when touching up areas of the layer mask (it's sometimes hard to see the details in the mask when there's a background image visible).
Tip: When Masks Move
The layer mask is tied to its layer, so when you move the layer with the Move tool, the layer mask moves, too. While this is usually what you'd want, you can stop it from happening by clicking on the Link icon that sits between the layer and layer mask previews in the Layers palette. When the Link icon is on, the layer and layer mask move together; when it's off, the layer and layer mask can be moved independently.
Layers as Masks
Layers not only have masks, but they can act as masks for other layers. The trick is to use clipping groups. For instance, if you place a circle on a layer with a transparent background, then make a new layer and fill it entirely with some bizarre fractal design, the strange texture totally obliterates the circle. However, if you group the two layers together, the lower one acts as a mask for the higher one, and the fractal design only appears within the circle (see Figure 8-32).
Figure 8-32. Grouping layers together to make a layer mask
You can group layers together in one of two ways.
You don't have to stop with grouping two layers. You can group together as many as you want, though the bottommost layer always acts as the mask for the entire group (see Figure 8-33). No, you can't group a layer with a layer setonly individual layers.
Figure 8-33. Layers as masks