Sub topic 2
White reveals, black conceals, gray blends
This chapter covers the one rule that every layer mask follows. It assumes you can find the Layers panel, Tools panel and Properties panel, and that you can use the Brush tool on a layer. If you know that a mask hides pixels without deleting them, you are ready. If not, read the previous chapter on why masking beats erasing first.
The mask is a grayscale picture attached to a layer
A layer mask is a separate grayscale image that sits next to a layer and has the same pixel dimensions. Photoshop reads each mask pixel and uses its brightness to decide how visible the matching layer pixel is.
The rule has three parts:
- White in the mask shows the layer pixel at full strength. White reveals.
- Black in the mask hides the layer pixel completely. Black conceals.
- Any gray in between shows the layer pixel partly. Gray blends.
The layer's own pixels are never changed. Only the mask changes, so you can repaint it at any time and get the hidden pixels back.
Mask values as opacity
Photoshop stores a mask as an 8-bit grayscale image in a standard document. Each pixel has a value from 0 (black) to 255 (white). The visibility of the layer at that pixel is the value divided by 255.
| Mask value | Appearance | Layer visibility |
|---|---|---|
| 255 | White | 100% |
| 191 | Light gray | About 75% |
| 128 | Middle gray | About 50% |
| 64 | Dark gray | About 25% |
| 0 | Black | 0% |
This is why a mask differs from the layer's Opacity slider. Opacity changes the whole layer by one amount. A mask can set a different amount at every pixel.
A mask with 50% gray everywhere looks the same as setting the layer to 50% opacity. The difference is that you can later paint areas of that gray lighter or darker without touching the layer.
The model also matters when you combine masks with opacity. The Opacity slider and the mask multiply. A layer at 80% opacity with a mask pixel of 50% gray shows that pixel at 40%.
How the result is composited
For each pixel, Photoshop blends the masked layer with whatever lies beneath it. In plain terms:
result = layer × mask + below × (1 − mask)
Here, mask is a number from 0 to 1. Where the mask is 1, you see only the layer. Where it is 0, you see only what is below. At 0.5 you see an even mix.
The diagram shows the decision made for each pixel.
A worked example: a two-layer composite
Suppose you have a photo of a sky on a layer named Sky above a layer named Landscape. You want the sky to appear only in the top half of the image.
- Select the Sky layer in the Layers panel.
- Click the Add Layer Mask button at the bottom of the panel. It is the rectangle with a circle in it. A white thumbnail appears next to the layer thumbnail. Because the mask is all white, nothing looks different yet.
- Click the mask thumbnail so that its frame shows it is active. This step is important, as explained below.
- Choose the Gradient tool and pick the Foreground to Background preset with the default colors (press D to reset to black and white).
- Drag from the middle of the image up to about one quarter of the way down from the top.
The result is a mask that is black at the bottom, white at the top, and a smooth gray ramp between. The Sky layer is visible at the top, fades through the ramp, and disappears at the bottom, where the Landscape shows through. Nothing was erased. If you later want more sky, you only need to drag a new gradient.
Default colors and the D and X keys
Painting on a mask uses the same Foreground and Background colors as everywhere else, but only gray values matter. When a mask is active, Photoshop converts any color you choose to its gray equivalent. A red foreground paints a mid-dark gray.
Two shortcuts make mask work fast:
- D resets the colors to black (foreground) and white (background). When a mask is active, this gives you a black foreground and a white background.
- X swaps the foreground and background colors, so you can switch between hiding and revealing without opening a color picker.
Keep in mind that the shortcuts follow the active target. If the layer thumbnail is active instead of the mask, D sets the colors in the same way, but painting changes the layer's pixels rather than the mask.
Knowing which thumbnail is active
Each masked layer has two thumbnails: the layer on the left and the mask on the right. A thin frame around one thumbnail shows which one receives your edits. Check it before every stroke.
A common error is painting black on the layer thumbnail when you meant to paint on the mask. This permanently changes the layer's pixels, and the result looks like a black stain instead of a hidden area. If you see color appear where you expected a reveal or hide, press Ctrl+Z (Cmd+Z on macOS), click the mask thumbnail, and try again.
Reading a mask at a glance
Once you know the rule, you can read a mask thumbnail as a map of the layer's visibility.
- A mostly white thumbnail with a few black areas means most of the layer is visible and a few regions are hidden.
- A mostly black thumbnail with white shapes means the layer is hidden except in those shapes.
- Soft transitions between black and white mean the layer fades in gradually at those places.
- Hard edges mean the layer is cut off sharply there.
You can read the edge quality directly. A crisp boundary in the mask gives a crisp cut in the picture. A blurry boundary gives a smooth blend. This is the main reason masks are good for compositing, because you can control how a transition looks by controlling how the mask looks.
Choosing white or black as the starting point
Two starting states cover most tasks, and the choice depends on which part of the layer you want to keep.
| Situation | Start with | Then paint |
|---|---|---|
| You want to keep most of the layer and remove a few parts | A white mask (everything visible) | Black over the parts to hide |
| You want to show only a small part of the layer | A black mask (everything hidden) | White over the parts to reveal |
Starting with the larger visible area in mind means fewer brush strokes. Creating the masks in each state is covered in the next chapter. For now, understand that the choice is only a starting value. You can switch at any time by inverting the mask or painting over it.
Edge cases and surprises
- Mid-gray is not always what you expect. Photoshop shows the mask values, but the picture you see is the result after blending. A 50% mask over a layer that is nearly the same color as the layer below looks like almost nothing happened.
- Values do not accumulate beyond the limits. Painting white over white changes nothing. Painting black over black changes nothing. Only values between the two can be pushed further by repeated strokes with a low-opacity brush.
- Opacity and Flow of the brush set the gray. Painting black at 30% brush opacity onto a white mask produces a light gray, about 30% darker than white, and it hides about 30% of the layer.
- Masks only affect their own layer. A mask on one layer does not change layers above or below it, unless the layer is a group, in which case the mask applies to everything in the group.
- Transparent areas stay transparent. If the layer has no pixels in a region, no mask value can make anything appear there. The mask only controls pixels that exist.
- Bit depth. In 16-bit documents the mask has finer steps, which reduces visible banding in long gradients. The principle is the same.
Check your understanding
Exercise
A layer has a mask that is white on the left half and black on the right half, with a smooth gray ramp across the middle. Describe what you see in the left, middle and right of the image. Then say what happens to the hidden pixels on the right.
Show answer
On the left, the layer is fully visible. Across the middle, the layer fades out gradually, getting more transparent toward the right. On the right, the layer is fully hidden and the layers below show through. The hidden pixels are not deleted. They stay stored in the layer, and painting white on the right side of the mask would bring them back.
Exercise
A masked layer is set to 80% Opacity. Part of its mask is 50% gray. How visible is the layer in that part? Then, you paint black at 25% brush opacity once over a white area of the mask. About how visible is the layer there afterward?
Show answer
In the gray area, the opacity and the mask multiply, so visibility is 0.8 × 0.5 = 40%. In the white area, one stroke of black at 25% brush opacity makes the mask about 75% white, so the layer is about 75% visible, before the 80% layer Opacity is applied. With that Opacity, the final result is about 60%.
Exercise
You paint a black stroke where you wanted to hide part of a layer, but the stroke leaves a black mark on the image instead of revealing the layer below. What most likely went wrong, and how do you fix it?
Show answer
The layer thumbnail was active instead of the mask thumbnail, so the stroke painted black pixels onto the layer itself. Undo with Ctrl+Z (Cmd+Z on macOS), click the mask thumbnail so its frame appears, and paint again with black.