Re: [Gimp-developer] Is there any kind of documentation on the new layer blend modes?

On 8/16/19 10:31 AM, Ofnuts wrote:
Specifically, I'm wondering about the "Split", "Merge", and the group
"Passthrough" modes.

The only relevant Google answer is a paying video tutorial.

Of course I have checked the online doc...

There's indeed no organized documentation for all the new layer modes
yet, unfortunately.

For Pass Through mode, see:

Merge and Split are complementary modes, as their names suggest.  They
are similar to Normal and Erase modes, respectively, but they handle
alpha values differently.  The short version is that (when using their
default composite modes) Merge adds the alpha values of the input
layers, while Split subtracts them.  In other words, if the alpha values
of the bottom and top layers are A and B, respectively, the resulting
alpha values for Merge and Split are `min (A + B, 100%)`
and `max (A - B, 0%)`, respectively.

--- Wall-of-text warning.  Skip to the end for practical examples. ---

The slightly more advanced version has to do with how alpha values are
interpreted.  Alpha values can be seen as a property of the sub-pixel
geometry of a pixel; they specify how much of a pixel's area is covered
by the layer's content.  For example, when you rasterize an ideal shape,
such as a circle, pixels along the circumference will only be partially
covered by it; their alpha values specify how much of their area is
covered by the circle.  It's even more instructive to think of alpha
values in terms of probability: when picking a random point within a
pixel, the alpha value specifies the *probability* of the point
belonging to the layer.

The information conveyed by the alpha value is, of course, only partial:
while it tells you *how much* of a pixel's area is covered by its
content, it doesn't tell you exactly *which* portion of the pixel is
covered.  The latter becomes relevant when you combine multiple layers,
though: two layers having a pixel with 50% alpha each, when overlaid on
top of each other, can result in a pixel having anywhere between 50%
alpha (if the areas covered by both layers coincides exactly) to 100%
alpha (if the areas covered by both layers don't coincide at all).
There is no correct answer here: we have to make a certain assumption
about the relationship between the two layers.

The "ordinary" assumption, used by most layer modes, is that the two
layers are independent (in the probabilistic sense): whether a given
point within a pixel belongs to one layer doesn't affect the probability
of it belonging to the other layer as well; this leads to the familiar
`A + B - AB` formula for combining alpha values.  I call this the
"diffuse" assumption.  While it's a reasonable assumption in the general
case, in can lead to artifacts when applied inappropriately.  Most
notably, it can lead to semitransparent "seams" between opaque objects
that should, in theory, intermesh perfectly.  That's a common problem
with Inkscape, for example; it happens because Inkscape renders each
object separately, throwing away the actual sub-pixel geometry in favor
of alpha values, and then combining the alpha values with the (wrong)
assumption that the objects are independent of each other.

There are at least two other simple assumptions we can make about the
layers: the "complement" assumption, where the two layers are thought to
be mutually exclusive (i.e., to *complement* each other), and the
"coincide" assumption, where the two layers are thought to occupy the
same area (i.e., to *coincide* with each other).  Note, however, that
this formalism places some restrictions on the layers' alpha values
(namely, that `A + B <= 100%` for "complement", and that `A = B` for
"coincide").  A more precise formalism is that with "complement" the
intersection of the two layers is as small as possible, and with
"coincide" the intersection is as big as possible.

One day, GIMP might allow this assumption to be controlled separately
from the layer mode, through an additional layer attribute.  For now,
Merge and Split are singled out as two useful cases of non-diffuse
modes: Merge is simply Normal mode with the "complement" assumption, and
Split is Erase mode with the "coincide" assumption.


Merge mode should be used when combining layers that are, logically,
separate parts of a whole.  The archetypical example is that of cutting
an antialiased selection, and pasting as a new layer.  When using Normal
mode for the pasted layer, there's usually a semitransparent "seam"
around the selection's boundary (as mentioned above).  Using Merge mode
instead fixes the issue, as the two layers are two parts of one whole,
reproducing the original image.

Split mode is complementary to Merge: it allows you to erase one of the
parts out of the whole, producing its complement; the two parts can then
be combined using Merge mode to reproduce the original.  For example,
you can split an image into two layers by first isolating one of the
parts into a separate layer, combining the isolated layer with the
original image using Split mode and creating a new layer from the
result, and then combining the two layers using Merge mode:

Note that the original image in the example deliberately has
semitransparency to begin with, otherwise the same result could have
been achieved with Erase mode instead of Split (but not with Normal
instead of Merge).


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]