Bug 420013

Summary: Blur Filters create artifacts that are revealed by splitting the alpha out
Product: [Applications] krita Reporter: Ahab Greybeard <ahab.greybeard>
Component: FiltersAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73, griffinvalley
Priority: NOR    
Version: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Debian stable   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Example image of artifacts

Description Ahab Greybeard 2020-04-13 08:38:55 UTC
Created attachment 127487 [details]
Example image of artifacts

SUMMARY
This happens for versions 4.2.0 onwards but does not happen in version 4.1.7.

If a simple painted shape has any blur filter applied then artifacts are created in the RGB content and these can be revealed by splitting the alpha out into a mask.

A .png file is attached (blur-artifacts-revealed.png) that shows an example.

Here is a .kra file with further examples for convenience of investigation:
https://www.dropbox.com/s/8ipsb35hsrgeet7/Sample-Blur-Artifacts.kra?dl=1
This was made using the 5.0.0 pre-alpha appimage 08-Apr git 78d1d45

STEPS TO REPRODUCE
1. On a new paint layer, paint a simple shape then apply any blur filter.
2. Do Layer - Split - Split Alpha Into Mask on that layer
3. Turn off the mask to reveal the artifacts.
4. Note that trying this with a filled rectangle of any size or aspect ratio does not give artifacts.
5. Note the 'tile' structure of the artifacts and that this is not 512 x 512 and seems to vary in size.
6. Note that varying the type of blur filter or the parameters of the blur filter does not make significant changes to the nature of the artifacts.
7. Having revealed the artifacts by alpha splitting, flatten the layer to combine the alpha with the image then reapply a split alpha into mask.
Note that the artifacts are now gone. (Rendered away by the flattening?).
8. After the blur filter is applied to a layer, turn off the background layer and export the layer as a .png with alpha preserved. Then open that .png file and split the alpha out to a mask.
Note that there are no artifacts.

OBSERVED RESULT
See Steps To reproduce

EXPECTED RESULT
No artifacts

SOFTWARE/OS VERSIONS

Krita

 Version: 5.0.0-prealpha (git 78d1d45)
 Languages: en_GB, en, en, en_GB, en
 Hidpi: true

Qt

  Version (compiled): 5.12.7
  Version (loaded): 5.12.7

OS Information

  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 4.19.0-8-amd64
  Pretty Productname: Debian GNU/Linux 10 (buster)
  Product Type: debian
  Product Version: 10
  Desktop: MATE

OpenGL Info
 
  Vendor:  "NVIDIA Corporation" 
  Renderer:  "GeForce GTX 750 Ti/PCIe/SSE2" 
  Version:  "4.6.0 NVIDIA 418.74" 
  Shading language:  "4.60 NVIDIA" 
  Requested format:  QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
  Current format:    QSurfaceFormat(version 4.6, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
     Version: 4.6
     Supports deprecated functions true 
     is OpenGL ES: false 

QPA OpenGL Detection Info 
  supportsDesktopGL: true 
  supportsOpenGLES: true 
  isQtPreferOpenGLES: false 

Hardware Information

  GPU Acceleration: auto
  Memory: 16039 Mb
  Number of Cores: 8
  Swap Location: /tmp

Current Settings

  Current Swap Location: /tmp
  Current Swap Location writable: true
  Undo Enabled: true
  Undo Stack Limit: 18
  Use OpenGL: true
  Use OpenGL Texture Buffer: true
  Use AMD Vectorization Workaround: false
  Canvas State: OPENGL_SUCCESS
  Autosave Interval: 60
  Use Backup Files: true
  Number of Backups Kept: 1
  Backup File Suffix: ~
  Backup Location: Same Folder as the File
  Backup Location writable: false
  Use Win8 Pointer Input: false
  Use RightMiddleTabletButton Workaround: false
  Levels of Detail Enabled: false
  Use Zip64: false


Display Information
Number of screens: 2
	Screen: 0
		Name: DVI-D-1
		Depth: 24
		Scale: 1
		Resolution in pixels: 1280x1024
		Manufacturer: Dell Inc.
		Model: DELL 1704FPV-
		Refresh Rate: 60
	Screen: 1
		Name: DVI-D-0
		Depth: 24
		Scale: 1
		Resolution in pixels: 1280x1024
		Manufacturer: Dell Inc.
		Model: DELL 1704FPV-
		Refresh Rate: 75
Comment 1 wolthera 2020-04-24 11:59:39 UTC
Indeed it does... I think what is going on is that those paintdevices aren't being initialized fully before anything is drawn on them.
Comment 2 Dmitry Kazakov 2020-08-28 11:34:18 UTC
Git commit fd0e0ff83d0c3b3d5e18de96d3c56a53544b6291 by Dmitry Kazakov.
Committed on 28/08/2020 at 11:13.
Pushed by dkazakov into branch 'krita/4.3'.

Fix artifacts when doing Split Alpha after Gaussian Blur filter

After applying gaussian we should not write color values into
the destination device if alpha channel is null. There had already
been such check, but it checked for null in 'double' space, not
in the space of the destination device (which is usually 'quint8')

M  +29   -7    libs/image/kis_convolution_worker_fft.h
M  +52   -0    libs/image/kis_math_toolbox.cpp
M  +2    -0    libs/image/kis_math_toolbox.h

https://invent.kde.org/graphics/krita/commit/fd0e0ff83d0c3b3d5e18de96d3c56a53544b6291
Comment 3 Dmitry Kazakov 2020-08-28 11:34:31 UTC
Git commit a3b71748b5c3a3ce57345568617e511598d6ea62 by Dmitry Kazakov.
Committed on 28/08/2020 at 11:34.
Pushed by dkazakov into branch 'master'.

Fix artifacts when doing Split Alpha after Gaussian Blur filter

After applying gaussian we should not write color values into
the destination device if alpha channel is null. There had already
been such check, but it checked for null in 'double' space, not
in the space of the destination device (which is usually 'quint8')

M  +29   -7    libs/image/kis_convolution_worker_fft.h
M  +52   -0    libs/image/kis_math_toolbox.cpp
M  +2    -0    libs/image/kis_math_toolbox.h

https://invent.kde.org/graphics/krita/commit/a3b71748b5c3a3ce57345568617e511598d6ea62