base-node (.bn) v0.13.1

merge

Compositor Merge operations on premultiplied images: Porter-Duff over, under, in, out, atop, xor, stencil, mask, and plus, minus, multiply, screen, divide, difference, hypot; premult, unpremult, keymix

Targetsblender-compositor
Version0.13.1 (edition 2026)
Depends on—
Importuse merge or use merge (name, …)
Sourcestdlib/merge.bn · example examples/merge_showcase.bn

The Merge operations of compositing, on premultiplied images as the compositor gives them. Each one puts the image a over the image b, as in fg |> over(bg), and works on the four channels: the formula of its comment is the one of red, green, blue and alpha alike, a and b being the alphas of the two images. mix and mask fade the result back to b: b where they are 0. in, out, atop, stencil and mask are the operators of Porter and Duff; exclusive or is their xor, a word the language keeps.

merge

Alpha#

alpha of#

Alpha of the image

compositor graph "alpha of"(image: Color) -> Float
InputTypeDefaultRange
imageColor
geometry ✓shader ✗compositor ✓

not in a shader tree: SeparateColor has no output 'alpha'; outputs: red, green, blue

with alpha#

The colors of the image with this alpha, unchanged

compositor graph "with alpha"(image: Color, alpha: Float = 1.0) -> Color
InputTypeDefaultRange
imageColor
alphaFloat1.0
geometry ✗shader ✗compositor ✓

premult#

Colors multiplied by the alpha: a straight image made premultiplied

compositor graph premult(image: Color) -> Color
InputTypeDefaultRange
imageColor
geometry ✗shader ✗compositor ✓

unpremult#

Colors divided by the alpha, 0 where it is 0: a premultiplied image made straight

compositor graph unpremult(image: Color) -> Color
InputTypeDefaultRange
imageColor
geometry ✗shader ✗compositor ✓

copy alpha#

The colors of the image with the alpha of another

compositor graph "copy alpha"(image: Color, from: Color) -> Color
InputTypeDefaultRange
imageColor
fromColor
geometry ✗shader ✗compositor ✓

Combining#

weighted sum#

a times wa plus b times wb, on the four channels

compositor graph "weighted sum"(a: Color, wa: Float = 1.0, b: Color, wb: Float = 1.0) -> Color
InputTypeDefaultRange
aColor
waFloat1.0
bColor
wbFloat1.0
geometry ✗shader ✗compositor ✓

keymix#

a where the mask is 1, b where it is 0, on the four channels

compositor graph keymix(
    a: Color,
    b: Color,
    mask: Float = 1.0 in 0.0..1.0,
    mix: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
maskFloat1.00.0..1.0
mixFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

channel sqrt#

Square root of each of the four channels, 0 below 0

compositor graph "channel sqrt"(image: Color) -> Color
InputTypeDefaultRange
imageColor
geometry ✓shader ✗compositor ✓

not in a shader tree: SeparateColor has no output 'alpha'; outputs: red, green, blue

Porter-Duff#

over#

A + B(1 - a): a in front of b

compositor graph over(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

under#

A(1 - b) + B: a behind b

compositor graph under(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

in#

Ab: a where b is

compositor graph in(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

out#

A(1 - b): a where b is not

compositor graph out(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

atop#

Ab + B(1 - a): a over b, only where b is

compositor graph atop(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

exclusive or#

A(1 - b) + B(1 - a): a and b where the other is not (xor)

compositor graph "exclusive or"(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

stencil#

B(1 - a): b with a cut out of it

compositor graph stencil(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

mask#

Ba: b only where a is

compositor graph mask(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

matte#

Aa + B(1 - a): over, for a straight (unpremultiplied) a

compositor graph matte(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

conjoint over#

A + B(1 - a)/b, A where a > b: over for a and b that share their edges

compositor graph "conjoint over"(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

disjoint over#

A + B where a + b < 1, A + B(1 - a)/b elsewhere: over for a and b that do not overlap

compositor graph "disjoint over"(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

Arithmetic#

copy#

A: a in place of b

compositor graph copy(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

plus#

A + B

compositor graph plus(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

minus#

A - B

compositor graph minus(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

from#

B - A: a taken from b

compositor graph from(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

average#

(A + B) / 2

compositor graph average(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

multiply#

AB

compositor graph multiply(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

divide#

A / B, 0 where B is 0

compositor graph divide(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

screen#

A + B - AB: lightens, as two projectors on one screen

compositor graph screen(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

maximum#

max(A, B), channel by channel

compositor graph maximum(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

minimum#

min(A, B), channel by channel

compositor graph minimum(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

difference#

|A - B|

compositor graph difference(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

hypot#

sqrt(A² + B²): a sum of two images that keeps the brighter one

compositor graph hypot(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓

geometric#

2AB / (A + B), 0 where A + B is 0

compositor graph geometric(
    a: Color,
    b: Color,
    mix: Float = 1.0 in 0.0..1.0,
    mask: Float = 1.0 in 0.0..1.0
) -> Color
InputTypeDefaultRange
aColor
bColor
mixFloat1.00.0..1.0
maskFloat1.00.0..1.0
geometry ✗shader ✗compositor ✓