You can paste this into https://markdownlivepreview.org/ to see the equations.

Prompted into Claude:

My goal is to prove mathematically that doing composition using premultiplied alpha blending into intermediate images then compositing those images together is equivalent to straight alpha blending multiple subjects into a single image. Write out the equations describing blending 3 layers using each technique. Then simplify both equations to reframe them until they are identical. Show intermediate steps. Keep the description as concise as possible. You can assume alpha is always in [0,1]

Proving Premultiplied Composition Equivalence

Definitions

Straight alpha blend (over operation):
$$C_{out} = \alpha_s C_s + (1 - \alpha_s) C_d$$
$$\alpha_{out} = \alpha_s + (1 - \alpha_s) \alpha_d$$

Premultiplied format: $C' = \alpha C$

Premultiplied blend:
$$C'{out} = C'_s + (1 - \alpha_s) C'_d$$
$$\alpha
{out} = \alpha_s + (1 - \alpha_s) \alpha_d$$


Setup

Three layers bottom-to-top: $(C_1, \alpha_1)$, $(C_2, \alpha_2)$, $(C_3, \alpha_3)$ over black background.


Method 1: Straight Alpha (All at Once)

Blend 1 over black:
$$R_1 = \alpha_1 C_1, \quad A_1 = \alpha_1$$

Blend 2 over result:
$$R_2 = \alpha_2 C_2 + (1-\alpha_2) R_1 = \alpha_2 C_2 + (1-\alpha_2)\alpha_1 C_1$$
$$A_2 = \alpha_2 + (1-\alpha_2)\alpha_1$$

Blend 3 over result:
$$R_3 = \alpha_3 C_3 + (1-\alpha_3) R_2$$
$$= \alpha_3 C_3 + (1-\alpha_3)\alpha_2 C_2 + (1-\alpha_3)(1-\alpha_2)\alpha_1 C_1$$

$$A_3 = \alpha_3 + (1-\alpha_3)\alpha_2 + (1-\alpha_3)(1-\alpha_2)\alpha_1$$


Method 2: Premultiplied with Intermediate

Stage A: Blend layers 1 and 2 into intermediate $I$

Convert to premultiplied: $C'_i = \alpha_i C_i$

$$C'_I = C'_2 + (1-\alpha_2)C'_1 = \alpha_2 C_2 + (1-\alpha_2)\alpha_1 C_1$$
$$\alpha_I = \alpha_2 + (1-\alpha_2)\alpha_1$$

Stage B: Blend layer 3 over intermediate $I$

$$C'_{final} = C'_3 + (1-\alpha_3)C'_I$$
$$= \alpha_3 C_3 + (1-\alpha_3)[\alpha_2 C_2 + (1-\alpha_2)\alpha_1 C_1]$$
$$= \alpha_3 C_3 + (1-\alpha_3)\alpha_2 C_2 + (1-\alpha_3)(1-\alpha_2)\alpha_1 C_1$$

$$\alpha_{final} = \alpha_3 + (1-\alpha_3)\alpha_I = \alpha_3 + (1-\alpha_3)\alpha_2 + (1-\alpha_3)(1-\alpha_2)\alpha_1$$


Comparison

Method 1 (straight):
$$R_3 = \alpha_3 C_3 + (1-\alpha_3)\alpha_2 C_2 + (1-\alpha_3)(1-\alpha_2)\alpha_1 C_1$$

Method 2 (premultiplied intermediate):
$$C'_{final} = \alpha_3 C_3 + (1-\alpha_3)\alpha_2 C_2 + (1-\alpha_3)(1-\alpha_2)\alpha_1 C_1$$

$$R_3 = C'{final} \quad \checkmark$$
$$A_3 = \alpha
{final} \quad \checkmark$$


Key Insight

The premultiplied blend formula $C'_{out} = C'_s + (1-\alpha_s)C'_d$ is algebraically identical to the expanded straight formula when you substitute $C' = \alpha C$. The associativity holds because both reduce to the same weighted sum where each layer's contribution is attenuated by the product of $(1-\alpha)$ terms for all layers above it.

Edit

Pub: 30 Dec 2025 20:25 UTC

Views: 62