This is a brief breakdown of the maths behind Fusion’s * Merge Tool*.

The * Operator modes* are well documented. But, I’ve done some digging around to uncover the maths behind the

*,*

**Apply mode****and**

*Alpha Gain***.**

*Burn In*

Eyeon Fusion’s * Merge tool* allows for

**and**

*additive***compositing.**

*subractive** Additive* assumes that images are pre-multiplied. This is the default for most compositing in Fusion.

* Subtractive* assumes that foreground image is NOT pre-multiplied. The

*will pre-multiply the foreground image by it’s alpha then do an additive merge.*

**Merge Tool**Generally images should be pre-mutliplied with black. If I’m working with 3d rendered images this is normally the default. If I’m working with green screen or rotoscoped footage I may need to do some work to remove colour from the edges.

The ** Subtractive Additive** slider is a quick and easy way to darken edges of the foreground image.

## The missing additive blend mode?

The merge tool DOES do a straight additive blend but ‘Add’ is not listed as an apply mode in the drop down list. You need to know your composite maths to solve the puzzle…

Set ‘Apply Mode’ to ‘Normal’ and ‘Alpha Gain’ to zero for the ADDATIVE BLEND.

This mathematically the same as an additive blend.

## The general maths for merging pixel colours

With an * Additive* merge the formula used to merge a pixel is

( A * **F**_{A} ) + ( B * **F**_{B} )

A – RGBA Foreground

B – RGBA Background

If a * Subtractive* merge is used the foreground ( A ) is pre-multiplied in the merge operation.

( A * α_{A} * **F**_{A} ) + ( B * **F**_{B} )

α_{A} – Alpha Foreground

α_{B} – Alpha Background

### The Merge Operator determines **F**_{A} and **F**_{B}

The various * operator* options control where the foreground is merged with the background.

The table below shows how the different merge operations determine **F**_{A} and **F**_{B} .

Diagramof 1 pixel |
F_{A} |
F_{B} |
||

Clear | 0 | 0 | ||

A | 1 | 0 | A = RGBA Foreground | |

B | 0 | 1 | B = RGBA Background | |

A Over B | 1 | 1-α_{A} |
||

A in B | B | 0 | ||

A Held Out B | 1-α_{B} |
0 | ||

A ATop B | B | 1-α_{A} |
||

A XOr B | 1-α_{B} |
1-α_{A} |

This table is based on the 1984 SIGGRAPH paper, Compositing Digital Images, Porter and Duff.

## Normal mode is A over B.

### The basic maths.

Substituting the formula from the table above we get these simple functions for merging one image over another.

#### Normal Additive ( A over B )

A + B * ( 1 – α_{A} )

#### Normal Subtractive ( A over B )

A * α_{A }+ B * ( 1 – α_{A} )

B – background color

A – foreground color

α_{A} – foreground alpha

### Alpha Gain and Burn In sliders.

* Alpha gain* and

*sliders scale the foreground alpha to create screen like effects.*

**Burn In**When G = 1 and U = 0 these equations can be simplified to the maths above.

#### Normal Additive ( A over B )

A + B * ( 1 – ( α_{A} * G ) * ( 1 – U ) )

#### Normal Subtractive ( A over B )

A * ( α_{A }* G ) + B * ( 1 – ( α_{A} * G ) * ( 1 – U ) )

G – Alpha Gain

U – Burn In

It’s worth noting that using** Burn In **with floating point maths can give alpha values above 1.0. The foreground alpha is essentially doubled where it crosses the background.

## Other Apply Modes.

The * Merge tool* offers a host of

**many of which emulate photoshop layers. The Subtractive Additive slider is disabled in these modes which makes the maths a bit simpler.**

*Apply modes** Screen Mode* is not effected by

*at all. Otherwise images should be pre-multiplied before using these blend modes.*

**alpha**In all these apply modes image * alphas* are combined using this equation.

α_{A} + α_{B} * ( 1 – α_{A} )

Gringo’s apply modes comp demonstrates the maths in Fusion using custom tools. I’ve summarised most of the maths in the table below.

Uses alpha | ||

Screen | 1 – (1-A) (1-B) | no |

Multiply | AB | yes |

Overlay | if B < 0.5 then 2AB else 1 – 2(1-A) (1-B) | yes |

Hard light | if A < 0.5 then 2AB else 1 – 2(1-A) (1-B) | yes |

Soft light | if A < 0.5 then 2AB + B^{2}( 1 – 2A ) else 2B(1 – A) + (2A – 1)√B |
yes |

Lighten | if A > B then B else A | yes |

Darken | if A < B then B else A | yes |

Difference | abs(A-B) | yes |

Exclusion | A + B – 2AB | yes |

Colour Dodge | B / (1 – A) | yes |

Colour Burn | 1 – ( (1 – B) / A ) | yes |

This is based on Delphi’s photoshop maths. Note: I’ve flipped the notation in my article… A = b, B = a.

I’ve also used some maths shorthand and removed the * sign. So; 2AB = 2*A*B, 2(1-A) = 2*(1-A), etc.