Skip to content

RFC : Modernizing basecurve module with Scene-Referred workflow, Perceptual Spaces (Oklab/JzAzBz), and Gamut Mapping #21022

@Christian-Bouhon

Description

@Christian-Bouhon

Hi everyone,

Following a significant development phase within the "Libre DT-lab" experimental fork, I have finalized a major evolution of the basecurve module. I would like to propose these improvements for potential integration into darktable's master branch.

The development history is available on pixls.us.

Key Features (Scene-Referred Mode):

  • Curve Control:

    • Automatic calculation from embedded preview (2 modes), fine node editing via X/Y sliders, and a picker tool.
  • Tone Mapping Modes (UCS Integration):

    • Mode 1 (Kinematic): Narkowicz (2016) rational approximation of ACES RRT+ODT. Provides a high-contrast "S-curve" look.

    • Mode 2 (Dynamic): Stephen Hill / BakingLab rational approximation. High precision, preserves highlight clarity (ideal for architecture and HDR landscapes).

    • Mode 3 (Cinematic DRT): Inspired by Jed Smith's OpenDRT using Oklab space. This Uniform Color Space (UCS) ensures natural colors even under aggressive compression, providing smooth skin tones and preventing hue shifts (e.g., turquoise skies).

  • Color Look:

    • Optional 3x3 RGB matrices (Portrait, Nature, Blue Sky...) with an blend slider.
  • Exposure Fusion:

    • Re-implemented to work in a linear pipeline before the tone mapper.
  • Color & Gamut Management:

    • Saturation Boost & Balance: Operates pre-tonemapping. Modes 1 & 2 use JzAzBz for HDR precision, while Mode 3 uses Oklab for perceptual smoothness.

    • Highlight Hue/Sat: Corrects hue shifts (e.g., "salmon" sunsets) using a progressive Jz mask (0.20 to 0.90) with Az/Bz hue rotation.

    • Highlight Roll-off (Pre-tonemapping): Adaptive "shoulder" modulated in Jz space for seamless highlight transitions.

    • Gamut Management: Compression logic based on Jed Smith's work to ensure display-referred integrity.

  • Technical Stability: Full OpenCL support with bit-perfect parity (verified via integration tests) between CPU and GPU.

I intend to clean up the code to match Introspection 7 and darktable's coding standards.

Would the team be interested in a Pull Request for these features? I am available to discuss implementation details or provide a test build.
The code is available here and the module can be tested on my experimental fork. As you know, I’m using AI to help me, and implementing this code requires further adjustments to integrate it properly into both the display and the scene-referenced mode.

Greetings from the Luberon, 🌿
Christian Bouhon

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions