Join Jan Kabili for an in-depth discussion in this video What is a layer mask?, part of Photoshop CS4: Layer Masks in Depth.
I would like to make sure that you have a really good idea of what a layer mask is before I start walking you through the steps of creating and working with layer masks. So this is one of the few movies where I'm going to invite you to sit back and just listen and watch rather than work along with me as I explain the concept of layer masking. In a nutshell, a layer mask is like an overlay that you add to a layer in order to hide part of that layer from view. To show you that, I have made an image here that has two layers, one of which contains a layer mask.
In the Layers panel, I'm going to click the Eye icon to the left of the topmost layer, the yellow layer, so that you can see the content of the layer below, the photo layer. Now I'll make the yellow layer visible again by clicking in its Eye icon field. The yellow layer is actually completely filled with yellow pixels, but you don't see all of those yellow pixels here in the document window, because the yellow layer contains a layer mask, which is represented by this thumbnail here on the yellow layer. The thumbnail on the left represents the image pixels.
The thumbnail on the right represents the layer mask. I'm going to make that layer mask temporarily invisible by holding down the Shift key and clicking on the layer mask thumbnail, so that you can see that without the layer mask the yellow layer really is completely filled with yellow pixels. That will make the layer mask visible again by going over to the Layers panel and just clicking on the layer mask thumbnail. To give you a better sense of what this layer mask is made up of, I'm going to show you the layer mask in the document window, and this is also something that I'll show you how to do in more detail in other movies.
But for now I'm just going to hold down the Option key on a Mac or the Alt key on a PC and click on the layer mask thumbnail and that displays the layer mask here in the document window. A layer mask is an image in it's own right and it's a grayscale image. That means that a layer mask can contain only black pixels, white pixels, or in some cases pixels that are shades of gray. Where a layer mask is black, it will hide the content of the layer to which it's attached and where a layer mask is white, it will show the content of the layer to which it's attached, and where a layer mask is gray, as this one is between the black and white pixels, it will partially show the content of the layer to which it's attached.
Now that you know that, let's go back and look at the image again. I'll go to the Layers panel, hold down the Option key on the Mac, the Alt key on the PC, and click again on the layer mask thumbnail to see the image inside the document window. So this is the area where there are black pixels on the layer mask, and in this area we can see down through the yellow layer to the photo on the layer below. This is the area where there are white pixels on the layer mask. So in this area the yellow parts of the yellow layer are showing, and in between there is a soft transition that's caused by the gray pixels on the layer mask.
So that's what a layer mask is, a grayscale overlay that hides part of the layer from view. But why use a layer mask at all? You may be wondering why in this case I didn't just take the Eraser tool and erase this portion of the yellow layer, or why I didn't select this portion with the Selection tool and then delete it from the file. The answer is that in Photoshop it's always good to work in a way that is nondestructive of your image. That way you have the flexibility to come back in and change your mind. When you add a layer mask like this one to a layer, you are not erasing or deleting pixels; you are just covering them up temporarily.
That means you can change your mind and come back in to reveal those pixels again, as I'll show you how to do in later movies. So the power of layer masking is that it allows you to edit nondestructively, hiding content without permanently deleting or erasing it, and allowing you to come back and change your mind at any time. Your layer mask will stay with the file as long as you save the image in a format that retains layers, either as a .PSD or Photoshop document, as a TIFF, or in some more rare cases as a Photoshop PDF or a large document format file.
But keep in mind that if you save as JPEG or as GIF, a layer mask will be applied but then deleted, and the layers in the file would be flattened. So the next time that you feel like erasing or deleting some content from a layer, consider whether you are better off adding a layer mask, which gives you the power of nondestructive flexible re-editing.
- Adding grayscale pixels to layer masks to hide and show layer content
- Refining the edges of layer masks in the Refine Mask dialog box
- Using filters and adjustments to manipulate layer masks
- Blending photographs into composites by applying gradients to layer masks
- Using layer masks with Smart Objects and Adobe Camera Raw to combine different adjustments of the same photo
- Simulating shallow depth of field and targeting sharpening with Smart Filter masks