Bug 251612

Summary: Brush softness acts odd when a painted line intersects itself
Product: [Applications] krita Reporter: Kubuntiac <user581>
Component: Brush enginesAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: cberger, dimula73, halla, lukast.dev, martinxyz, pentalis
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: file demonstrating the effect
Self intersecting , semi-transparent, soft brush line in The Gimp
In gimp
Right angle in krita
demonstration by david revoy of the problem.

Description Kubuntiac 2010-09-17 21:15:17 UTC
Version:           svn trunk (using KDE 4.5.1) 
OS:                Linux

When painting lines that overlap, you get an unexpected effect if a line that you are painting pintersects with itself. It looks different from when it instersects with any other line already painted.

Reproducible: Always

Steps to Reproduce:
Draw a line that intersects with itself. Look at the corners where it overlaps

Actual Results:  
The line seems to fade inwards at the corners where it overlaps

Expected Results:  
The line looks the same at the intersection, as it does when two intersecting lines are painted

OS: Linux (i686) release 2.6.32-24-generic-pae
Compiler: cc
revision:1176447
Comment 1 Adam C 2010-09-19 10:45:54 UTC
Created attachment 51803 [details]
file demonstrating the effect

this is probably due to the way the stroke is composited. it takes max(source, dest) instead of adding the colours. so if on a intersecting point there is grey 100 it is overwritten with grey 80 instead of adding it to grey 20. 

to change the behavior, change to build up painting mode. i suppose, that this is by design, but i don't really know it.
Comment 2 Dmitry Kazakov 2010-11-14 12:12:58 UTC
Yes, this is due to the differences between Wash mode and Build-up mode. Wash mode is supposed to work exactly as described in the report =)
Comment 3 Kubuntiac 2010-11-14 12:40:32 UTC
I don't pretend to understand the wash / buildup modes, but I am very certain that no artist would expect it to work the way it currently does by default. Surely this is not a good thing...
Comment 4 LukasT 2010-11-14 13:47:18 UTC
You can compare the results with GIMP. In GIMP the mode is called Incremental.
Comment 5 Kubuntiac 2010-11-14 13:59:59 UTC
Created attachment 53408 [details]
Self intersecting , semi-transparent, soft brush line in The Gimp

I'm not referring to the name. I'm referring to how lines look when painted. In Gimp they look exactly as I would expect (even if I'd never used Gimp). ie there are no strange white "corners" drawn where a line intersects itself. (Even if those are somehow "expected" by the algorithm). See attached image from the Gimp.
Comment 6 Halla Rempt 2010-11-14 19:09:42 UTC
kubuntiac is right. This is the zombie brains effect described by Deevad, too, I think.
Comment 7 Dmitry Kazakov 2010-11-14 20:31:45 UTC
Ok, should we set build-up mode as default then? Or there is some other way out?
Comment 8 Cyrille Berger 2010-11-15 09:44:10 UTC
Created attachment 53426 [details]
In gimp

It is a tricky problem.

Gimp is basically cheating, instead of "alpha darken" they are using the "normal" blend, and they are using brush with an exponential fade, which allow to still get lines that are soft. But this has significant drawbacks:
1) points and lines have different aspect, this also means the preview of the brush looks significatively different of what it is drawn on the canvas (see the left part of the attachement)
2) the fading of the line is dependent of the spacing (see the right part of the attachement)
3) it is not possible to draw a line with a high amount of fading, this image was made with hardness set at minimum
Comment 9 Cyrille Berger 2010-11-15 09:56:04 UTC
Created attachment 53428 [details]
Right angle in krita

While in Krita we have choosen to follow the "mathematicaly" correct way. We use "alpha darken" in wash mode (non-incremental), meaning that new color is added only if the pixel has a higher alpha value (and it does some mixing).
This way of doing things fix all drawbacks from the gimp solution. However, it has the drawback of that oddness when line intersects itself.

In the attached image, I have created two lines with a right angle (perfect one), if you use the color picker and follow the individual lines horizontally, and then vertically, you can see that they have equal color value (take a pixel of the horizontal part, then go right horizontally and pick color, untill you arrive at the corner and then go down). This is very interesting, because, if you look at zoom = 100%, you can see the ghost line of David (or the oddness of Kubuntiac), while if you look at the data it looks like a perfect right angle.
Comment 10 Cyrille Berger 2010-11-15 10:06:27 UTC
To conclude on this, as I said it is a tricky problem, as we can see, both solutions have problems. I am not sure if there is a fix to that problem. A possibility would be to add a new mode for paintop, using the normal paintop instead of alphadarken. But I am also rather convinced that our choice is the reason why people think krita has a more natural drawing than gimp.
Comment 11 LukasT 2010-11-17 10:41:11 UTC
>But I am also rather convinced that our choice is the
>reason why people think krita has a more natural drawing than gimp.

Why do you think so, which people :) ? I saw people usually compain about our choice, they see it as bug: deevad, Kubuntiac and enkithan.

Maybe adding new mode that mimics MyPaint and GIMP as fix to this bug?
Comment 12 Cyrille Berger 2010-11-17 11:35:58 UTC
> I saw people usually compain about our choice, they see it as bug: deevad,
> Kubuntiac and enkithan.

yes they complain about the line crossing, do they complain about the other part of the behaviour ?
Comment 13 pentalis 2011-06-11 07:25:56 UTC
The effect with the perfect angular line seems to be due to Mach bands:
http://en.wikipedia.org/wiki/Mach_bands

Or to other optical effects:
http://www.michaelbach.de/ot/lum_cobc/index.html
http://www.michaelbach.de/ot/lum_diamond/index.html

The human body is like a piece of spagetti code programmed by countless different entities. The eyes do some adjustments to the image, then other changes are done as the information transits to the brain, then the brain does the final changes. Sometimes a set of changes undoes the previous changes. Sometimes we see things that the computer knows are not there, but we force the poor computer to render things incorrectly so we can feel peace of mind.

Just my 0.02   :)
Comment 14 Halla Rempt 2011-06-11 10:44:04 UTC
Created attachment 60882 [details]
demonstration by david revoy of the problem.
Comment 15 LukasT 2011-06-11 11:01:55 UTC
From Cyrille's conclusion at #comment10 I think we could just add new GIMP-like mode and let the artist decide what he wants in the moment, if he prefers krita's clean style or gimp's cheating mode :)
Comment 16 Sven Langkamp 2011-06-16 12:40:38 UTC
Is this bug fixed now?
Comment 17 Halla Rempt 2011-06-16 12:58:04 UTC
As far as I'm concerned, yes, but let Bugsbane check Plassy's new code :-)
Comment 18 Kubuntiac 2011-06-17 08:59:38 UTC
Joy! <3 <3 <3 <3 <3 <3 ! Bugsbane is happy and declares this bug resolved. +1 to good sir Plassy :D