Bug 414386 - 'Split Alpha' creates unexpected edges with some brush blending modes
Summary: 'Split Alpha' creates unexpected edges with some brush blending modes
Status: RESOLVED NOT A BUG
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-22 06:20 UTC by acc4commissions
Modified: 2020-08-20 21:29 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
the file (900.75 KB, application/x-krita)
2019-11-22 06:20 UTC, acc4commissions
Details
(capture) black artifacts in vector text areas (43.64 KB, image/png)
2019-11-22 06:22 UTC, acc4commissions
Details
(capture) resulting edges (66.83 KB, image/png)
2019-11-22 06:23 UTC, acc4commissions
Details

Note You need to log in before you can comment on or make changes to this bug.
Description acc4commissions 2019-11-22 06:20:57 UTC
Created attachment 124057 [details]
the file

SUMMARY
git f41bc3f

'Split Alpha' (+ other alpha-related operations) creates unexpected edges with some brush blending mode.

I'm not sure it's related to Bug 410516, but it produces very similar results.



STEPS TO REPRODUCE
1. Draw something on the layer with various brush blending modes.
2. Layers docker > Right click > Split alpha > Alpha into mask
3. Uncheck the visible option of its transparency mask.

OBSERVED RESULT
Edges of brushstrokes appear in various shapes. 
'Normal' produces blocky edges.
'Overlay', 'Screen', 'Soft Light (SVG)', 'Multiply' etc produces sharp edges with artifacts.
Only 'Luminosity / Shine (SAI)' produces the smooth result. 

EXPECTED RESULT
It shouldn't vary, I guess?


SOFTWARE/OS VERSIONS
Windows: Win7
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION

Plus, there's this weird black triangles appears in vector text areas...
Comment 1 acc4commissions 2019-11-22 06:22:23 UTC
Created attachment 124058 [details]
(capture) black artifacts in vector text areas
Comment 2 acc4commissions 2019-11-22 06:23:53 UTC
Created attachment 124059 [details]
(capture) resulting edges
Comment 3 Dmitry Kazakov 2019-11-22 06:51:49 UTC
Hi, acc4commisions!

That is a very interesting report :) I've never though about these effects. Most of them are the consequence of the design decisions we did for optimization purposes. So before explaining them I would like to ask you, what is your workflow? Why do you want these edges to be smooth?


Detailed explanation:

> 'Normal' produces blocky edges.

By definition, when alpha is null, the value of color channels is undefined (in normal user workflow). Therefore, if we know that the destination alpha is null,  we just copy the color of source channels, disregarding alpha. It is faster, and normal users will not see the difference.

And you see blocky edges, because in "Normal" composite op we don't operate on individual pixels, but on strides of 8(!) pixels (due to AVX CPU optimizations). If you go to Settings->Performance->Disable AVX Optimizations and restart Krita you'll see that the edges become less blocky, like in "Overlay", but without artifacts.

> 'Overlay', ... etc produces sharp edges with artifacts

It happens because of a division in 8-bit numerical space. When alpha is low, then division/multiplication operations become non-stable. If you switch to 32-bit float color space, then the bug will disappear. Theoretically, we can try to fix it: Normal doesn't have this effect, though it has a little bit different blending. Though it might take quite a bit of time with uncertain results.

> Only 'Luminosity / Shine (SAI)' produces the smooth result

It is actually a bug in 'Luminosity / Shine (SAI)' and it should be fixed with 410516 :) This blending mode blends-in black color into the edges, which makes the edge look smooth. Just compare the strokes on white background.

> Plus, there's this weird black triangles appears in vector text areas...

Yes, it is a bug and should be fixed. It would be better if you added a separate ticket for that.
Comment 4 acc4commissions 2019-11-22 07:08:10 UTC
Actually I don't care about this particular bug. I just reported it because it seemed related to 410516. :)

So if you need to ignore this for any development purpose I won't mind. Just hope this report helped.
Comment 5 acc4commissions 2019-11-27 18:06:15 UTC
> > Plus, there's this weird black triangles appears in vector text areas...
> 
> Yes, it is a bug and should be fixed. It would be better if you added a
> separate ticket for that.

https://bugs.kde.org/show_bug.cgi?id=414581
Comment 6 wolthera 2020-04-24 13:13:25 UTC
I guess confirmed.
Comment 7 acc4commissions 2020-04-25 05:27:48 UTC
(In reply to wolthera from comment #6)
> I guess confirmed.

As a user I don't even consider this an issue to be honest. I doesn't cause any problem in the actual painting process. Like I said I reported this because it seemed related to another bug(410516), but yeah, I'm not against fixing it either...
Comment 8 Dmitry Kazakov 2020-08-20 21:29:59 UTC
Okay, the bug looks really interesting, but I don't think we can fix it without changing behavior and speed of existing blending modes.

The only exception is 'Luminosity / Shine (SAI)', but it has its own bugreport in bug 410516.

And since the big does not cause any real workflow problems to the reporter, I guess we can just close it :)

Thank you, acc4commissions, for a really interesting observation! :)