Merge node
This documentation is for version 2.0 of Merge (net.sf.openfx.MergePlugin).
Description
Pixelbypixel merge operation between two or more inputs. Input A is first merged with B (or with a black and transparent background if B is not connected), then A2, if connected, is merged with the intermediary result, then A3, etc.
A description of most operators is available in the W3C Compositing and Blending Level 1 Recommendation https://www.w3.org/TR/compositing1/ and a complete explanation of the PorterDuff compositing operators can be found in “Compositing Digital Images”, by T. Porter and T. Duff (Proc. SIGGRAPH 1984) http://keithp.com/~keithp/porterduff/p253porter.pdf
Note that if an input with only RGB components is connected to A or B, its alpha channel is considered to be opaque (one) by default, thus the output will be completely opaque if the checkbox for channel A of input B is checked. One reason for this behaviour is that nonzero RGB values with a zero A value are not valid alphapremultiplied RGBA values. If the user wishes to keep the background fully transparent, it can only be black, which is equivalent to not using the merge operator. Nonblack fully transparent pixels should never appear anywhere in a proper compositing graph.
Operators
The following operators are available.
PorterDuff compositing operators
copy: A (a.k.a. src)
over: A+B(1a) (a.k.a. srcover)
under: A(1b)+B (a.k.a. dstover)
in: Ab (a.k.a. srcin)
mask: Ba (a.k.a dstin)
out: A(1b) (a.k.a. srcout)
stencil: B(1a) (a.k.a. dstout)
atop: Ab + B(1  a) (a.k.a. srcatop)
xor: A(1b)+B(1a)
Blend modes, see https://en.wikipedia.org/wiki/Blend_modes
Multiply and Screen
multiply: AB, A if A < 0 and B < 0
screen: A+BAB if A or B <= 1, otherwise max(A, B)
overlay: multiply(A, 2*B) if B < 0.5, screen(A, 2*B  1) if B > 0.5
hardlight: multiply(2*A, B) if A < 0.5, screen(2*A  1, B) if A > 0.5
softlight: burnin if A < 0.5, lighten if A > 0.5
Dodge and burn
colordodge: brighten B towards A
colorburn: darken B towards A
pinlight: if B >= 0.5 then max(A, 2*B  1), min(A, B * 2) else
difference: abs(AB) (a.k.a. absminus)
exclusion: A+B2AB
divide: A/B, 0 if A < 0 and B < 0
Simple arithmetic blend modes
divide: A/B, 0 if A < 0 and B < 0
plus: A+B (a.k.a. add)
from: BA (a.k.a. subtract)
minus: AB
difference: abs(AB) (a.k.a. absminus)
min: min(A, B) (a.k.a. darken only)
max: max(A, B) (a.k.a. lighten only)
Hue, saturation and luminosity
hue: SetLum(SetSat(A, Sat(B)), Lum(B))
saturation: SetLum(SetSat(B, Sat(A)), Lum(B))
color: SetLum(A, Lum(B))
luminosity: SetLum(B, Lum(A))
Other
average: (A + B) / 2
conjointover: A + B(1a)/b, A if a > b
disjointover: A+B(1a)/b, A+B if a+b < 1
freeze: 1sqrt(1A)/B
geometric: 2AB/(A+B)
grainextract: B  A + 0.5
grainmerge: B + A  0.5
hypot: sqrt(A*A+B*B)
matte: Aa + B(1a) (unpremultiplied over)
reflect: A*A / (1  B)
See also:
“Digital Image Compositing” by Marc Levoy https://graphics.stanford.edu/courses/cs24806/comp/comp.html
“Compositing and Blending Level 1” https://www.w3.org/TR/compositing1/
“SVG Compositing Specification” https://www.w3.org/TR/SVGCompositing/
“ISO 320001:2008: Portable Document Format (July 2008)”, Sec. 11.3 “Basic Compositing Operations” http://www.adobe.com/devnet/pdf/pdf_reference.html
“Merge” by Martin Constable https://web.archive.org/web/20220627015903/http://www.opticalenquiry.com/nuke/index.php?title=Merge
“Merge Blend Modes” by Martin Constable https://web.archive.org/web/20220807185657/http://www.opticalenquiry.com/nuke/index.php?title=Merge_Blend_Modes
“Primacy of the B Feed” by Martin Constable https://web.archive.org/web/20220807185551/http://www.opticalenquiry.com/nuke/index.php?title=Primacy_of_the_B_Feed
grainextract and grainmerge are described in http://docs.gimp.org/en/gimpconceptslayermodes.html
Inputs
Input 
Description 
Optional 

B 
The main input. This input is passed through when the merge node is disabled. 
Yes 
A 
The image sequence to merge with input B. 
Yes 
Mask 
Yes 

A2 
Yes 
Controls
Parameter / script name 
Type 
Default 
Function 

Operation / 
Choice 
over 
The operation used to merge the input A and B images.
The operator formula is applied to each component: A and B represent the input component (Red, Green, Blue, or Alpha) of each input, and a and b represent the alpha channel of each input.
If Alpha masking is checked, the output alpha is computed using a different formula (a+b  a*b).
Alpha masking is always enabled for HSL modes (hue, saturation, color, luminosity).
atop: Ab + B(1  a) (a.k.a. srcatop)
average: (A + B) / 2
color: SetLum(A, Lum(B))
colorburn: darken B towards A
colordodge: brighten B towards A
conjointover: A + B(1a)/b, A if a > b
copy: A (a.k.a. src)
difference: abs(AB) (a.k.a. absminus)
disjointover: A+B(1a)/b, A+B if a+b < 1
divide: A/B, 0 if A < 0 and B < 0
exclusion: A+B2AB
freeze: 1sqrt(1A)/B
from: BA (a.k.a. subtract)
geometric: 2AB/(A+B)
grainextract: B  A + 0.5
grainmerge: B + A  0.5
hardlight: multiply(2*A, B) if A < 0.5, screen(2*A  1, B) if A > 0.5
hue: SetLum(SetSat(A, Sat(B)), Lum(B))
hypot: sqrt(A*A+B*B)
in: Ab (a.k.a. srcin)
luminosity: SetLum(B, Lum(A))
mask: Ba (a.k.a dstin)
matte: Aa + B(1a) (unpremultiplied over)
max: max(A, B) (a.k.a. lighten only)
min: min(A, B) (a.k.a. darken only)
minus: AB
multiply: AB, A if A < 0 and B < 0
out: A(1b) (a.k.a. srcout)
over: A+B(1a) (a.k.a. srcover)
overlay: multiply(A, 2*B) if B < 0.5, screen(A, 2*B  1) if B > 0.5
pinlight: if B >= 0.5 then max(A, 2*B  1), min(A, B * 2) else
plus: A+B (a.k.a. add)
reflect: A*A / (1  B)
saturation: SetLum(SetSat(B, Sat(A)), Lum(B))
screen: A+BAB if A or B <= 1, otherwise max(A, B)
softlight: burnin if A < 0.5, lighten if A > 0.5
stencil: B(1a) (a.k.a. dstout)
under: A(1b)+B (a.k.a. dstover)
xor: A(1b)+B(1a)

Bounding Box / 
Choice 
Union 
What to use to produce the output image’s bounding box.
Union (union): Union of all connected inputs.
Intersection (intersection): Intersection of all connected inputs.
A (a): Bounding box of input A.
B (b): Bounding box of input B.

Alpha masking / 
Boolean 
Off 
When enabled, the input images are unchanged where the other image has 0 alpha, and the output alpha is set to a+b  a*b. When disabled the alpha channel is processed as any other channel. Option is disabled for operations where it does not apply or makes no difference. 
R / 
Boolean 
On 
Use red channel from A input(s). 
G / 
Boolean 
On 
Use green channel from A input(s). 
B / 
Boolean 
On 
Use blue channel from A input(s). 
A / 
Boolean 
On 
Use alpha channel from A input(s). 
R / 
Boolean 
On 
Use red channel from B input. 
G / 
Boolean 
On 
Use green channel from B input. 
B / 
Boolean 
On 
Use blue channel from B input. 
A / 
Boolean 
On 
Use alpha channel from B input. 
R / 
Boolean 
On 
Write red channel to output. 
G / 
Boolean 
On 
Write green channel to output. 
B / 
Boolean 
On 
Write blue channel to output. 
A / 
Boolean 
On 
Write alpha channel to output. 
Invert Mask / 
Boolean 
Off 
When checked, the effect is fully applied where the mask is 0. 
Mix / 
Double 
1 
Mix factor between the original and the transformed image. 