Bug 320651 - Brush Engine has Artifacts [3 BIG BUGS].
Summary: Brush Engine has Artifacts [3 BIG BUGS].
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Brush engines (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-03 07:43 UTC by Paul Geraskin
Modified: 2013-09-25 19:32 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Geraskin 2013-06-03 07:43:44 UTC
Hi all.

I found 2 big bugs with the brush engine. 

1) Pixel Brush has artifacts with pressure. They are seen when i release the pen preassure (make presure less). 
Explanation: http://i.imgur.com/jxprwJD.png
This happens especially with default soft brush(named "Basic_tip_soft") with Spacing=14.

2) If i make Colored pixel Brush (Custom or Clipboard) i'll get some strange artifacts.
See my screenshot: https://dl.dropboxusercontent.com/u/26887202/blender/brush_color_artifacts.png
Brush Parameters: http://i.imgur.com/hDfjewO.png
Source file: https://dl.dropboxusercontent.com/u/26887202/blender/brush_rotation_bug.kra
Artifacts also appears when I release pen pressure or make pressure less.

Thank you.

PS. Check this bug too: https://bugs.kde.org/show_bug.cgi?id=320368
Comment 1 Paul Geraskin 2013-06-03 07:58:50 UTC
These bugs becomes because of "Wash" painting mode. 
"Build-Up" painting mode has no artifacts. 
Screen by DmitryK: http://i.imgur.com/m5IgS8j.png
Comment 2 vanyossi 2013-06-04 01:11:08 UTC
Hi mifth, thanks for the report.

I can confirm the behavior on number 1), the brush seems to have a different spacing exiting the stroke as the one set. On the other hand, with some effort the dabs can be done also in the entry stroke. Lowering the spacing makes the defect disappear. It probably is a bug as the difference between the entry stroke and the exit one are quite different.

The second one I can fully confirm as suggested. Also, turning on rotation for clip brush produces a deep shadow around the brush tip.

To get the artifacts on color brush tip set a low saturated color as the example provided in the bug report.
Comment 3 Paul Geraskin 2013-06-04 10:34:54 UTC
THE THIRD BUG IS HERE:

Another issue is found with Build-Up Mode. If i draw with a smooth brush i get artifacts if layer has alpha>0.

EXPLANATION:
http://i.imgur.com/MFHKGaF.png
http://i.imgur.com/KvhsspK.png
Source file for testing: https://dl.dropboxusercontent.com/u/26887202/blender/build-up_issue.psd
Comment 4 Halla Rempt 2013-06-10 07:58:04 UTC
Confirmed since Vanyossie confirmed the bug.
Comment 5 Dmitry Kazakov 2013-06-29 08:11:42 UTC
Git commit 166ea4cb56baf4a5068912dc1567963dcab7a4cb by Dmitry Kazakov.
Committed on 29/06/2013 at 08:10.
Pushed by dkazakov into branch 'krita-testing-kazakov'.

Fixed a pressure bug in Wash-mode of painting

When the pressure drops, the opacity drops as well. In this moment, to
avoid the artifacts while painting the ALPHA_DARKEN op should work in a
reversed way. That is the contents of the layer should be painted on the
top of the brush dab. To allow this, we now keep the average value of the
opacity of several last dabs to be able to reverse the composite op.

This is tested to work best with spacings 0.1-0.2. With other spacing
values, probably, one needs to correct exponent value in
ParameterInfo::updateOpacityAndAverage().

M  +52   -6    krita/benchmarks/kis_composition_benchmark.cpp
M  +6    -1    krita/benchmarks/kis_composition_benchmark.h
M  +6    -2    krita/image/kis_painter.cc
M  +7    -0    krita/image/kis_painter.h
M  +2    -2    krita/plugins/paintops/libpaintop/kis_pressure_flow_opacity_option.cpp
M  +1    -1    krita/plugins/paintops/libpaintop/kis_pressure_opacity_option.cpp
M  +13   -0    libs/pigment/KoCompositeOp.cpp
M  +12   -1    libs/pigment/KoCompositeOp.h
M  +18   -3    libs/pigment/compositeops/KoCompositeOpAlphaDarken.h
M  +71   -24   libs/pigment/compositeops/KoOptimizedCompositeOpAlphaDarken32.h
M  +13   -7    libs/pigment/compositeops/KoOptimizedCompositeOpOver32.h
M  +7    -5    libs/pigment/compositeops/KoStreamedMath.h

http://commits.kde.org/calligra/166ea4cb56baf4a5068912dc1567963dcab7a4cb
Comment 6 Dmitry Kazakov 2013-07-16 11:00:56 UTC
Git commit b9d749eb4e7c6bbc00332c9d1c090c9a2293af74 by Dmitry Kazakov.
Committed on 16/07/2013 at 10:43.
Pushed by dkazakov into branch 'master'.

A significant refactoring in the Predefined Brush engine

This patch ports the predefined brush engine to the new capabilities
of Qt. It removes a huge chunk of hand-written code. Here is a short list
of changes:

1) All the operations are now performed on non-premultiplied RGB values.
   The use of premultiplication resulted in instability of the color,
   which caused artifacts on scaling and rotation of the brushes.

2) Trilinear filtering of the brushes is now substituted with simple
   bilinear filtering from the nearest pyramid level.

   It turned out that trilinear filtering not only impacted the
   performance, but also introduced heavy aliasing artifacts on specific
   zoom levels.

3) After the patch the speed of the dab generation raised 3-5 times. Here
   are the values for 512px brush:
   Before patch:
      Scaling:   34 ms
      Rotation:  19 ms
   After patch:
      Scaling:   6 ms
      Rotation:  9 ms
Related: bug 320368, bug 319944, bug 300665
CCMAIL:kimageshop@kde.org

M  +1    -2    krita/plugins/paintops/libbrush/CMakeLists.txt
M  +0    -1    krita/plugins/paintops/libbrush/kis_abr_brush.cpp
M  +1    -1    krita/plugins/paintops/libbrush/kis_auto_brush.cpp
M  +70   -778  krita/plugins/paintops/libbrush/kis_brush.cpp
M  +3    -26   krita/plugins/paintops/libbrush/kis_brush.h
M  +2    -3    krita/plugins/paintops/libbrush/kis_gbr_brush.cpp
D  +0    -135  krita/plugins/paintops/libbrush/kis_qimage_mask.cpp
D  +0    -138  krita/plugins/paintops/libbrush/kis_qimage_mask.h
A  +196  -0    krita/plugins/paintops/libbrush/kis_qimage_pyramid.cpp     [License: GPL (v2+)]
A  +52   -0    krita/plugins/paintops/libbrush/kis_qimage_pyramid.h     [License: GPL (v2+)]
D  +0    -64   krita/plugins/paintops/libbrush/kis_scaled_brush.cpp
D  +0    -62   krita/plugins/paintops/libbrush/kis_scaled_brush.h
A  +-    --    krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_0_sc_0.871853_rot_3.55731_sub_0.137199.png
A  +-    --    krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_1_sc_0.861342_rot_3.45867_sub_0.20933.png
A  +-    --    krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_2_sc_1.80941_rot_4.97706_sub_0.113862.png
A  +-    --    krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_3_sc_0.46124_rot_4.18791_sub_0.167627.png
A  +-    --    krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_4_sc_0.963137_rot_2.82314_sub_0.444059.png
A  +-    --    krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_5_sc_0.592981_rot_0.439579_sub_0.45074.png
A  +-    --    krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_6_sc_1.86775_rot_3.12606_sub_0.365777.png
A  +-    --    krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_7_sc_1.13937_rot_3.47854_sub_0.458733.png
A  +-    --    krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_8_sc_1.53198_rot_3.68719_sub_0.410264.png
A  +-    --    krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_9_sc_1.46566_rot_2.88023_sub_0.474873.png
M  +-    --    krita/plugins/paintops/libbrush/tests/data/result_autobrush_3.png
M  +-    --    krita/plugins/paintops/libbrush/tests/data/result_autobrush_4.png
A  +-    --    krita/plugins/paintops/libbrush/tests/data/testing_brush_512_bars.gbr
M  +24   -28   krita/plugins/paintops/libbrush/tests/kis_auto_brush_test.cpp
M  +91   -17   krita/plugins/paintops/libbrush/tests/kis_brush_test.cpp
M  +7    -2    krita/plugins/paintops/libbrush/tests/kis_brush_test.h
M  +5    -4    krita/plugins/paintops/libbrush/tests/kis_imagepipe_brush_test.cpp

http://commits.kde.org/calligra/b9d749eb4e7c6bbc00332c9d1c090c9a2293af74
Comment 7 Paul Geraskin 2013-07-17 14:40:20 UTC
Hi Dmitry!
It seems you did not push the fix with alpha multiply. There is no the fix in latest update.
http://i.imgur.com/UUAbx4P.png 
I'm on master.
But your fix was about 2 days ago. Possibly something was merged incorrectly? 

Thanks.
Comment 8 Paul Geraskin 2013-07-17 14:41:12 UTC
But your fix was in master about 2 days ago*
Comment 9 Dmitry Kazakov 2013-07-17 20:58:21 UTC
Yes, the fix was reverted due to the bug 321935 introduced by it. Now the patch is store in krita-testing-kazakov until I fix this regression.
Comment 10 Dmitry Kazakov 2013-09-25 19:32:37 UTC
Git commit c42aa8266818d05a6af24c7194d8e4bf53172e3f by Dmitry Kazakov.
Committed on 25/09/2013 at 19:32.
Pushed by dkazakov into branch 'krita-testing-kazakov'.

The copy-constructor should be implemented for structures having pointers
Related: bug 321935

M  +25   -0    libs/pigment/KoCompositeOp.cpp
M  +5    -6    libs/pigment/KoCompositeOp.h

http://commits.kde.org/calligra/c42aa8266818d05a6af24c7194d8e4bf53172e3f