Switch to full style
Ask all general Gimp related questions here
Post a reply

Layer Groups: Where's the Maths?

Sun Oct 16, 2022 6:36 am

GIMP Version: 2.10.18
Operating System: Linux
GIMP Experience: Experienced User



Having posted links to GIMP 2.10 documentation for Layers and Layer Groups, I settled back for a cozy evening-read of same.

I was surprised to find nothing in the latter regarding equations defining Layer-Group modes acting on Layers inside, corresponding to, for example, this one found in the former discussion of Layer modes:
Image

The Layer Group documentation mentions:
Layer Modes and Groups
A layer mode applied to a layer group acts on layers that are in this group only. A layer mode above a layer group acts on all layers underneath, outside and inside the layer groups.

but then goes on to discuss the Pass-through mode only.

However Layer Groups have apparently all the modes Layers do, and my experiments with Layer-Group mode-setting haven't led me to a greater understanding of how the Group mode interacts with underlying Layers' modes.

For example, I was about to ask, if I want to have three layers "add" to a background, should they be each be in Addition mode and the Group in Pass-through (or Normal: is there a difference in this simple case) or vice versa? However a quick consideration recalls that if underlying Layers are all in Normal mode, the topmost Layer will hide the others.

But what about more sophisticated examples?

What does Group-mode Additon do to Layer-mode Multiplication? (That may be a key question: when a Multiplication Layer is moved into a Group in Normal mode, what Layers is it then acting upon?)

I'm looking for a succint mantra that makes clear how Group modes affect Layer modes, both inside and outside it and other Groups below it in the Layer stack.

Something like Lenz's Law: "A change in magnetic flux will induce a current appearing in such a way as to tend to oppose the change in flux which induced it." (When stuck trying to figure out the polarity of an induced voltage, this little chant helps figure it out.)

"The mode of a Group will ..."

Perhaps I'm just asking about priorities: the order in which modes are applied.

Thank you.

Re: Layer Groups: Where's the Maths?

Sun Oct 16, 2022 11:09 am

Groups act as parentheses in formulas. A layer applies to what is below at the same nesting level. So in a group, the layers of the group are composited between themselves and the group represents this (virutal) result, to which the group's blend mode (and mask) is applied, before being composited in the group above....

For instance, in this image, the color circles in addition mode apply to the whole background and the shape is ignored.

ksnip_20221016-180614.png
ksnip_20221016-180614.png (41.53 KiB) Viewed 510 times


By putting them in a group with the shape, the action is restricted to the shape: the Addition mode keeps the opacity of the pixels it is composited to, without a group this is the whole background, with the group this is only the non-transparent pixels in the shape.

ksnip_20221016-180620.png
ksnip_20221016-180620.png (44.27 KiB) Viewed 510 times


If you prefer, instead of having:

Code:
( add R ( add G ( add B ( normal Shape  Background ) ) ) )

You have:
Code:
(Normal ( add R ( add G ( add B  Shape  ) ) ) Background )


(where "∅" is a virtual, empty layer)

Re: Layer Groups: Where's the Maths?

Sun Oct 16, 2022 2:25 pm

I'll add my spell-it-all-out-loud interpretation of your symbolic representations, for like (smaller-)minded people who will happen upon this.

> ( add R ( add G ( add B ( normal Shape Background ) ) ) )

"First [innermost parentheses] 'put'* Layer 'Shape' over Background using Normal mode."
"Next [next-outer parens] put Layer B over previous using Addition mode."
"Do the same for Layers G and then R."
* I hesitate to use the word 'add' to describe the parenthetical actions to avoid confusion with the mode "Addition."**
** Gosh! How often does one get to use superscripting in the forum?!

> (Normal ( add R ( add G ( add B Shape ) ) ) Background )

"First [innermost] put Layer B over Layer Shape using Addition mode."
"Then [next-outer] put Layer G over the previous."
"Do the same for Layer R."
"Finally put the previous over Layer Background using Normal mode."

If there are better words than "put" and "using" and "over", I will edit the post joyfully.

Re: Layer Groups: Where's the Maths?

Sun Oct 16, 2022 2:32 pm

To pay for my sin of having ofnuts do my work for me1, I've gone back and generated an .xcf for anyone else who'd like to experiment with Layer Modes, mimicking the earlier layout, but using a 50% gray background needed to see some mode effects. You'll find it attached.
Image

1 For which thank you, ofnuts. [And I suppose we'll all have to suffer through my sudden fascination with superscripting which fascinations usually disappear with the first nap.]

Re: Layer Groups: Where's the Maths?

Mon Oct 17, 2022 1:23 am

gramp wrote:
If there are better words than "put" and "using" and "over", I will edit the post joyfully.


Technically the operation of putting a layer in what Gimp calls "normal" mode over another is indeed called the "over" operation.
Post a reply