Bug 447562

Summary: Issue with certain MyPaint brushes
Product: [Applications] krita Reporter: jesus <qb-ray_otk>
Component: Brush enginesAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: info
Priority: NOR    
Version: 5.0.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Attachments: here's a screenshot of the affected brushes, strokes made with "basic" and "weighted" smoothing mode
here's a screenshot of the affected brushes, strokes made with "stabilizer" mode, sample count 70
Ink Pen (mypaint) stroke artifacts with Slow Tracking 0 and Stabilizer

Description jesus 2021-12-27 06:01:03 UTC
Created attachment 144885 [details]
here's a screenshot of the affected brushes, strokes made with "basic" and "weighted" smoothing mode

SUMMARY
***
The Pencil 2B and Ink Pen brushes in the MyPaint bundle produce noticeable jagged strokes, which look different depending on the Smoothing mode in use, most notably using the "Stabilizer" mode even at the lowest "Sample Count" values.
This seems to happen regardless of Input device, giving the same result with tablet or mouse.
This seems to happen with the default brush settings of said presets.

NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

STEPS TO REPRODUCE
1. Select Pencil 2b (mypaint) or Ink Pen (mypaint) brush
2. Select Stabilizer smoothing mode with a minimum to medium Sample Count value
3. Try making round shapes like spirals or circles, using swift motions

OBSERVED RESULT
Resulting strokes look jagged and polygonal

EXPECTED RESULT
Smooth strokes like every other brush does under the same circumstances

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

ADDITIONAL INFORMATION
Using Wacom CTL-472, driver ver. 6.3.45-1
Comment 1 jesus 2021-12-27 06:04:21 UTC
Created attachment 144886 [details]
here's a screenshot of the affected brushes, strokes made with "stabilizer" mode, sample count 70
Comment 2 David REVOY 2021-12-27 08:20:18 UTC
Hi, I can't reproduce it on Kubuntu Linux 20.04 with the appimage of 5.0.0. I tried various stabilizer settings, high and low, and its ok. Same with various checkboxes. But I have a large tablet with many time more input and resolution than the Wacom one small you use (Wacom CTL-472), so the events sent by my device might fills the gap. Also, I have another driver obviously on this platform.

For background info: Mypaint brush engine already has its own method built-in for smoothing the brush stroke (named slow tracking, afair). And, to do so (smoothing/stabilizer) it requires to lag a little (in milliseconds, usually not that much perceptible) in order to get from the origin to the destination and then render the line smoothed in-between the two points.  Your bug might be a collision of this built-in smoothing/stabilizer with the Krita smoothing/stabilizer method on top. Especially if your operating system or driver report different timing, or tablet input for both method at same time?  Or maybe Mypaint engine require more coordinate? No idea, I'm not a dev, just a tester. 

But here is things you can try that might help adding details for the report:

1. Select the Pencil 2b (mypaint), go to the brush editor , and reduce "stroke duration log" to zero (be careful; the slider at minimum go to -1). Test. Report if you see improvements or degradation.

2. Try also with "Slow Tracking" (the built-in Mypaint stabilizer). Report if you see improvements or degradation.

3. Try the "Use Tablet Driver Stamps For Brush Speed" in the tablet settings in Krita. ( https://docs.krita.org/en/reference_manual/preferences/tablet_settings.html ) maybe this timestamp things can help about catching better driver input.
Comment 3 jesus 2021-12-27 08:47:38 UTC
hello, your suggestions 1 and 3 didn't seem to offer any noticeable changes, bad or good

however it looks like changing Slow Tracking to 0 in the affected brushes solves the problem.
i looked at the parameters you named and switched back and forth between the presets to see if there was a possible difference in values between them.
For example, "Pencil 1 sketch (mypaint)" had Slow Tracking 0 but "Pencil 2b (mypaint)" has Slow Tracking 1.03, so i matched it to the former preset's value of 0 and it works like i wanted now.
in other words, mypaint presets can make polygonal strokes by increasing Slow Tracking, being the culprit here.
do the reported brushes on your end come with Slow Tracking 0 *by default*?
Comment 4 David REVOY 2021-12-27 09:04:36 UTC
> Slow Tracking, being the culprit here. [...] value of 0 and it works like i wanted now

Good, this is a precious information for this report for sure. 👍 Thanks for testing.

> do the reported brushes on your end come with Slow Tracking 0 *by default*?

The stabilizer/smoothing of Mypaint is not global, but saved inside the preset − in each Mypaint's preset brushes. So, yes, I have similar observation than you:  "Pencil 1 sketch (mypaint)" had Slow Tracking 0 but "Pencil 2b (mypaint)" has Slow Tracking 1.03 by default.

I wonder if I should submit modified Mypaint presets for Krita 5.1 and turn Slow Tracking to 0 to workaround the issue (a sort of short term move). I'll try to ask this to the developpers later on IRC channel.
Comment 5 jesus 2021-12-27 11:31:08 UTC
glad to be of help!
there's one more little thing about this issue:
Ink Pen (mypaint) produces slight artifacts when reducing Slow Tracking to 0 and using Stabilizer, it looks like it tries to paint the little round spot it makes at the beginning of the stroke several times across the stroke, resulting in a bumpy line.
i'll update with a relevant attachment
Comment 6 jesus 2021-12-27 11:34:01 UTC
Created attachment 144889 [details]
Ink Pen (mypaint) stroke artifacts with Slow Tracking 0 and Stabilizer
Comment 7 David REVOY 2022-02-16 09:56:34 UTC
Hi Jesus, 

1. Slow Tracking/Polygonal line bug:
I'm working on the bug this morning. 
I'll push the modifications of reducing the Slow Tracking of c)_Pencil2b and d)_Ink_pen to 0.
It will fix the polygonal shapes when Mypaint engine is used in combination with Krita stabilizer.

2. Dot at line entry/repeated diameter with stabilisation/speed issue:
I tried to investigate this issue but I couldn't reproduce it. Maybe works have been done into the stabilizer and Speed inner clock system on Krita over the last monthes. I tried with Stabilizer, Delay, check/uncheck the "Stabilize sensor" too, and various strenght of stabilisation. I couldn't get the repetitive pattern here. If you still can reproduce it after the future Krita update, can you report it in a new bug report ticket? It will require to be assigned to a skilled developper and sounds really specific to 'Speed' and internal way to handle time in Krita. Maybe even related to the device/operating system. Thanks!
Comment 8 Dmitry Kazakov 2022-02-16 11:01:30 UTC
Git commit 40f4b41fad175fea3d5032fc8ff775f30063b161 by Dmitry Kazakov, on behalf of David Revoy.
Committed on 16/02/2022 at 11:00.
Pushed by dkazakov into branch 'master'.

Fix issue with Mypaint presets when Slow Tracking interacts with Stabilizer

If a user activate Krita Stabilizer (or other smoothing option) in combination
with the Mypaint presets that use 'Slow Tracking' (Mypaint's built-in smoothing/stabilizer),
the result is polygonal strokes. Removing 'Slow Tracking' (switching to 0) delegate fully
stabilisation to Krita via tool option and prevents the polygonal lines.

M  +1    -1    plugins/paintops/mypaint/brushes/c)_Pencil_2b_(mypaint).myb
M  +1    -1    plugins/paintops/mypaint/brushes/d)_Ink_pen_(mypaint).myb

https://invent.kde.org/graphics/krita/commit/40f4b41fad175fea3d5032fc8ff775f30063b161
Comment 9 Dmitry Kazakov 2022-02-16 11:03:21 UTC
Git commit 6c678eeef57d315e282967c13284445188c22f1f by Dmitry Kazakov, on behalf of David Revoy.
Committed on 16/02/2022 at 11:03.
Pushed by dkazakov into branch 'krita/5.0'.

Fix issue with Mypaint presets when Slow Tracking interacts with Stabilizer

If a user activate Krita Stabilizer (or other smoothing option) in combination
with the Mypaint presets that use 'Slow Tracking' (Mypaint's built-in smoothing/stabilizer),
the result is polygonal strokes. Removing 'Slow Tracking' (switching to 0) delegate fully
stabilisation to Krita via tool option and prevents the polygonal lines.

M  +1    -1    plugins/paintops/mypaint/brushes/c)_Pencil_2b_(mypaint).myb
M  +1    -1    plugins/paintops/mypaint/brushes/d)_Ink_pen_(mypaint).myb

https://invent.kde.org/graphics/krita/commit/6c678eeef57d315e282967c13284445188c22f1f