Bug 444267

Summary: Merging three layers with each own RGB channel separately turned on gives different result.
Product: [Applications] krita Reporter: healer.harie
Component: Layer StackAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: halla, paul
Priority: NOR    
Version First Reported In: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: result

Description healer.harie 2021-10-23 11:52:05 UTC
Created attachment 142789 [details]
result

SUMMARY

For three layers, if you turn only the red on layer 1, green on layer 2
and blue on layer 3, translate it and merge it, the resulting color is
different.

STEPS TO REPRODUCE
1. Pick color black and draw a circle with black filled inside.
2. Create 2 duplicates and only turn on each RGB channel on each
separate layers. (right click layer -> properties).
3. Translate each layer to form what's in the attachment.
4. Click all three layers and merge with layer below.

OBSERVED RESULT
The layers merge into black.

EXPECTED RESULT
Layers merge into what is seen.

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

ADDITIONAL INFORMATION
Krita

 Version: 5.0.0-beta2 (git fa4ad10)
 Languages: en_US, en
 Hidpi: false

Qt

  Version (compiled): 5.12.11
  Version (loaded): 5.12.11

OS Information

  Build ABI: x86_64-little_endian-llp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: winnt
  Kernel Version: 10.0.15063
  Pretty Productname: Windows 10 (10.0)
  Product Type: windows
  Product Version: 10

OpenGL Info
 
  Vendor:  "Google Inc." 
  Renderer:  "ANGLE (Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0)" 
  Version:  "OpenGL ES 3.0 (ANGLE 2.1.0.57ea533f79a7)" 
  Shading language:  "OpenGL ES GLSL ES 3.00 (ANGLE 2.1.0.57ea533f79a7)" 
  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 3.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::DefaultSwapBehavior, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile) 
     Version: 3.0
     Supports deprecated functions false 
     is OpenGL ES: true 
  supportsBufferMapping: true 
  supportsBufferInvalidation: false 

QPA OpenGL Detection Info 
  supportsDesktopGL: true 
  supportsAngleD3D11: true 
  isQtPreferAngle: true 

useBufferInvalidation (config option): false


Hardware Information

  GPU Acceleration: auto
  Memory: 1946 Mb
  Number of Cores: 4
  Swap Location: C:/Users/User6/AppData/Local/Temp

Current Settings

  Current Swap Location: C:/Users/User6/AppData/Local/Temp
  Current Swap Location writable: true
  Undo Enabled: true
  Undo Stack Limit: 30
  Use OpenGL: true
  Use OpenGL Texture Buffer: true
  Disable Vector Optimizations: false
  Disable AVX Optimizations: false
  Canvas State: OPENGL_SUCCESS
  Autosave Interval: 900
  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: 1
	Screen: 0
		Name: \\.\DISPLAY1
		Depth: 32
		Scale: 1
		Resolution in pixels: 1280x800
		Manufacturer: 
		Model: 
		Refresh Rate: 60
Comment 1 healer.harie 2021-10-23 12:03:10 UTC
I was trying to induce chromatic aberration and I ended up discovering this
behaviour. And I'm not sure if this is a bug or a feature.
Comment 2 Paul 2021-12-12 14:20:30 UTC
I was noodling around with this bug and I think I have some additional detail. I was messing with 5.0.0-beta5 (git 91daced) and 4.4.8 using macOS 12.0.1 (intel). The both behaved the same for me.

* If you "Flatten image" the colors don't change to black. The image looks like it did before you flattened it. But the Background must be a solid color (like white) and be included in the merge. The resulting layer has all channels toggled on.
* If you "Merge with Layer Below" and the Background is the bottom layer, the colors of the resulting layer don't change. The resulting layer has all channels toggled on.
* If you merge two layers that have the same combination of RGB channels toggled, it looks as expected. The resulting layer also has those specific channels toggled.
* The behavior being described seems to happen when you "Merge with Layer Below" and the layer below has one or more RGB channels toggled. The resulting layer has all channels toggled on.
* If you toggle the visibility of the "Background" layer the image turns to black (like the reporter is describing and the included images show).
Comment 3 Halla Rempt 2022-06-28 12:56:17 UTC
This is actually to be expected. If you merge a layer down on another layer, we merge the color data, not the projection of the layer. If you flatten the image, by contrast, the projection of the layer stack is taken. I'm not sure we should be trying to change this...