Compositing
Premultiplication
You lay a visual effect over a background and a dirty ring appears around the edge. It's not the render and it's not your eyes. One small multiplication happened the wrong number of times. This page starts from what a colour actually is, so the fix makes sense instead of being a checkbox you tick and hope.
Colours are just numbers
A pixel is a tiny square of colour, and your computer doesn't store “orange”. It stores three numbers: how much red, how much green, how much blue, each from 0 (none) to 255 (full). Mix the sliders.
That's it. Everything you do to an image is arithmetic on these numbers.
The fourth number: alpha
Red, green and blue say what colour a pixel is. Alpha says how much of it is there: 0 is absent, 1 is solid, 0.5 is half there. A soft edge is just alpha sliding from 1 down to 0.
The checkerboard is how software draws “nothing here”. It isn't part of your image. Notice the colour numbers never change. Only alpha changes how much of them shows. Laying one image over another is a composite, and the image on top is the element.
See the problem
When software composites, it does one job at every pixel: multiply the element's colour by its alpha, then fill the rest with background. At a half-there edge pixel, that means half the orange plus half the background. That multiplication, colour × alpha, must happen exactly once.
Below is a soft-edged orange element over a blue-grey background. The three buttons are the three possibilities. Nobody chooses the wrong ones; they happen silently when software misreads the file it was handed, which is the next section. Switch between them and watch only the edge.
Why is it only ever the edges?
Where alpha is 1, multiplying by it changes nothing. Where alpha is 0, there is no colour to ruin. The mistake can only show in the in-between pixels: soft edges, motion blur, hair, smoke.
That's why the damage is always a thin outline, and why it's easy to miss until the shot is on a big screen.
One pixel, two kinds of file
There are two valid ways to save a transparent image, and the only difference is whether the multiplication has been done yet. Here is one half-transparent orange pixel, saved both ways.
Straight
A 0.50 saved alongside
The colour is saved untouched. The software multiplies by alpha when it composites.
Premultiplied
248 × 0.5 = 124, and so on
The colour is saved already multiplied. The software must not do it again.
So why the ring?
Both files are correct, but you have to tell your software which one it has. Read a premultiplied file as straight and the multiplication runs twice: dark ring. Read a straight file as premultiplied and it never runs: light ring.
The fix
Fix 1: tell your software which kind of file it has
When you import a file, set it as premultiplied or straight. If you see a ring, check this first.
- In Fusion (DaVinci Resolve): tick or untick
Pre-Multipliedon the Loader or MediaIn node to match the file.
Fix 2: divide, grade, multiply
A grade applied to a premultiplied element also changes the edges, because the edge pixels are already darkened by alpha. To grade safely, divide by alpha first, grade, then multiply by alpha again.
Try it: a brightening grade on a premultiplied element.
Graded directly, the brightness spills into the empty pixels around the element. With the divide and multiply steps, only the element changes.
- In Fusion (DaVinci Resolve): an
Alpha Dividenode before the grade, anAlpha Multiplynode after.
If you remember nothing else
- 1A dirty ring means the multiplication ran the wrong number of times. The file itself is fine.
- 2Dark ring: it ran twice. Light ring: it never ran.
- 3Check the Pre-Multiplied setting first, before you reach for any other fix.
- 4Grading a premultiplied element? Divide by alpha, grade, multiply by alpha.
Want to get hands on?
Take a look at the Resolve scene here:
Download the Resolve sceneIt's a .drp project file. In Resolve, right-click in the Project Manager and choose Import Project.
