Bug 329026

Summary: Weird brush spacing with rotation->drawing angle
Product: [Applications] krita Reporter: Francesco B. <charblaze>
Component: Brush enginesAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: charblaze, dimula73, halla, info, joupent
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
URL: http://www.youtube.com/watch?v=wBDSc3xn3D4
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Chain brush broken by the spacing variation on diagonal and curved strokes.
A *.kpp brush preset to reproduce the bug easily
the KPP preset encapsuled in a ZIP
[^ screenshot : drawing angle test with a 'knife' like brush ]
Experimental change to ignore rotation
[^ mini visual guide to reproduce the bug easily ]
[^ screenshot : 'nyancat brush' is back ! ]

Description Francesco B. 2013-12-20 08:21:02 UTC
Created attachment 84191 [details]
Chain brush broken by the spacing variation on diagonal and curved strokes.

I found that Krita brush spacing behavior changes when you activate rotation->drawing angle.

For diagonal strokes, or the diagonal component of a curved stroke (when dx/dy ~ 1), the spacing is bigger than for straight vertical/horizontal lines. When drawing angle is not active the brush spacing is always constant, no matter the stroke direction.

Video of the issue: http://www.youtube.com/watch?v=wBDSc3xn3D4

The spacing is the same for all strokes, yet on diagonal strokes the gap in the pattern more than doubles. On curved lines you get spacing variation along the stroke.
*see attachment picture*
I think it's really annoying because it forces you to change the spacing on straight strokes, depending on direction, to get the same result. Moreover it kind of breaks custom and/or textured brushes for tire tracks, chains, cables, tentacles, etc. on curved lines, since you can't get uniform spacing.

Forum thread about the issue: http://forum.kde.org/viewtopic.php?f=139&t=118868
Comment 1 David REVOY 2013-12-20 09:46:42 UTC
Created attachment 84193 [details]
A *.kpp brush preset to reproduce the bug easily

( to be copied into ~/.kde/share/apps/krita/paintoppresets )
a brush preset who reproduce the bug of Francesco B ; trace orthogonal lines = ok spacing , trace diagonal = larger spacing.  
I confirm also the bug ( and the grave status of it ) as it might affect users with a popular speed-painting workflow rellying a lot on brush pattern.
Comment 2 David REVOY 2013-12-20 09:52:19 UTC
Created attachment 84194 [details]
the KPP preset encapsuled in a ZIP

I saw the bugtracker detected the KPP as a PNG , so I paste here another version of it encapsuled into a ZIP, to prevent the server to do PNG optimisations probably responsible of crunching the *.kpp data/metadata. 
to extract in ~/.kde/share/apps/krita/paintoppresets
Comment 3 Dmitry Kazakov 2013-12-22 10:35:28 UTC
Confirmed. It is not quite easy to implement it this way, though.
Comment 4 Francesco B. 2013-12-22 14:35:10 UTC
(In reply to comment #3)
> Confirmed. It is not quite easy to implement it this way, though.

It seems that one year ago it worked correctly.
From the wiki: http://userbase.kde.org/File:Krita-tutorial4-I.3.a-5.png
So It may be a regression rather than a new bug.
Comment 5 Dmitry Kazakov 2013-12-24 12:08:25 UTC
Hi, Francesco!

I have just check, and it seems the problem happens, because now the Spacing is Anisotropic by default, that is it depends on the Aspect Ratio of the brush. Could you please go to Spacing option and tick the "Isotropic Spacing" checkbox and check whether you still have a bug or not?

2All:
Probably, we should change the default value for the Spacing option?
Comment 6 Francesco B. 2013-12-24 18:14:50 UTC
Hi, Dmitry!

The bug happens even with isotropic spacing checked and with brushes with 1:1 aspect ratio, like the predefined brush U Circle shape 1.
Comment 7 Dmitry Kazakov 2013-12-24 19:14:41 UTC
Reopen then
Comment 8 David REVOY 2015-01-08 12:04:05 UTC
Created attachment 90287 [details]
[^ screenshot : drawing angle test with a 'knife' like brush ]

I add here another screenshot from 2.9beta : the two painting shapes in the scratch paintpad are painted with the same preset  with drawing angle and it's evident the spacing are different if the stroke is diagonal or vertical/horyzontal.
I wanted to make a color-smudge rake preset today, but this bug introduce too much banding in the diagonal angle of the resulting stroke ( on color-smudge , low spacing ).
Comment 9 joupent 2015-01-19 20:33:47 UTC
Created attachment 90524 [details]
Experimental change to ignore rotation

This is just a quick duct-tape change to test how the things would work if we completely ignore rotation for brush spacing.

Posting this as requested on IRC.
Comment 10 David REVOY 2015-01-19 21:40:35 UTC
Created attachment 90526 [details]
[^ mini visual guide to reproduce the bug easily ]

@tyyppi : I tried the patch, unfortunately it doesn't fix the issue.  But it scratch the right zone ; because the effect is different than before ( https://bugsfiles.kde.org/attachment.cgi?id=90287 ).

It feels like if the vertical strokes want to adapt spacing to the vertical brush tip geometry ( with ratio)  , while the horyzontal adapt to the horyzontal (with ratio too). It sounds logical if the brush doesn't rotate ( to preserve a visual spacing based in percent ).
Comment 11 Dmitry Kazakov 2015-01-25 15:43:49 UTC
Ok, I know how to solve this bug. I will implement it on Tuesday. The rotation should be calculated in the elliptical equation instead of the effective size.
Comment 12 Dmitry Kazakov 2015-01-27 12:20:07 UTC
Git commit ee2ad09322752ff9067a7a57e3ed5ebf268c1799 by Dmitry Kazakov.
Committed on 27/01/2015 at 12:18.
Pushed by dkazakov into branch 'calligra/2.9'.

Fix spacing of rotational brushes

The rotation should be counted not in the characteristic size but in the
elliptical equation for the spacing.

M  +17   -4    krita/image/kis_distance_information.cpp
M  +8    -2    krita/image/kis_distance_information.h
M  +9    -6    krita/plugins/paintops/libpaintop/kis_brush_based_paintop.cpp
M  +1    -1    krita/plugins/paintops/libpaintop/kis_brush_based_paintop.h

http://commits.kde.org/calligra/ee2ad09322752ff9067a7a57e3ed5ebf268c1799
Comment 13 David REVOY 2015-01-29 05:21:37 UTC
Created attachment 90773 [details]
[^ screenshot : 'nyancat  brush' is back ! ]

Many thanks Dmitry ! I just came back from a full week away in family, and I'm just testing your fix. Really cool; it unlocks a lot of possibilities with the brush engine. Thanks again.