Bug 452172 - Blending mode doesn't work with transparency mask
Summary: Blending mode doesn't work with transparency mask
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (other bugs)
Version First Reported In: 5.0.2
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Lynx3d
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-02 10:44 UTC by killy
Modified: 2022-05-09 09:48 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description killy 2022-04-02 10:44:07 UTC
SUMMARY
***
When I choose a blending mode for the brush and paint on the transparency mask, the blending mode does not work correctly,and multiply is normal.
***


STEPS TO REPRODUCE
1. Create a new RGBA 8-bit depth document, add a layer, draw any content on the layer, and add a transparency mask for this layer
2. Choose the lighten blending mode for the brush and choose a color with a lower gray value to paint on the mask

OBSERVED RESULT
It is found that the content can still be painted on the mask, which is inconsistent with the effect of the lighten blending mode. The brush still works in the normal blending mode

EXPECTED RESULT
Blending modes that works in grayscale mode documents also works on transparency mask


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

ADDITIONAL INFORMATION
Comment 1 Ahab Greybeard 2022-04-02 11:28:38 UTC
This was first reported in the forum here:
https://krita-artists.org/t/help-blending-mode-doesnt-work-with-transparency-mask/39094

I've just looked at this with the Apr 01 5.1.0-prealpha nightly build.
Now, the warnings are shown for brush blending modes when a transparency mask is selected.

However, the brush still seems to paint in Normal mode.
(I get confused by blending modes.)

@killy - Please use the nightly build to see how it behaves for you.

Also, if I select Lighten and paint with that, it stays in Lighten mode while painting.
If I then select Darken, it switches to Normal and I have to select Darken again to get it to stay in Darken mode.

So, I'll set this to Confirmed because there is a bug here.
Comment 2 Lynx3d 2022-04-28 21:39:10 UTC
This is a tricky one...but I think I have a solution for using the proper the blending modes.

I still need to investigate the UI issues, it dropdowns clearly should mark unavailable modes, and also not randomly jump back to "Normal" although it will paint in the selected mode.
Comment 3 Lynx3d 2022-05-09 09:48:25 UTC
Git commit 85a75ea2768db0a51d239eb10a7d5dd3fee563b0 by Mathias Wein.
Committed on 09/05/2022 at 09:00.
Pushed by mwein into branch 'master'.

Correctly show available paint blending modes for masks

The combo-box in KisPaintopBox was using the paint device color space,
but in case of masks, composition happens in Grayscale/Alpha while the
paint device is plain Alpha.

M  +16   -6    libs/ui/kis_paintop_box.cc
M  +1    -1    libs/ui/kis_paintop_box.h

https://invent.kde.org/graphics/krita/commit/85a75ea2768db0a51d239eb10a7d5dd3fee563b0
Comment 4 Lynx3d 2022-05-09 09:48:33 UTC
Git commit 73d5958e94517a98f7bc4a91882d94d99d892617 by Mathias Wein.
Committed on 09/05/2022 at 09:00.
Pushed by mwein into branch 'master'.

Fix painting on selection masks with various blending modes

The issue was that KoColorSpace::bitBlt() only accepted composite ops from
its own color space, while at the same time allowing KoAlphaColorSpace to
blit in a differing source color space and substituting the composite op
accordingly, specifically to allow painting.

Since we cannot acquire most composite ops from KoAlphaColorSpace, some
restructuring was necessary:

- KoColorSpace::compositeOp() and ::hasCompositeOp() now take an optional
  destination color space to acquire the desired composite op
- KoColorSpace::bitBlt() accepts composite ops from source color space
  if it's going to work in source color space; this also avoids the lookup
  for substitution on each call
- KisPainter delays fetching the composite op until the source color space
  is known and caches the result
- change KisPainter::compositeOp() to compositeOpId() since we can no
  longer return an actual composite op
- since recompile time can't get any worse, take care of the TODO and
  rename KisPainter::setCompositeOp() to setCompositeOpId() and cleanup
  many places that were fetching a composite op beforehand

M  +2    -2    benchmarks/kis_filter_selections_benchmark.cpp
M  +3    -3    benchmarks/kis_floodfill_benchmark.cpp
M  +1    -1    benchmarks/kis_gradient_benchmark.cpp
M  +1    -1    benchmarks/kis_painter_benchmark.cpp
M  +1    -1    libs/brush/tests/kis_auto_brush_test.cpp
M  +1    -1    libs/brush/tests/kis_imagepipe_brush_test.cpp
M  +1    -1    libs/image/kis_fill_painter.cc
M  +1    -1    libs/image/kis_indirect_painting_support.cpp
M  +1    -1    libs/image/kis_layer_projection_plane.cpp
M  +1    -1    libs/image/kis_onion_skin_compositor.cpp
M  +1    -1    libs/image/kis_paint_layer.cc
M  +47   -26   libs/image/kis_painter.cc
M  +9    -5    libs/image/kis_painter.h
M  +2    -2    libs/image/kis_painter_blt_multi_fixed.cpp
M  +5    -1    libs/image/kis_painter_p.h
M  +1    -1    libs/image/kis_perspectivetransform_worker.cpp
M  +1    -1    libs/image/layerstyles/KisLayerStyleKnockoutBlower.cpp
M  +2    -2    libs/image/layerstyles/kis_ls_bevel_emboss_filter.cpp
M  +1    -1    libs/image/layerstyles/kis_ls_drop_shadow_filter.cpp
M  +2    -2    libs/image/layerstyles/kis_ls_stroke_filter.cpp
M  +3    -3    libs/image/layerstyles/kis_ls_utils.cpp
M  +1    -1    libs/image/layerstyles/kis_multiple_projection.cpp
M  +1    -1    libs/image/lazybrush/kis_colorize_mask.cpp
M  +1    -1    libs/image/tests/kis_gradient_painter_test.cpp
M  +3    -3    libs/image/tests/kis_layer_style_projection_plane_test.cpp
M  +5    -5    libs/image/tests/kis_painter_test.cpp
M  +16   -6    libs/pigment/KoColorSpace.cpp
M  +14   -3    libs/pigment/KoColorSpace.h
M  +2    -2    libs/ui/tool/kis_resources_snapshot.cpp
M  +1    -1    libs/ui/tool/strokes/kis_painter_based_stroke_strategy.cpp
M  +1    -1    plugins/extensions/qmic/kis_qmic_import_tools.h
M  +1    -1    plugins/extensions/waveletdecompose/waveletdecompose.cpp
M  +1    -1    plugins/filters/gaussianhighpass/gaussianhighpass_filter.cpp
M  +3    -3    plugins/filters/halftone/KisHalftoneFilter.cpp
M  +1    -1    plugins/filters/smalltilesfilter/kis_small_tiles_filter.cpp
M  +1    -1    plugins/generators/gradient/KisGradientGenerator.cpp
M  +2    -2    plugins/generators/screentone/KisScreentoneGenerator.cpp
M  +3    -3    plugins/paintops/colorsmudge/KisColorSmudgeStrategyLightness.cpp
M  +3    -3    plugins/paintops/colorsmudge/KisColorSmudgeStrategyWithOverlay.cpp
M  +1    -1    plugins/paintops/defaultpaintops/duplicate/kis_duplicateop.cpp
M  +2    -2    plugins/paintops/experiment/kis_experiment_paintop.cpp
M  +1    -1    plugins/paintops/filterop/kis_filterop.cpp
M  +3    -3    plugins/paintops/libpaintop/kis_texture_option.cpp
M  +2    -2    plugins/paintops/mypaint/MyPaintPaintOp.cpp
M  +3    -3    plugins/paintops/mypaint/MyPaintSurface.cpp
M  +2    -2    plugins/paintops/tangentnormal/kis_tangent_normal_paintop.cpp

https://invent.kde.org/graphics/krita/commit/73d5958e94517a98f7bc4a91882d94d99d892617