Skip to content

Adds high-precision compositing in overlay module - #21345

Merged
TurboGit merged 1 commit into
darktable-org:masterfrom
masterpiga:overlay_hq
Jul 22, 2026
Merged

Adds high-precision compositing in overlay module#21345
TurboGit merged 1 commit into
darktable-org:masterfrom
masterpiga:overlay_hq

Conversation

@masterpiga

@masterpiga masterpiga commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

The overlay module previously composited its overlay through an 8-bit Cairo path. The overlay image was rendered to a linear 8-bit buffer before blending, which posterized smooth gradients (visible banding in skies and
soft shadows); the in-module hint to "move after the output color profile" was only a workaround.

What changed

  • High-precision float path (default for new instances). The overlay is now rendered as scene-referred linear float in the working RGB space and composited in floating point — no quantization, no banding. dt_dev_image() gained a want_float argument; when set, gamma (which stays the terminal module) passes the 4-channel float straight through instead of packing 8-bit ARGB. A new two-stage float resampler (anti-aliased Lanczos minification + per-pixel bicubic placement) replaces Cairo for scaling/rotation. CPU and OpenCL paths included.
  • compositing algorithm selector at the top of the module:
    • high-precision (v1) — float compositing (16 B/px overlay cache).
    • legacy 8bit (v0) — the original Cairo path, reproduced faithfully (4 B/px cache) so edits made before this change render identically.
  • Backward compatibility. Introspection is bumped to v2; legacy_params() migrates every existing edit to legacy 8bit, so nothing changes appearance on upgrade. Only newly added overlays default to high-precision.

8 bit (left) vs high-precision (right)

image

Notes

  • The two modes differ in color space, not just precision (legacy blends display-encoded sRGB/BGRA bytes into the linear host buffer), so legacy needed the actual old code path, not a quantized cache.
  • The per-instance overlay cache tracks its format and re-renders when the mode is toggled.
  • legacy 8bit still posterizes on gradients — that is the faithfully reproduced old behavior, kept only for edit fidelity.

Co-authored with Claude.

@masterpiga masterpiga added this to the 5.8 milestone Jun 18, 2026
@masterpiga masterpiga added the scope: image processing correcting pixels label Jun 18, 2026
@masterpiga

Copy link
Copy Markdown
Collaborator Author

@TurboGit I have a couple more PRs ready, all about masks (as discussed on Pxls). Should I wait to send them out or do you prefer if I wait for the release? TIA!

@masterpiga masterpiga added the feature: new new features to add label Jun 18, 2026
@TurboGit

Copy link
Copy Markdown
Member

You can create the PR now. I'll tag them for 5.8 and review will start when I have time.

@masterpiga masterpiga added feature: enhancement current features to improve and removed feature: new new features to add labels Jun 21, 2026
Comment thread src/iop/overlay.c Outdated

@TurboGit TurboGit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks!

@TurboGit
TurboGit merged commit c2a7555 into darktable-org:master Jul 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants