iop/basecurve: add ACES-like modes, JzAzBz saturation and gamut mapping#20320
iop/basecurve: add ACES-like modes, JzAzBz saturation and gamut mapping#20320Christian-Bouhon wants to merge 7 commits intodarktable-org:masterfrom
Conversation
dbc808d to
4a6dfb5
Compare
|
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. |
|
Thank you for this detailed analysis! I have taken note of all your comments regarding coding style (alignment, one parameter per line, and spaces). I will work on the code this weekend to apply all these corrections and publish the updates. |
TurboGit
left a comment
There was a problem hiding this comment.
I have finally tested this a bit, some comments:
- I have on the console a bunch of :
34,4786 /home/obry/dev/builds/c-darktable/x86_64-linux-gnu-default/src/src/iop/basecurve.c:3000 gui_init: trying to add widget that already has a parent to box (#1)
-
When I change the "color look" it resets to 100% the "look opacity".
-
I'm wondering if the target gamut should not be Rec 2020 by default?
|
Also this PR introduces a regression on the The new report is: So 44885 different pixels in CPU compared to GPU instead of 9772. |
I finally found a typo. In color_conversion.h, we have this matrix: // XYZ to Rec.2020 conversion matrix coefficients and a small error in the basecurve.c file |
Hello, Regarding the name without capital letters, I noticed that this was not applied in French. I adapt the fr.po file and create a new pr or link it to this one. |
|
After updating my CM_BC work branch from the master branch, as mentioned in the commit, I had to replace these two lines in basecurve.c: |
This sounds really wrong to me. We don't do that in any other sliders. If the user needs this it must be done manually, because some other people may be quite annoyed by having to go back to the control for reset to the previously set value. |
Yes, see 4e6d1b8. See that only
|
As parameters for OpenCK kernels must be presented as 'pointer-to-value' we use compound literals for readability.
d9f8555 to
bed486a
Compare
bed486a to
ac32cab
Compare
|
A very quick test with some thoughts I'd get rid of the kinematics in the names and just use ACES and the other It would be nice to set a curve in ACES and then switch to the other without the curve resetting so that you can compare the difference. Do we need a basecurve scene referred workflow? Should that be included in this PR? Does scene referred basecurve need a tone mapper at the end of the pipe? I think yes because being scene referred the edits can drive the image out of the 0 - 1 range, but maybe not enabled by default? The following error messages repeat when I open/change image |
There was a problem hiding this comment.
Hello,
Thank you for your feedback!
I have removed src/views/view.c from the PR, it was included by mistake. Sorry about that!
I worked on this project over the weekend to correct all the comments I received, and today I ran tests to check that everything is OK. I will do more tomorrow or later this week. You can see the results on my work branch, BC_CM. I also compiled this branch with the official script adapted to my branch to check that everything works at this level. https://github.com/Christian-Bouhon/darktable/actions/runs/22862606858#artifacts
I have a question before updating the PR. Besides the core files (basecurve.c, basecurve.cl, color_conversion.h), I also modified a few other files to make the scene-referred workflow work properly:
- develop.c and presets.c — to allow basecurve auto-apply presets in scene-referred
- utility.c — to add the new workflow mode to darktable's workflow detection
- modulegroups.c — to show basecurve parameters in the quick access panel
- darktableconfig.xml.in — to add the new entry in the preferences
Would it be better to include everything in this PR, or would you prefer two separate PRs?
I am still learning, so any advice is welcome. Thank you!
Salutations du Lubéron,
Christian
TurboGit
left a comment
There was a problem hiding this comment.
You still have a huge amount of error on the console:
10,9565 /home/obry/dev/builds/c-darktable/x86_64-linux-gnu-default/src/src/iop/basecurve.c:2998 gui_init: trying to add widget that already has a parent to box (#1)
10,9565 /home/obry/dev/builds/c-darktable/x86_64-linux-gnu-default/src/src/iop/basecurve.c:3012 gui_init: trying to add widget that already has a parent to box (#1)
It looks like you are trying to add a widgets two times. Maybe the box containing the widget and the box itself? (just a wild guess as I haven't looked at the code yet).
And you still are setting "look opacity" to 100% when change "color look". This is not consistent with current UI.
I don't see why and your example about blending is exactly the point. When you change the blend mode the opacity is not changed. Again this is not OK and not consistent, I'd prefer to have the "look opacity" to keep it's value and that is the user responsibility to change it if needed. |
So, if I understand correctly, you want this layout, for example.
|
Yes exactly that. Sorry if it was not clear. |


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.