Given a screen color S_0 and a fragment color F_1 with opacity \alpha_1, the new screen color is:
If we apply again a color (F_2, \alpha_2), the new screen color is:
(alpha_1, alpha_2, F_1, F_2, S_0) (alpha_1, alpha_2, F_1, F_2, S_0) |
|
|
In the end:
We can see that we can find a color equivalent to the combination of F_1 and F_2, but its expression would be fairly complex. Instead, we can note that we can simplify the initial alpha blending by using premultiplied color and alpha value. They are denoted (F_i^*, \alpha_i^*) and are equal to:
Alpha blending becomes:
and then:
Now, the equivalent color has a simple expression:
We can push farther with a third layer:
So the equivalent color is now:
Let's denote the color-composition operator \oplus:
We can use it this way:
For simplicity, I will assume from now on that fragment colors are always premultiplied and screen colors are not. We can then omit the star notation:
The \oplus operator is associative:
We can then introduce the \bigoplus notation for a series of combination. We see easily that:
|
What happens if we apply many times the same color over and over:
(F, alpha, n, i) (F, alpha, n, i) |
|
The combination is then:
So let's define the function C: \Re^4\times \Re \rightarrow \Re^4 such that:
We also extend C with:
However, note that, because (F:\alpha) are premultiplied, then if \alpha=1, then F=0. So:
|
|
|
|
|
|
The function C is a function from \left[0,1\right]^4 to \left[0,1\right]^4. In other terms, the elements of a color are from 0 to 1, and so is the transparency.
First, the function \alpha \mapsto \alpha^n is from [0,1] to [0,1], whatever n is.
For the color, we can first note that, as we are working on pre-multiplied values, the upper bound is 1-\alpha. We can also note that the function is monotonic increasing with respect to the color, so we only need to evaluate the function on the bounds of the source set.
|
It is obvious that 1-\alpha^n is between 0 and 1. Also, C(0:\alpha,n) = (0:\alpha^n).
Therefore the color is always between 0 and 1.
|
|