Sub topic 12
Limiting a Blend to Certain Tones with Blend If
This chapter assumes you can work with layers, add layer masks, and tell brightness from hue and saturation. You should also know the main blend modes from the earlier chapters, especially Multiply, Screen and Overlay. Blend If is a way to restrict a blend mode, or a layer's visibility, to a chosen range of tones. You do this without painting a mask.
What Blend If does
A layer mask hides pixels by position. You paint on it, and the mask stores your decisions. Blend If hides pixels by value. For each pixel, Photoshop checks a brightness number and decides how much of the layer to show. If you move the underlying image, the visible area changes with it.
Blend If is useful when the area you want has no clean edge but has a clear tonal range. Examples are:
- Highlights that should receive a glow.
- Shadows that should receive a color tint.
- Texture that should stay out of the darkest areas.
Blend If is a layer style option. It does not change any pixels, so you can reopen it and adjust it at any time.
Opening the controls
- Select a layer. This can be a pixel layer, a Smart Object, a group, or an adjustment layer.
- Double-click the layer to the right of its name, or choose Layer > Layer Style > Blending Options.
- In the Layer Style dialog, find the Advanced Blending section. The Blend If controls are at the bottom of that section.
- Use the dropdown to pick a channel. Gray looks at overall brightness. Red, Green and Blue look at one color channel at a time.
You see two gradient bars with sliders:
| Bar | What it measures | What the sliders do |
|---|---|---|
| This Layer | The brightness of the layer you selected | Hide pixels of this layer that are darker or lighter than the slider positions |
| Underlying Layer | The brightness of everything below this layer | Hide this layer wherever the image beneath is darker or lighter than the slider positions |
Each bar runs from 0 (black) on the left to 255 (white) on the right. Each bar has a black slider on the left and a white slider on the right.
Reading the sliders
The rule is simple once you see the pattern.
- Move the black slider on a bar to the right. Pixels with a value below that position are hidden.
- Move the white slider on a bar to the left. Pixels with a value above that position are hidden.
On This Layer, the hidden pixels are those of the selected layer itself. On Underlying Layer, the hidden pixels are still those of the selected layer. The test is the brightness of the image below, and the underlying pixels show through at those spots.
Here are two common settings:
- This Layer, white slider moved to 200: the layer's brightest pixels disappear. A layer filled with a bright texture then leaves highlights untouched.
- Underlying Layer, black slider moved to 60: the layer disappears wherever the image below is darker than 60. A tint then stays out of the shadows.
Splitting the sliders
Dragging a slider directly creates a hard cutoff. Pixels at 59 are hidden, and pixels at 60 are fully visible. In photographs this often makes visible edges or posterized patches.
Hold Alt (Windows) or Option (Mac) and drag one half of a slider. The triangle splits into two halves. The pixels between the halves fade in gradually. A split slider gives you a smooth ramp instead of a step.
The number above each half of a split slider shows its position. Two numbers, such as 50 / 100, mean the layer is invisible below 50, fully visible above 100, and partly visible in between.
The math behind the sliders
The visibility of a pixel is a number from 0 (hidden) to 1 (fully shown). The code below models it in Python. The function ramp_up handles the black slider. The function ramp_down handles the white slider. The function visibility multiplies both, because a pixel must pass the black and the white test.
def ramp_up(v, lo, hi):
"""Black slider: 0 below lo, 1 above hi, linear in between."""
if v < lo:
return 0.0
if v >= hi:
return 1.0
return (v - lo) / (hi - lo)
def ramp_down(v, lo, hi):
"""White slider: 1 below lo, 0 above hi, linear in between."""
if v <= lo:
return 1.0
if v >= hi:
return 0.0
return (hi - v) / (hi - lo)
def visibility(v, black=(0, 0), white=(255, 255)):
"""Visibility of one pixel for one Blend If bar.
black and white are (lo, hi) pairs. Equal values mean an unsplit slider.
"""
return ramp_up(v, *black) * ramp_down(v, *white)
def blend_if(this_value, under_value, this_bar, under_bar):
"""Both bars must allow the pixel, so their visibilities multiply."""
return visibility(this_value, *this_bar) * visibility(under_value, *under_bar)
# Keep a layer out of the shadows: underlying black slider split at 50 / 100.
under_bar = ((50, 100), (255, 255))
this_bar = ((0, 0), (255, 255))
for under in (0, 50, 75, 100, 200):
shown = blend_if(180, under, this_bar, under_bar)
print(f"underlying {under:3d} -> layer visibility {shown:.2f}")Running it prints:
underlying 0 -> layer visibility 0.00
underlying 50 -> layer visibility 0.00
underlying 75 -> layer visibility 0.50
underlying 100 -> layer visibility 1.00
underlying 200 -> layer visibility 1.00The final pixel is a mix of the layer and the image beneath, in proportion to this visibility. In effect, Blend If acts as an automatic mask. You can think of the result as a grayscale mask computed from tones.
Worked example: a glow that avoids the shadows
Suppose you have a photo of a lantern in a dark room. You want a warm glow on the lit areas only.
- Create a new layer above the photo. Set its blend mode to Screen.
- Paint on it with a soft orange brush over the whole lantern region. Paint generously. You will limit the effect with Blend If.
- Open Blending Options.
- On the Underlying Layer bar, hold Alt or Option and drag the left half of the black slider to 120. Then drag the right half of that slider to 60, so the split spans 60 to 120.
- Check the image at 100% zoom. The glow should fade out where the room is dark and stay strong near the lantern.
The Screen blend already brightens, so the glow would otherwise lift the dark walls into a gray haze. Blend If keeps those walls black.
Using single color channels
The Gray channel is the default and works for most tasks. Choosing Red, Green or Blue tells Blend If to use only that channel's values. This is a precise tool for color-based selection.
- Skin is rich in red. Use the Red channel on Underlying Layer to affect skin without much effect on blue backgrounds.
- Sky is rich in blue. Use the Blue channel to protect it, or to target it.
- Foliage is rich in green. The Green channel separates leaves from other content.
Selecting a channel moves the sliders of that channel only. The Gray settings and each color channel's settings are all active at once, and they multiply. If a layer disappears unexpectedly, check each channel in the dropdown. A forgotten slider on another channel is a common cause.
Limits and failure modes
- Blend If is based on the composite below the layer, including layers you did not intend to count. Hidden layers do not count, but visible adjustments do. If you reorder layers, the effect changes.
- Pixel values at sharp edges can produce a jagged boundary when the sliders are not split. This is more visible on noisy shadows.
- Hidden parts of a layer still exist. The pixels are not erased, so you can restore them by moving the sliders back.
- A layer mask and Blend If both reduce visibility. They multiply, so an area at 50% from each shows at 25%.
- On a Pass Through group, the group has no blend of its own, so the controls on the group apply differently from a normal layer. If Blend If does not behave as expected on a group, set the group's mode to Normal first, then compare.
- Blend If cannot select by position or by hue. For that you need a mask or a Hue/Saturation range.
When to use Blend If or a mask
| Situation | Better tool |
|---|---|
| The target area is defined by tone, such as highlights or shadows | Blend If |
| The target area is defined by shape, such as a face or a sign | Layer mask |
| You want a smooth, automatic fade that follows image changes | Blend If |
| You want to paint a precise local correction | Layer mask |
| You need both | Blend If for the tonal limit, a mask for the location |
You can also turn a Blend If result into a mask. Put the layer in a group, or convert it to a Smart Object, and add a mask to the group. This keeps the tonal logic and adds painted control.
Exercise
A texture layer set to Overlay adds grain across a photo. You want it to skip the brightest highlights, so they stay clean. Which bar and which slider do you move, and in which direction? What should you do to avoid a harsh edge?
Show answer
On the This Layer bar, move the white slider to the left. This hides the texture layer's own pixels above that brightness. However, if the texture itself is mid-gray, its values rarely reach the highlights, so it is usually better to use the Underlying Layer bar. Move its white slider to the left, so the layer fades out where the photo is bright. Hold Alt (Windows) or Option (Mac) and drag half of the slider to split it, so the fade is gradual instead of a hard cutoff.
Exercise
Using the Python model, what visibility does a pixel with underlying value 90 get if the underlying black slider is split at 60 / 120 and the white slider is unsplit at 255?
Show answer
The ramp is (90 - 60) / (120 - 60) = 0.5, and the unsplit white slider gives 1.0 at value 90. The visibility is 0.5, so the layer shows at half strength at that pixel.