Hi!
John Hess from Filmmaker IQ and, there’s
no sugar coating it, today we’re going to
look at the mathematics behind Blend modes
found in basically all digital imaging software
like After Effects Premiere Pro, Photoshop,
Davinci Resolve as well as, I’m sure, other
software platforms.
You’re not going to be asked to do any number
crunching yourself but we are going to get
deep into functions in a 3D space, so hold
onto your butts.
I admit it, I think of myself as an advanced
After Effects user for almost 20 years but
frankly I never had more than a vague notion
of what these different blend modes did.
I know you find them here in After Effects,
here in Photoshop and in the Opacity settings
in Premiere.
I, probably like you, just try out different
blend modes to see what looks good and call
it a day.
And frankly even after this in depth dive
today, I’ll still resort to experimentation
- and that’s okay, but hopefully our experimentation
will be guided by a bit more understanding
This will require you to be somewhat familiar
with basic color theory and hopefully some
the more basic mathematical functions.
Since I work in a luminous medium I will be
focusing on the RGB color model - not the
CMYK of print although there is some obvious
cross over.
So let’s start at the basics.
What is a blend mode?
Blending modes is how we take the pixel information
from one layer and blend them with the pixel
information of another layer.
For this we are going to standardize our tonal
levels between 0 and 1 - zero being no value
and 1 being full value.
If we were working in grayscale, 0 would be
black and 1 would be white.
In RGB, 0 is no value in a specific color
channel and 1 is full value in that channel
- so an RGB pixel of 0,0,0 would be black,
1,0,0 is full red, 0,1,0 is full green and
0,0,1 is blue.
Combined together, 1, 1, 1 is white.
Keep in mind we are using the standard 0-1
scale - this can translate into 8 bit which
has values of 0-255 for each channel or to
10 bit which has values between 0-1023 or
any bit value.
To help visualize the effect of these blending
modes let’s use two squares - a base that
has a black and white gradient going from
bottom to top and a blend layer that has a
gradient going from left to right.
Combining these squares creates an effective
matrix of all possible combinations along
a single dimension be it grayscale or any
of the three color channels.
Notice that the corners represent all the
possible 0 and 1 combinations: In the bottom
left both the base and blend have a value
of zero.
In the top right corner both the base and
blend have a value of 1.
In the top left and bottom right, the blend
and base alternate 0 and 1.
The middle horizontal line of the base is
middle gray while the middle vertical line
of the blend is middle gray.
Where both middle lines meet in the center
of the square - both the blend and base are
middle gray.
Keep in mind that, although we are using black,
white and gray for this visualization - this
chart can also represent the full values for
Red Green and Blue as well… but we’ll
keep it in black and white to keep things
clear.
We will also plot these gradients in 3 dimensions
- the X and Y axis remain as they are with
the Z axis being the luma value - a value
of 1 will be higher than value of 0.
You’ll notice that the gradient isn’t
perfectly linear in the Z axis - I believe
this is because the gradients created by Photoshop
and After Effects aren’t perfectly linear
to begin with and because 3D Studio Max also
added gamma when creating the relief map.
It’s a detail that I think doesn’t really
detract from understanding the point of the
demonstration and may actually more accurately
represent visually what it is happening.
Let’s look at the very first set of blending
modes - normal:
The typical “normal” behavior of two layers
is the layer on top is covers up the layer
beneath it.
We can notate it like this
So the function of a, which is the bottom
layer and, b, top layer, is just b.
Now if the b has an alpha channel, the channel
which controls the transparency of the that
channel, we could write it like this.
That means where top layer b as defined by
its alpha is shown over the lower layer a.
And in this little animation you can see the
transition from 0 alpha - completely transparent
to an alpha of 1 completely opaque.
Before heading into some more mathematically
tumultuous waters, there are a couple blending
modes left in this Normal Section.
The first is Dissolve.
Dissolve randomly chooses a value between
the base and blend layers - in Photoshop and
AfterEffects, the opacity of layer b determines
how many random pixels are chosen from the
blend layer - the lower the opacity, the fewer
pixels from layer “b” are used.
Since this a static blend mode, After Effects
has the option of Dancing Dissolve which randomizes
the pixel selection over time.
In Adobe programs, and probably other imaging
programs, blending modes are divided into
groups.
Let’s explore the first two groups: Darken
and Lighten modes.
The first mode is a simple mode called Darken.
Darken takes a look at the two layers and
retains only the darker channel value.
Notice how the square of our blend is essentially
cut in half diagonally - anything that’s
below the diagonal is essentially the base,
anything above the diagonal is the blend layer.
Notice the prominent diagonal line - the transition
is pretty distinct here.
The opposite of Darken is Lighten.
Lighten retains only the brighter of the two
channel values.
Again notice how the blended image is essentially
cut in half by the diagonal but this time
anything that’s below the diagonal is the
blend, and everything above the diagonal is
the base.
Now just pointing out - that diagonal I’m
referencing exists in the blend only because
of the nature of the gradients in our base
and blend.
The visible diagonal represents hard transition
the blend mode makes when confronted with
two gradients - when darkening - whatever
pixel value is darker it takes that pixel.
When lightening - whatever pixel value is
lighter takes that pixel.
Let’s extrapolate that out in a practical
example here.
I have a red box on top of a face.
When using darken blend mode, After Effects
compares each color channel and picks the
darker one.
This spot on her face with a it picks 220 which converted to stardard is 0.86 then 0, 0
When over the cyan background which has a it picks (0, 0, 0).
Let’s flip it to lighten.
Now when the dark areas of the image like
her hair and he sun glasses get converted
to red while the cyan background shifts to
something more pink.
So with Darken and Lighten you will see shifts
of color.
Now Darken and Lighten have one alternate
effect called Darker Color and Lighter Color.
Instead of basing the decision on each of
the channel values, Darker Color and Lighter
Color look at the composite and pick only
the darker or lighter color composite respectively.
Here is our practical example again with Darker
Color.
Notice how the box is fully red except in
the shadows which are darker.
Flipping over to Lighter Color - notice how
the dark shadow areas (hair, sunglasses) are
red which everything else retains its original
color.
Because of this hard transition, Darken, Lighten,
Darker Color and Lighter Color aren’t usually
used for blending - that honor goes to the
following two: Multiply and it’s opposite
Screen.
Multiply is pretty straight forward mathematically
- you take each channel and multiply them
together.
Since a fraction less than one times a fraction
less than one always yields a fraction smaller
than either of the original fractions, multiply
will always darken the image.
Notice that the upper left and bottom right
corners are black - because black is 0 and
anything times zero is zero regardless of
whether it is in the blend or base layer.
On the flip side, white, being a value of
1, will have no effect on the blend in Multiply
mode.
Screen, the opposite of multiply, is a little
more complicated mathematically.
The inverse of a color one minus that color.
Screen, takes the inverse of the base and
blend layers, multiplies them together and
takes the inverse of that value: Now white
dominates because it’s inverse is 0 and
when you take the inverse of something times
0, the answer is always one.
You see white dominating the upper left and
bottom right corners.
On the flip side, black, with a value of 0
get’s inverted to 1 which gets flipped back
to zero - in other words - black will have
no effect on the blend in Screen mode.
In fact all modes in the Lighten group will
be unaffected by black and all modes in the
Darken group will be unaffected by white.
Screen mode is really useful for blend light
effects like light leaks, barrel blasts, explosions
- anything that generates light.
Multiply mode is useful when you’re trying
to blend something darker on an object or
creating shadows.
The next subtractive mode is Color Burn.
Color burn takes the bottom image, inverts
it, divides by the top layer and inverts the
result.
It’s opposite found in the lighten ground
is Color Dodge which is the base layer divided
by the inversion of the bottom layer.
Color Burn and Color Dodge essentially replicate
the look of Burning and Dodging an image - With
Color Burn you get more saturation in the
mid tones and reduced highlights.
Color Dodge also increases the saturation
in the midtones but blows out the highlights.
Color Burn and Dodge are also members of a
special 8 blend modes where there are two
ways to control their effect: Opacity which
is used for all the blend modes, and fill.
In After Effects, it can be a little tricky
to find fill - you have to go into layers,
Layers Styles, Show All, then you’ll find
fill opacity in the advanced Blending.
Here is how the shape of the blend in 3D changes
using the opacity vs fill using Color Burn
and here is the differences with Color Dodge.
Let’s apply a horizontal black and white
gradient to our practical sample to see what
happens with Color Burn and Color Dodge.
With Color Burn you see the left side going
to black and the model’s skin tones way
saturated.
With Color Dodge we see the opposite side
going to white but still the same over saturation
although its harder to see as everything is
blown out.
Toning down the fill opacity would create
something that is more useful in everyday
projects.
To see how colors shift, let’s apply a red
yellow gradient and see what happens.
Using Color Dodge, the left side of the image
goes completely black.
Going back to the equation this makes sense
because the inverse of the cyan background
is red - red divided by red is 1 so 1-1 is
black.
Switching over to Color Dodge and we see this
- this is covered with ones of noise because
Yellow is full red and green.
This cyan background has very zero red.
Going back to our graph we’re in this jagged
section where the math starts to break down
as you’re having essentially a zero value
divided by zero.
The solution to this is to pull down the fill
a bit to prevent the numbers from going over
the edge.
In After Effects, there is a Classic version
of both Color Burn and Dodge, those are the
same visual effect but a legacy version for
older projects that might still use them.
The final yin yang pairing in the Darken and
Lighten modes are Linear Burn and Linear Dodge.
Those of you After Effects aficionados may
have noticed that I skipped Add - well that’s
because every source on the math I’ve been
able to find says that Add and Linear Dodge
are the same thing - you take the values from
the base layer and add them to the blend layer.
This will always result in an image that is
brighter than the original images and in the
case where the sum is more than 1 we just
cut it off at 1 - full white.
The inverse of Add or Linear Dodge is, not
subtraction - that’s another mode for later
- it’s simply the sum of the two layers
minus 1 - and here every value below 0 is
replaced with zero black.
Linear Dodge and Burn have similar characteristics
to Color Dodge and Burn but as their name
implies, the characteristic is much more linear
and there’s not the kind of saturation you
get with Color Dodge/Blur.
As with Color Dodge/Burn, Linear Dodge/Burn
are also differently by the fill and the opacticity
as you can see here.
Because Linear Dodge/Burn doesn’t have this
asymptote shaped curve at the extreme ends,
it can be more useful in overlaying text.
Where Color Dodge and Burn can lead to some
bizarre and ugly transfers with over saturation,
Linear Dodge and Burn are pretty predictable
to the eye and have more contrast than multiply.
The next set of modes are the Contrast Modes.
Where white had no effect in the Darken Modes
and black had no effect in the Lighten Modes
- it is Middle Gray that has no effect in
the Contrast mode Section.
To see how this plays out let’s look at
the first Contrast Mode: Overlay.
Overlay is a combination of two other modes
we just discussed: Multiply for the tones
below middle gray and Screen for the tones
above middle gray.
Overlay is the only contrast mode that actually
looks at the base layer in order to determine
which mode to use as a blend.
Now notice the middle gray line on the base
layer - if we transpose this line to the blended
version we can very easily see how the pattern
above middle gray is the same pattern we had
for Screen only squished and the pattern below
middle gray is the same thing as Multiply
- again squished.
Overlay is also what’s called a commuted
blending mode.
Commuted blending modes are modes that are
related to each other based on the order of
the layers.
Overlay is a commuted blending mode to Hard
Light - here you see Hard Light has the same
math only instead of using the blend layer
as the reference for middle gray.
The difference in our gradient sample is the
middle gray line runs vertically - on the
left side or darker than middle gray, you
see Multiply and on the right of the middle
gray side you see the pattern for Screen.
The Hard Light mode would yield the same results
as Overlay if you switched the blend and base
layers - which makes sense since the only
difference between Overlay and Hard Light
is which layer is referenced for middle gray.
Overlay and Hardlight are good for applying
textures on an image, especially something
that has both light and dark elements to contribute.
I found this paper texture - now this is a
little bit too bright to work using an Overlay
because - remember, it will multiply the highlights
and push everything towards white.
So I used curves to bring the texture down
more into the realm of middle gray.
Now watch what happens when I use Overlay
- the texture gets applied rather pleasingly
to the image.
It takes on the paper texture better than
either Multiply or Screen.
Also because Overlay samples the base layer
- the base layer always comes through - let’s
switch it over to Hard Light and you’ll
see the paper texture actually comes through
stronger, it’s almost like a transparent
sheet of paper was put on top of the image.
The next mode in the contrast group is Soft
Light.
You might think that Soft Light is related
to Hard Light because of the name - well it
isn’t at all.
In fact here’s the formula for Soft Light
which is some sort of quadratic function here…
best I can tell is it is the mulitiplication
of a and the inverse of b plus b - all of
that again multiplied by a when values are
below middle gray in the blend layer then
the inverse of that for when values are above
middle gray.
There are several other similar formulas used
by other software applications - this one
is used by Photoshop since 2012 but it does
have local discontinuity of contrast based
on gamma values that is corrected in other
software applications.
That’s all I’m going to say on that topic
for now - information on this is a bit hard
to come by and it’s a little too in the
mathematical weeds even for me.
Point is, Softlight sort of emulates Overlay
but in a much softer way.
As Adobe describes it the effect is similar
to shining a diffused spotlight on the image
- black and white from the blend mode will
never fully turn the blend black or white.
Softlight can be used in a number of ways
- to add some punch to your shot, you can
simply duplicate the any layer and add soft
light to the top layer.
You can also use Soft Light to relight or
give a shot vignette shot using a gradient
map - white on the blend layer will brighten
the base layer, black will darken.
You can also use Soft Light to gently add
color casts - you’ll see a lot of orange
and teal at work here because, hey it actually
works and looks good - but there’s lots
of ways to subtly apply interesting color
combinations using Soft Light.
Moving from a still photograph to stock video
- here’s a 4 color gradient applied to a
beach scene using only soft light which I
think brings the footage to life if you’re
going for a warm cozy look.
The next few contrast moders are kind of extreme
cases: Linear light as you might have guessed
is the combination of Linear Dodge and Linear
Burn.
Vivid Light combines Color Dodge and Color
Burn, and Pin Light combines Darken and Lighten.
These three are also part of the special 8
which can be controlled by the fill as well
as opacity and you can see the different effects
here - generally you’ll want to set the
fill to about 50% on these three as they do
give you a little too extreme of a look at
100%.
To me, Linear, Vivid and Pin light aren’t
as useful for creating naturalistic blends
because you’ll end up dialing them so far
back that you might as well just use softlight
or overlay.
But if you’re going for a truly out there
look - give them a try.
The final contrast blend mode is a strange
one called Hard Mix.
This one is a bit hard to explain - first,
it is based on the Linear Light blend so middle
gray doesn’t affect it.
Once the Linear Light math is done, each channel
is then converted to either 0 or 1 - on or
off - resulting in only 8 colors allowed when
the blend mode is in full fill opacity: White,
Red, Green, Blue Cyan Magenta, Yellow and
Black.
You can best see it in this color wheel sample
- watch as I apply a middle gray layer with
a hard mix - the result is a pattern which
only contains those previously mentioned 8
colors.
Now watch as I change that hard mix layer
- increasing the brightness to white and lowering
it to black.
Changing the color also creates interesting
nifty patterns and shapes.
As I mentioned only 8 colors are allowed when
this blend mode is in full fill opacity.
Reducing the fill opacity increases the number
of colors allowed.
Now as for practical application - Hard Mix
is basically an extreme version of Linear
Light - for color grading and recoloring purposes
- I think you’re better off just using Linear
Light.
There are some graphic design uses for Hard
Mix as you saw in the initial explanation
- if you hard mix a noise layer with a black
and white base, you can create an interesting
pointillism effect.
You can even get a reasonable half tone dots
using a blurred checker pattern hard mixed
over black and white footage.
THE DIFFERENCE MODES
The last of our mathematically based blending
modes, we come to the Difference Modes.
These modes as the title suggest look at the
differences between the blend and base layer.
The first one is difference and it’s just
the absolute value of the base minus the blend
mode.
When you apply the difference mode to a blend
layer that is the exact same as the base you
will get black - this is useful if you’re
trying to align the same object from different
shots.
Otherwise the difference mode will tend to
create a negative effect when either the blend
or base modes are white and allow the other
layer to show through when either the blend
or base mode is black.
Difference is also one of the special 8 that
has different fill and opacity effects.
Classic Difference in After Effects is basically
the same but as a legacy code.
The next mode is Exclusion which is a linear
dodge minus two times the multiply effect.
As you can see, the shape of this is very
close to that of difference, except that the
valley between the two white corners never
gets all the way down to black - in fact middle
gray in either layer will always return middle
gray.
Black in the blend layer will have no effect
where as white in the blend layer will invert
whatever is in the base layer.
The result when applying a color layer using
Exclusion blending is the dark regions will
take on the blend layer color whereas the
light parts of the image will take on the
inverse of the color.
Artistically speaking, it’s most practical
effect is when you apply a blue layer with
exclusion - the skin tones because they tend
to be higher will become blue’s opposite
of yellow and the darker parts of the shot
will take on some more blue.
But both Difference and Exclusion can be used
for more extreme pop-art styles.
The next two modes were designed for calibrated
imaging systems but they do have some artistic
application.
Subtract is pretty straight forward - it’s
just the base layer minus the blend layer.
Subtract can be useful for adding or taking
away a color cast.
Here the original footage has a greenish cast
to it - applying a solid with a color of 0,20,0
subtracts 20 green from the entire shot leaving
what I think is a more pleasing color - you
can even introduce different color casts by
slightly adjusting mix and notice that the
values used are very low.
Anything higher would result in subtracting
all the image.
The final mode in the difference group is
Divide - which as you have guessed divides
the base layer by the blend layer.
Here, white is the neutral color as anything
divided by 1 is 1.
You can also use this mode to correct a color
cast only here you would use a color that’s
closer to one.
Okay that does it for all the mathematically
based blend modes - there are a few more blend
modes in After Effects (and Photoshop) worth
covering and we’ll run through these briefly.
The first section is the HSL section.
Basically this section replaces the Hue Saturation,
Color or Luminance of the blend layer the
corresponding attribute of the base layer.
So if we select Hue - we keep the hues of
the blend layer but take the saturation and
luminosity of the base layers.
If we select Saturation - the result will
maintain the saturation of the of the blend
layer but take the hue and luminosity of the
base layer.
If we select Color, we keep the hue AND saturation
from the blend layer and take only the luminous
data from base layer.
If we select Luminous we take only the luma
data from the blend layer and get our hue
AND saturation from the base layer.
HSL blend modes are useful in recoloring shots
and used extensively in turning black and
white images into color.
After HSL are stencil modes.
Stecil Alpha means every layer below will
take on the Alpha of the blendlayer.
Stencil luma does the same thing only instead
of looking at the alpha layer, looks at the
brightness of the blend layer.
Silhouette Alpha and Luma do the Inverse.
Finally the last two blend modes of After
Effects are Alpha Add and Luminescent Premul.
Alpha Add changes the behavior of alpha channels
when layered on top of one another.
Instead of performing a second alpha calculation
alpha add, adds the channel’s alpha value
to the alpha value underneath it.
This is useful when you have layers that are
touching where antialiasing can create seems
between layers.
Luminescent Premultiply is a utility to correct
clipping of color values that exceed the alpha
channel value after compositing.
This is mainly used when you have light effects
in footage with it’s own alpha channel coming
from other matting software.
And there you have it - a conceptualizations
of all the blending modes found in After Effects
and most image manipulation software.
With digital imaging there are multiple ways
to skin a cat and hopefully this exploration
of blend modes gave you a few extra ways to
accomplish what it is you’re after!
If you liked this video, hit like, subscribe
and ring that bell.
Consider becoming a patron on Patreon so I
can give you more insight and deep dives into
the fastinating world of filmmaking - special
thanks to our A-Team Patrons.
Check out our merch in the shelf below - thank
you for watching and now my friends go out
there and blend up something great - I’m
John Hess and I’ll see you on Filmmaker
IQ.com
