Bug 353204 - 32 bit float composite ops overflow: Layer Blending Mode Over Gradients result in strange patterns
Summary: 32 bit float composite ops overflow: Layer Blending Mode Over Gradients resul...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Color models (show other bugs)
Version: 2.9.7
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-26 07:25 UTC by romuluspb
Modified: 2020-08-28 21:16 UTC (History)
2 users (show)

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


Attachments
Image where pattern can be seen and tested, appears to be an overflow (2.87 MB, application/x-krita)
2015-09-26 07:27 UTC, romuluspb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description romuluspb 2015-09-26 07:25:48 UTC
Some blend modes appear to produce in some condition strange results in some gradients. It was tested with 32 float, but some cases where verified in 16 bits integer. 

A image was posted,  it will probably be quite visible with divide, or parallel or vivid Light, among others.

Reproducible: Always
Comment 1 romuluspb 2015-09-26 07:27:42 UTC
Created attachment 94722 [details]
Image where pattern can be seen and tested, appears to be an overflow
Comment 2 Dmitry Kazakov 2020-08-28 14:10:00 UTC
Yes, it looks like the gradients managed to generate negative colors...
Comment 3 Dmitry Kazakov 2020-08-28 19:17:50 UTC
Steps to reproduce:

1) Create a RGBAF32 image with g10 color profile
2) Create a gradient Red-Green-Blue
3) Draw this gradient
4) Convert to LabAF32
5) Convert back to RGBAF32

Now some of the pixels have negative values (near zero point).
Comment 4 Dmitry Kazakov 2020-08-28 21:14:39 UTC
Git commit e488caa31049bfff784f57fa79903df07e02aa1f by Dmitry Kazakov.
Committed on 28/08/2020 at 21:14.
Pushed by dkazakov into branch 'krita/4.3'.

Fix Divide, Vivid Light and Parallel blending modes handle negative layer colors

Sometimes, when converting RGBAF32<->LabAF32 colorspaces, LCMS may
generate pixels with "slightly negative" values, like -1e-7. The
mentioned blending modes couldn't handle that correclty, because
they only checked for zero'ness.

Now before doing a division operation we:

1) check if the value isn't too small
2) check it the value is positive

NOTE: there are still a lot of blendign modes from "Binary" section
      that still don't handle that correctly. But, speaking truly, I
      don't think we should actually enable these blending modes for
      F32 color spaces :)

M  +23   -0    libs/pigment/KoColorSpaceMaths.h
M  +11   -11   libs/pigment/compositeops/KoCompositeOpFunctions.h

https://invent.kde.org/graphics/krita/commit/e488caa31049bfff784f57fa79903df07e02aa1f
Comment 5 Dmitry Kazakov 2020-08-28 21:16:01 UTC
Git commit 8f4494412e5e791f1426bcc2f9d3dc73ed12d5e2 by Dmitry Kazakov.
Committed on 28/08/2020 at 21:15.
Pushed by dkazakov into branch 'master'.

Fix Divide, Vivid Light and Parallel blending modes handle negative layer colors

Sometimes, when converting RGBAF32<->LabAF32 colorspaces, LCMS may
generate pixels with "slightly negative" values, like -1e-7. The
mentioned blending modes couldn't handle that correclty, because
they only checked for zero'ness.

Now before doing a division operation we:

1) check if the value isn't too small
2) check it the value is positive

NOTE: there are still a lot of blendign modes from "Binary" section
      that still don't handle that correctly. But, speaking truly, I
      don't think we should actually enable these blending modes for
      F32 color spaces :)

M  +23   -0    libs/pigment/KoColorSpaceMaths.h
M  +11   -11   libs/pigment/compositeops/KoCompositeOpFunctions.h

https://invent.kde.org/graphics/krita/commit/8f4494412e5e791f1426bcc2f9d3dc73ed12d5e2