Bug 409627 - Implement a Blending Mode corresponding to SAI's Luminosity/Shine mode
Summary: Implement a Blending Mode corresponding to SAI's Luminosity/Shine mode
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Unclassified
Component: Layer Stack (show other bugs)
Version: 4.2.2
Platform: Other All
: NOR wishlist
Target Milestone: ---
Assignee: Tiar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-08 16:24 UTC by Tyson Tan
Modified: 2019-08-04 09:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Addition blending mode in Krita with transparent background (324.81 KB, image/png)
2019-07-08 16:27 UTC, Tyson Tan
Details
Addition blending mode in Krita with black background (325.44 KB, image/png)
2019-07-08 16:27 UTC, Tyson Tan
Details
Source file of the above 2 demo pics (1.78 MB, application/x-krita)
2019-07-08 16:28 UTC, Tyson Tan
Details
Screenshot of the workaround + new mode (83.62 KB, image/png)
2019-07-15 17:57 UTC, Tiar
Details
SAI2 Shine transparency test (122.49 KB, image/png)
2019-08-04 09:59 UTC, Tyson Tan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tyson Tan 2019-07-08 16:24:42 UTC
SUMMARY
SAI's "Luminosity (SAI1)" or "Shine (SAI2)" layer blending mode is widely used by the newer generation of digital artists. This blending mode is useful because it can easily create highlight effect that looks vividly colorful in the gradient part while clipping to a colored white at the extremes, loosely resembling that of the natural lighting. It's one of SAI's killer feature and has been mentioned again and again as one of the major reasons for which SAI artists are unwilling to adopt Krita or even Photoshop, despite knowing the alternatives are superior in almost every other way. It'd be nice for Krita to implement such a feature.

We can recreate such effect in the current version of Krita using 2 different workarounds:

Method A:
1) Create a new layer above the base color layer
2) Set layer blending mode as "Addition" or "Linear Dodge"
3) Fill this layer with pure black
4) Paint highlight effect with very bright colors

Method B:
1) Create a new group layer above the base color layer
2) Set blending mode of the group as "Addition" or "Linear Dodge"
3) Create a new fill layer inside the group, fill color set to black
4) Above the fill layer, create a new normal layer
5) Paint highlight effect with very bright colors

Additional information:
You can do this in Photoshop by using "Linear Dodge" with "Transparent Shape Layer" box unchecked in Layer Properties.

I suspect that this "feature" of SAI is actually a happy accident, resulted by SAI treating 100% transparent pixels as pure black (0,0,0) when doing color maths. The way the extreme white parts clip resembles that of a characteristic sRGB gamma corrected value curve. And because sRGB gamma corrected value curve is created after how human perceives value, it explains quite well why this blending mode looks so appealing.

I will attach demonstration images later.
Comment 1 Tyson Tan 2019-07-08 16:27:02 UTC
Created attachment 121389 [details]
Addition blending mode in Krita with transparent background
Comment 2 Tyson Tan 2019-07-08 16:27:28 UTC
Created attachment 121390 [details]
Addition blending mode in Krita with black background
Comment 3 Tyson Tan 2019-07-08 16:28:06 UTC
Created attachment 121391 [details]
Source file of the above 2 demo pics
Comment 4 Tiar 2019-07-15 17:57:37 UTC
Created attachment 121532 [details]
Screenshot of the workaround + new mode

This is the result of my work for now.

On the left, you can see the workaround with a group that has a black layer on Normal mode (let's call it "workaround middle layer"), then a layer with the new color in Normal mode (let's call it "workaround top layer"), and then the whole group is in Addition mode (let's call it "workaround group"). Right side is my new blending mode. Color values are just the same, I checked it.

I have a question how this blending mode should behave while being on a layer that has a lower opacity than 50%. 

On the right side of the screenshot you can see two rows of smaller yellowish-whitish circles. The first row is compiled out of 9 circles painted with 20, 50, 40 etc. to 100% of opacity. The second one is the same layer, but the opacity of the layer is 50%. As you can see, the brightest circle on the layer is yellow and looks the same as 50% opacity circle in the top row.

On the left side there are two rows under the first "reference" one - first one is when you lower the opacity of the "workaround top layer" to 50%. The second one is when you lower the opacity of the "workaround group" to 50%. The first row has values identical to what you can get in the new blending mode. The second one is an example of how I can make it behave.

The question is, whether you think it should behave (after lowering opacity of the layer) like the second small circle row or like the third one? What about making a transparency mask? (If I leave it as it is, it will be always consistent; I'm just not sure if it's what is expected. This is the first blending mode that uses alpha for something else than just blending two output colors together, here we calculate the result color using the alpha value). If you don't have a preference, please tell me so, too.

Another question: do you have an access to SAI or Photoshop? I need to know what the value of the color is if you put a layer of color (10, 100, 200) in 30% and on top of that color (250, 200, 150) in 50% in the Luminosity (SAI) blending mode. Workaround don't work at all on that example and I think my blending mode can have "incorrect" colors there.
Comment 5 Tiar 2019-07-17 12:27:00 UTC
Git commit 4f16ff7c1d5cd727360ef1845377b2f9a960e74c by Agata Cacko.
Committed on 17/07/2019 at 12:21.
Pushed by tymond into branch 'master'.

Implement SAI-like Luminosity blending mode

It was requested to make a new lighten mode that behaves
just like a Luminosity/Shine mode in SAI. This commit contains
the code that adds it to the program.

M  +1    -0    libs/pigment/KoCompositeOpRegistry.cpp
M  +4    -1    libs/pigment/KoCompositeOpRegistry.h
M  +16   -0    libs/pigment/compositeops/KoCompositeOpFunctions.h
M  +88   -15   libs/pigment/compositeops/KoCompositeOpGeneric.h
M  +42   -2    libs/pigment/compositeops/KoCompositeOps.h

https://invent.kde.org/kde/krita/commit/4f16ff7c1d5cd727360ef1845377b2f9a960e74c
Comment 6 Tyson Tan 2019-07-19 05:38:41 UTC
(In reply to Tymond from comment #4)
> Created attachment 121532 [details]
> Screenshot of the workaround + new mode
> 
> This is the result of my work for now.
> 
> On the left, you can see the workaround with a group that has a black layer
> on Normal mode (let's call it "workaround middle layer"), then a layer with
> the new color in Normal mode (let's call it "workaround top layer"), and
> then the whole group is in Addition mode (let's call it "workaround group").
> Right side is my new blending mode. Color values are just the same, I
> checked it.
> 
> I have a question how this blending mode should behave while being on a
> layer that has a lower opacity than 50%. 
> 
> On the right side of the screenshot you can see two rows of smaller
> yellowish-whitish circles. The first row is compiled out of 9 circles
> painted with 20, 50, 40 etc. to 100% of opacity. The second one is the same
> layer, but the opacity of the layer is 50%. As you can see, the brightest
> circle on the layer is yellow and looks the same as 50% opacity circle in
> the top row.
> 
> On the left side there are two rows under the first "reference" one - first
> one is when you lower the opacity of the "workaround top layer" to 50%. The
> second one is when you lower the opacity of the "workaround group" to 50%.
> The first row has values identical to what you can get in the new blending
> mode. The second one is an example of how I can make it behave.
> 
> The question is, whether you think it should behave (after lowering opacity
> of the layer) like the second small circle row or like the third one? What
> about making a transparency mask? (If I leave it as it is, it will be always
> consistent; I'm just not sure if it's what is expected. This is the first
> blending mode that uses alpha for something else than just blending two
> output colors together, here we calculate the result color using the alpha
> value). If you don't have a preference, please tell me so, too.
> 
> Another question: do you have an access to SAI or Photoshop? I need to know
> what the value of the color is if you put a layer of color (10, 100, 200) in
> 30% and on top of that color (250, 200, 150) in 50% in the Luminosity (SAI)
> blending mode. Workaround don't work at all on that example and I think my
> blending mode can have "incorrect" colors there.

Hi Tymond,
Thank you for helping us with the new blending mode! I'm very busy at the moment so I cannot do the tests right away. I did secure access to PS and SAI again, and I will let you know about the result. I cannot fully understand what you were saying by a glance, so please give me some time.
Comment 7 Halla Rempt 2019-07-29 08:35:38 UTC
Git commit 5c4cbc44b182067d956139770d02534635cb3d43 by Boudewijn Rempt, on behalf of Agata Cacko.
Committed on 29/07/2019 at 08:33.
Pushed by rempt into branch 'krita/4.2'.

Implement SAI-like Luminosity blending mode

It was requested to make a new lighten mode that behaves
just like a Luminosity/Shine mode in SAI. This commit contains
the code that adds it to the program.

M  +1    -0    libs/pigment/KoCompositeOpRegistry.cpp
M  +4    -1    libs/pigment/KoCompositeOpRegistry.h
M  +16   -0    libs/pigment/compositeops/KoCompositeOpFunctions.h
M  +88   -15   libs/pigment/compositeops/KoCompositeOpGeneric.h
M  +42   -2    libs/pigment/compositeops/KoCompositeOps.h

https://invent.kde.org/kde/krita/commit/5c4cbc44b182067d956139770d02534635cb3d43
Comment 8 Tyson Tan 2019-08-04 09:59:39 UTC
Created attachment 121927 [details]
SAI2 Shine transparency test

Hi Tymond,

I really appreciate your help, but I was unable to fully understand what you were discussing in comment #4. English not being my native language and I;m very sorry!

This was a request from the community and I don't use SAI at all myself. They did not mention the transparency, and they reached out to me through way too many layers of middle men, information just can't come through smoothly. I can't say I fully understood what they precisely wanted either. I asked people to provide feedback and linked to this page. I hope they can help us some day.

On the other hand...

I do have access to SAI right now and if reluctantly, maybe also PS (but I really rather donate the money to Krita). I can help you with further tests.

In the attachment, I did the last test you asked:
1) a layer of color (10, 100, 200) in 30%
2) on top of that color (250, 200, 150) in 50% in the Luminosity/Shine (SAI) blending mode.