Skip to content

Comments

iop/basecurve: add ACES-like modes, JzAzBz saturation and gamut mapping#20320

Open
Christian-Bouhon wants to merge 10 commits intodarktable-org:masterfrom
Christian-Bouhon:basecurve_PR
Open

iop/basecurve: add ACES-like modes, JzAzBz saturation and gamut mapping#20320
Christian-Bouhon wants to merge 10 commits intodarktable-org:masterfrom
Christian-Bouhon:basecurve_PR

Conversation

@Christian-Bouhon
Copy link

This PR modernizes the basecurve module to improve its scene-referred capabilities while ensuring perfect backward compatibility for display-referred workflows.
Key Improvements
1. Scene-Referred Mode (ACES-like/Narkowicz):
◦ New Flow: Implements a perceptual tone mapping pipeline: Signal Analysis -> Matrix-based Looks -> Exposure Normalization -> Perceptual Tone Mapping -> RGB Reconstruction.
◦ Tone Mapping: Added ACES-like and Narkowicz perceptual models for better highlight roll-off and contrast control compared to standard curves.
◦ Looks: Added 3x3 RGB matrix-based "Looks" (Portrait, Sky, etc.) with a mix slider.
2. Color & Gamut Integrity:
◦ Perceptual Saturation (JzAzBz): Improved "UCS saturation balance" to compress highlight saturation while boosting shadows for better visual density.
◦ Hue Correction: New color rotation slider with selective desaturation to eliminate common color drifts (skin tones, blues).
◦ Gamut Securing: Introduced a multi-space gamut engine (sRGB, Adobe RGB, Rec2020) and a specific Anti-Magenta Algorithm (Highlights Protection): Implementation of a selective highlight desaturation logic. When luminance exceeds the threshold (0.8), the compression factor is biased to be 10% stronger on the blue channel compared to red and green.
◦ Goal: This specifically targets the common "magenta shift" in overexposed skies or artificial blue lights, ensuring they desaturate towards white rather than shifting hue.
3. Ergonomics & Compatibility:
◦ Backward Compatibility: Display-referenced processing (classic mode) remains untouched.
◦ UI: Curve graph can now be resized with the mouse.
◦ Introspection: Bumped to version 7.

jenshannoschwalm and others added 9 commits February 18, 2026 18:13
For readability and maintenance this returns a valid OpenCL error code instead of a gboolean.
Some error codes fixed.
As parameters for OpenCK kernels must be presented as 'pointer-to-value' we use
compound literals for readability.
- kernels called with the _args() variant
- a missing mem allocation check added
- using CLARGFLOAT
- deduplicated code for atomic floats to common.h
  preparation for better support also for modern devices instead of that workaround
- use _args() variants for kernel calls in bilateral
- constify in both related kernels
1. All non-local OpenCL kernel calls use _args() interface
2. new kernels as asked for by @ralfbrown (code does not work)
   - eaw_zero
   - eaw_addbuffers
1. All non-local OpenCL kernel calls now use the _args() variant
2. Deduplicated code for old/new variant (still using "old" code
3. Fixed some possible clmem-leaks if kernels would fail
As the tiling factor_cl for blendop might be less than the overall now we have to
mix properly.
This often avoids 1x1 OpenCL tiling in the pipe for blended modules.
As we need to use it0 (selected->data) later don't mess with it. We
do a copy before checking for first/last item.

Closes darktable-org#20290.
@Christian-Bouhon Christian-Bouhon changed the title iop/basecurve: modernization, JzAzBz saturation, and gamut protection iop/basecurve: add ACES-like modes, JzAzBz saturation and gamut mapping Feb 18, 2026
@Christian-Bouhon
Copy link
Author

I just saw that you've been working on the project. Sorry if my last push overwrote some of your maintenance fixes. I've finalised the implementation of the JzAzBz adaptive shoulder extension and CPU/GPU parity. The mathematical logic is now complete on my end.
Thanks for your help,
Christian

@Christian-Bouhon Christian-Bouhon marked this pull request as ready for review February 18, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants