Bug 281364

Summary: Bad aliasing problem when using autobrush at small sizes
Product: [Applications] krita Reporter: Halla Rempt <halla>
Component: Brush enginesAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: critical CC: enkithan, goffrie, info
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: potential fix
disable supersampling for big brushes

Description Halla Rempt 2011-09-05 07:53:14 UTC
We have a bad aliasing problem when painting with a small autobrush. It is a regression since 2.3. See http://forum.kde.org/viewtopic.php?f=138&t=96043&hilit=ramon&start=15 for more discussion.

This is a really big problem for Krita -- we need to find a solution.

Also from IRC:

18:05:36 < basse> http://dl.dropbox.com/u/2965641/a.png
18:05:57 < basse> lot of aliasing
...
08:30:37 < basse> boud: yes, i compiled git version, so this is recent krita
08:32:30 < basse> so i'm not trying to see what is different, why autobrush produces this
09:02:28 < boud> basse: we had a discussion about it on the forum; we
09:02:34 < boud> re not sure what happens either...
09:03:52 < basse> http://dl.dropbox.com/u/2965641/aa.png  
09:04:14 < basse> ok, have to check the forums, but its not happening so much with big brushes.. but 
                  small ones you can't really use :( 
09:04:32 < boud> the weird thing is, with the predefined brushes it seems to work ok
09:04:48 < basse> and i dont remember this behaviour in the krita i had from repos
09:05:07  * basse checks predefineds
09:06:54 < basse> oh, you are right. it's better there.
09:07:07 < basse> i had 1x1 pixel brush in gimp too because i never trusted those autobrushes
09:07:50 < boud> there might even be a difference if you select the soft brush option in the autobrush
09:08:43 < basse> there was a bit i noticed that, but not much
09:09:00 < basse> funny, if i scale my 1x1 pixel brush it comes out as triangle :)  
09:09:15 < basse> it's meant to be 1 pixel size anyways
Comment 1 Geoffry Song 2011-09-15 00:58:38 UTC
Created attachment 63656 [details]
potential fix

This patch (not pushed) supersamples the autobrush to smooth it. Currently the SUPERSAMPLING parameter is set to 3, i.e. it averages 9 points in a 3x3 grid. It significantly reduces this problem, as far as I can tell. However, I'm concerned about (a) the hack-like nature of the patch, and (b) possible performance issues with calling valueAt a large number of times. Suggestions?
Comment 2 Sven Langkamp 2011-09-15 13:54:43 UTC
valueAt is really expensive operation, so it should be avoid if possible. It shouldn't be used with big brushes as that would be a major performance hit.
Comment 3 Halla Rempt 2011-09-16 06:15:24 UTC
Maybe we can just enable it for small brushes? The aliasing problem doesn't happen with big brushes anyway.
Comment 4 Geoffry Song 2011-10-01 19:57:31 UTC
Created attachment 64130 [details]
disable supersampling for big brushes

This does what boud suggested, although I'm not quite sure if this is the right heuristic to use.

Patch applies on top of the previous one.
Comment 5 Geoffry Song 2011-10-01 19:58:00 UTC
I also wasn't on the CC for this bug. Whoops.
Comment 6 David REVOY 2011-10-01 21:21:08 UTC
For the moment my workaround with small brush is to apply this sort of curves , then the aliasing is ok ( maybe a bit too smooth, I have to find the right setting ) http://img11.imageshack.us/img11/8024/aliasingautobrush.jpg
Comment 7 Halla Rempt 2011-10-02 11:25:05 UTC
Looks good to me! What do you think, Sven?
Comment 8 Halla Rempt 2011-10-08 12:47:59 UTC
I don't notice a visible slowdown -- it might be possible to optimize some more, but I want to push these patches now.
Comment 9 Halla Rempt 2011-10-08 13:03:22 UTC
But the bug shouldn't be closed yet.
Comment 10 Halla Rempt 2011-10-09 11:45:25 UTC
*** Bug 247363 has been marked as a duplicate of this bug. ***
Comment 11 Halla Rempt 2011-10-15 08:33:04 UTC
The unittest is fixed -- I think we can close this bug now, right?
Comment 12 Geoffry Song 2011-10-15 23:57:36 UTC
I don't think 247363 is a dupe of this bug, though. That bug is about the fading of large brushes, which is unaffected by the patch for this bug.
Comment 13 Halla Rempt 2011-10-16 12:11:50 UTC
Ok, reopened that one, closed this one then. Goffrie, do you have any ideas about 247363?