darktable-org / darktable-org/darktable

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

Open
#21,022 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

no-issue-activity
Dominant language
C
Stars
13.1k
Forks
1.4k
Avg merge
22h 14m
Merged PRs (30d)
198

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposed implementation in src/iop/basecurve.c and review the linked Libre DT-lab discussion and experimental fork. Check how the module currently fits darktable's Introspection 7 and coding standards, then inspect the integration tests mentioned for CPU/GPU parity. The scope and acceptance criteria need maintainer agreement before implementation can begin.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.