Ronounours wrote:
ofnuts wrote:
What I have not quite figured out yet is how the blend mode formula (that assumes full opacity) is adapted when the mod'ed layer is partially transparent. Everyone knows that playing with the opacity slider for that layer tunes the amount of the blend mode effect...
From what I understood (and implemented), in this case the blending operation is actually decomposed into two steps :
- First, the computation of the blended image, according to the selected mode (assuming full opacity).
- Second, the computation of the alpha blending between the base layer and the blended layer. And in that case, it is well known how to get the resulting alpha-channel, when the two layers to composite have alpha-channels too (accrding to
http://en.wikipedia.org/wiki/Alpha_compositing).
I still don't get it. AFAIK in normal mode a layer is composited with the image resulting of the compositing of the stack below it. So if you have, bottom to top, A,B,C,D: A is composed with B:
RGBA(AB) = AlphaCompose(RGBA(A),RGBA(B))
then AB with C:
RGBA(ABC) = AlphaCompose(RGA(AB),RGBA(C))
No mystery here. I assume that the actual opacity of a pixel is the product of the alpha value of the pixels and the general opacity of the layer (as set on the Opacity slider).
So if we add a layer M in one of the blend modes, assuming full opacity of M we have:
RGB(ABCM) = Blend(RGB(ABC),RGB(M))
Alpha(ABCM) = Alpha(ABC)
where Blend() is one of the formulas, and there is no compositing... so what happens when A(M) isn't 100%? Is there, at least conceptually:
# compute RGB image assuming full opacity, as above
RGB(ABCM) = Blend(RGB(ABC),RGB(M))
# Compute alpha channel for that image
A(ABCM) = A(M)*A(ABC)
# Compute final by composing original with blended image
RGBA(Final)= AlphaCompose(RGBA(ABC),RGBA(ABCM))
How far off am I?