It is currently Sun Jun 30, 2024 5:49 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: How does it works on Layer Blending Mode "Add" with Alpha Channel?
PostPosted: Tue May 19, 2020 6:21 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: May 19, 2020
Posts: 7
GIMP Version: 2.8.14
Operating System: Windows
OS Version: Windows 10
GIMP Experience: Intermediate Level



I want to know the exact algorithm for layer blending mode "add" with alpha channel.

I blended foreground BLUE (layer blending mode "add") and background BLACK with some opacity settings.
This make me find some things.

1. Background opacity will be the resultant opacity.
2. Foreground opacity will linearly affect the resultant luminance values.
3. Background opacity will "nonlinearly" affect the resultant luminance values.

Is there any person who can explain precisely about nonlinearity of the case 3.
How does the algorithm for layer blending mode "add" work if the both layers have opacity.

Attachment:
File comment: Transitions of the resultant value of blending fg BLUE and bg BLACK by changing bg opacity for foreground opacities 100%, 75%, 50%, 25%.
BaddK.png
BaddK.png [ 8.43 KiB | Viewed 2425 times ]


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: How does it works on Layer Blending Mode "Add" with Alpha Channel?
PostPosted: Tue May 19, 2020 12:16 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4752
Everything is complicated in Gimp 2.8 because Gimp works with gamma-corrected values, so non-linearity is the rule (and even the Gamma isn't a "pure" function, some segments don't follow the general rule).

AFAIK the idea is that with two layers, these two methods give identical results

1) apply the blend mode wit the top layer at X% opacity
2) apply the blend mode with the top layer at 100% opacity and then compose with X% opacity over the bottom layer.

In other words:
Top(x%) ⊗ Bottom = (Top(100%)⊗ Bottom)(x%) ⊙ Bottom

where "⊗" is any blend mode and "⊙" is the "Normal" blend mode.

There may be exceptions for some 'discrete' modes such as Dissolve.

_________________
Image


Top
 Post subject: Re: How does it works on Layer Blending Mode "Add" with Alpha Channel?
PostPosted: Tue May 19, 2020 4:04 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: May 19, 2020
Posts: 7
Thank you for suggestion.
I think that I understand the algorithm for the "Normal" blend mode aka "over" operation.

Actually,
1) fg RGBA(0,0,255,127) "Add" bg RGBA(0,0,0,127) = actual result1 RGBA(0,0,101,127)
2) two steps
2-1) fg RGBA(0,0,255,255) "Add" bg RGBA(0,0,0,127) = actual im RGBA(0,0,169,127)
2-2) im RGBA(0,0,169,127) over bg RGBA(0,0,0,127) = actual result2 RGBA(0,0,112,191)

The calculation part 2-2 by over algorithm matches the actual result2.
Is your meaning that the difference between result1 and result2 come from gamma correction?


Top
 Post subject: Re: How does it works on Layer Blending Mode "Add" with Alpha Channel?
PostPosted: Tue May 19, 2020 9:40 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: May 19, 2020
Posts: 7
Sorry, I mistook the 2nd calculation.

Actually,
1) fg RGBA(0,0,255,127) "Add" bg RGBA(0,0,0,127) = actual result1 RGBA(0,0,101,127)
2) three steps
2-1) fg RGBA(0,0,255,255) "Add" bg RGBA(0,0,0,127) = actual im1 RGBA(0,0,169,127)
2-2) im1 RGBA(0,0,169,127)(Opacity50%) = actual im2 RGBA(0,0,169,63)
2-3) im2 RGBA(0,0,169,63) over bg RGBA(0,0,0,127) = actual result2 RGBA(0,0,66,159)

The calculation by Porter Duff's over algorithm without gamma correction produces
fg RGBA(0,0,169,63) over bg RGBA(0,0,0,127) = calc result RGBA(0,0,67,159)


Top
 Post subject: Re: How does it works on Layer Blending Mode "Add" with Alpha Channel?
PostPosted: Fri May 22, 2020 11:11 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: May 19, 2020
Posts: 7
I finally got your meaning. Thank you very much.

> Top(x%) ⊗ Bottom = (Top(100%)⊗ Bottom)(x%) ⊙ Bottom

In the following calculation, "LegacyAdd" and "LegacyOver" denote operations in Gimp 2.8
and "NewAdd" and "NewOver" denote operations in Gimp 2.10.

Additionally, in the following calculation, opacity(%) is different a little in Gimp 2.10.
For example, the result of 50% opacity of value 255 is 128 in Gimp 2.10 while the result is 127 in Gimp 2.8. I prefer 127 to 128 for 50% opacity of value 255.

1) fg RGBA(0,0,255,127) "LegacyAdd" bg RGBA(0,0,0,127) = actual result1 RGBA(0,0,101,127)
2) four steps
2-1) fg RGBA(0,0,255,255) "NewAdd" bg RGBA(0,0,0,127) = actual im1 RGBA(0,0,255,127)
2-2) im1 RGBA(0,0,255,127)(Opacity50%) = actual im2 RGBA(0,0,255,63)
2-3) im2 RGBA(0,0,255,63) "LegacyOver" bg RGBA(0,0,0,127) = actual im3 RGBA(0,0,101,159)
2-4) apply bg opacity to im3 RGBA(0,0,101,159) = actual result2 RGBA(0,0,101,127)

And now, I am confused because "NewOver" is strange for me.
Operation "LegacyOver" is the calculation based on Porter-Duff's way.
Now, how is the operation "NewOver" calculated?

3) fg RGBA(0,0,255,63) "LegacyOver" bg RGBA(0,0,0,127) = actual result RGBA(0,0,101,159)
4) fg RGBA(0,0,255,63) "NewOver" bg RGBA(0,0,0,127) = actual result RGBA(0,0,170,159)

So, I want to post this problem as a new topic.


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Eraser painting on layer that has alpha channel

2

No new posts Attachment(s) Dodge blending mode but with gradient fade?

12

No new posts Attachment(s) Alpha Channel not working

7

No new posts Attachment(s) Add Alpha Channel to All Layers

1

No new posts Attachment(s) Colorizing (only) with a Radial Gradient/ Alpha Channel

8



* Login  



Powered by phpBB3 © phpBB Group