Repository navigation
LR-EDIT-LIGHT-HIGHLIGHTS: keep local contrast under Highlights and Shadows - #645
Conversation
|
Supporting data for this, from my Lightroom 9.5.1 measurements on Sony A7CR raws (exports only, exploratory), with one caveat on how far to take it:
So #645 moves in the right direction: not flattening is the necessary first step. Matching Lightroom on unclipped frames with dark surroundings would eventually mean adding detail, not just keeping it. That's a separate, measured step for later. |
|
Thank you @radialmonster! The median before the guided filter fixes #632/#634 nicely, the CPU and GPU medians match exactly, and the measurements are convincing. It changes how every existing edit with Highlights or Shadows renders, so under the process-version rule from #533 (now on main) it needs to ship as part of One trap: the PR sets Please join our Discord if you haven't already: https://discord.gg/artcraft |
f5fd63f to
d4e3ebc
Compare
|
@echelon thanks for the review. It's rebased onto main and reworked as
Details are in the updated description. |
|
Tried this on 1917 Sony ILCE-7RM4 photos from a Lightroom catalog ( |
|
Note: these numbers are from the revision before the |
…s, as process V2 (storytold#632) The highlights/shadows base (fast guided filter of log luminance, eps 0.35) followed thin high-contrast detail, so the per-pixel shift flattened twigs, lines and texture in bright areas (and dark ones under Shadows); Exposure kept them. This changes how every existing edit with Highlights or Shadows renders, so it ships as a new rendering process (docs/process-versions.md): - Process::V2 (version 2) is added and made LATEST. New photos and Reset get it; existing edits stay on V1 until Update to Current Process. Settings saved without the field still load as V1. - From V2 the base is the same guided filter of a separable median of log luminance (radius 0.15 % of the long edge, <= 24 px): fine detail takes its surroundings' shift and keeps its contrast, region steps stay put (no new halos). V1's base is untouched: local::tone_base_detail is 0 under V1 and tone_base then is exactly guided_fast(l, sigma, BASE_EPS), as before. - CPU (local::prepare) and GPU prepare (median_h / median_v kernels, bit for bit with the CPU median) both branch on it via PlaneSigmas::base_detail. - The base plane's cache key is now (sigma, process, median radius) (local::BaseKey), so a warm cache never serves one process the other's base. plane_at is shared with the GPU crate. - finish::base_tone: V2 uses V1's tone map. Tests: V2 keeps twig/local contrast (>= 0.9 of Exposure's) with no halo; V1 plane sigmas have no median and its base equals guided_fast bit for bit; V1 and V2 render alike without Highlights/Shadows; warm-cache renders across V1/V2 switches equal fresh ones (fails if the key drops the process); GPU matches CPU on both processes at 720 and 2400 px, cached and not. Pentax 645D 2401 at 4000 px: main and V1 renders bit-identical (plain, Highlights -100, Shadows +100). Highlights -100 bright rel. detail 0.095 (V1) -> 0.147 (V2), Exposure -1: 0.124; Shadows +100 dark rel. detail 0.126 -> 0.148. RENDER_CACHE_VERSION 54 (adjust at merge).
d4e3ebc to
70103a7
Compare
|
Rebased onto main (b70ae17) to clear the conflicts. They were only |
The tone work from storytold#146/storytold#196 changes how every existing raw edit renders, so it goes behind a process version (docs/process-versions.md): V2 is the measured rendering and LATEST; V1 keeps the pre-branch rendering exactly. - Process::V2 added, LATEST; ALL is [V1, V2]. V2 is shared with the Highlights/Shadows base (storytold#645) and the sharpening (storytold#762) landing in the same batch, so a photo that updates to V2 gets the whole measured look at once. - finish::base_tone: V1's arm calls tone::ToneMap::{camera_v1, hdr_v1}, the old model restored verbatim (neutral base curve, extended-Reinhard shoulder, Blacks as the curve's toe, Whites as a display-domain lift); V2's arm is the measured model. A display-referred source uses display_hdr in both. - FinishParams::blacks is Blacks::IDENTITY for V1, and the per-photo Whites statistic is measured only for V2 (Process::is_measured_tone) -- V1 pays for neither. - RENDER_CACHE_VERSION 48 -> 49. - docs: process-versions.md describes V1/V2 and records that the V2 constants are fitted to the reference developer's observed output only (its rendered images; no bundle, profile, preset or Adobe asset); parity.md, ROADMAP.md and gpu-pipeline.md name V2 / F_PER_CHANNEL. Tests: v2_is_not_v1 pins the default curve apart; the v1_* golden tests pin the frozen model; stored_process_numbers_render_with_a_known_process now asserts the two arms render a raw differently and a rendered source alike. cargo xtask ci: all 8 steps green (fmt, clippy, heif, test, parity, layers, assets, wasm).
Takes the branch onto the 346 commits main landed since b70ae17, including its own Process::V2 (storytold#632: Highlights and Shadows keep the local contrast of the tones they move) and the progress-doc restructure (parity.md -> parity-checklist.md, "Where we stand" -> target-app-parity.md, milestones and risks -> roadmap.md). Resolutions: - Process: main's V2 and this branch's measured tone model share one V2, as agreed with the Highlights/Shadows (storytold#645) and sharpening (storytold#762) work. The Process::V2 doc comment and docs/process-versions.md say so. - finish::base_tone keeps V1 frozen (main's tone map) and gives V2 the measured model, now HDR-aware on the camera path too (ToneMap::camera_scaled_hdr), so an HDR render keeps the file's camera look. Process::is_measured_tone gates the Blacks curve and the per-photo Whites statistic; local::tone_base_detail gates storytold#632's median base. - The camera-look fitter keeps scoring its candidates with the frozen V1 tone map (ToneMap::{camera_v1, hdr_v1}). The model a fit is scored with decides which files accept a look -- the source stage, which the process version does not reach; the fit's own test (a_black_and_white_jpeg_gives_its_tone_curve) asserts the default curve is darker, which V2's measured curve is not. - crates/pipeline/src/spots.rs: chunks_exact(3) -> as_chunks::<3>() for the clippy lint rustc 1.98 added (main's new line; the local gate is -D warnings). - RENDER_CACHE_VERSION 60 -> 61 (the branch's look changes on top of main). - Docs merged: parity-checklist.md (the five Light rows, the storytold#632 note on Highlights/Shadows, LR-PROF-CAMERACOLOR and LR-BEHAV-RENDER-FIDELITY), process-versions.md (V1/V2 as one batch), roadmap.md (Look parity bullet), gaps.md (gap 3 is no longer "render fidelity unmeasured"). cargo xtask ci: all 8 steps green (fmt, clippy, heif, test, parity, layers, assets, wasm).
…t's single-slider responses against Lightroom exports A shareable render-fidelity measurement for gap 3 (docs/render-fidelity.md). It compares a user's own Lightroom TIFF exports with LightCraft renders of the same recipes from the same raws. It reads no Adobe application file, profile, preset or table, keeps only the names of an export's profile and look, and the Lightroom presets it writes are generated from the recipe values. It needs numpy and tifffile (tools/requirements-render-fidelity.txt) and the standard library. - plan: Lightroom develop presets for Basic-slider recipes (default: the Neutral and every Basic slider at two amounts) and export instructions: one export operation into one new folder per session, 16-bit sRGB TIFF, All Metadata. - pair: reads each export's embedded XMP and checks the clean recipe affirmatively (the settings the measurement depends on stated, everything else neutral, identity curves, Adobe Standard / Adobe Color, no crop or local edits). Finds the raw by crs:RawFileName and identifies photos by the raw's sha256; refuses a raw whose own XMP, read where LightCraft's reader reads it, carries develop settings. Pairs each single-slider export with a Neutral, else the same slider's smallest other amount, from the same session (export folder and time segment) and size. Photos split into tune and check by hash. - render: measures a private copy of the given lightcraft-cli. Each raw is first checked with LightCraft's own importer (run --import, develop.get, develop.reset, develop.get: any changed field refuses it). Renders the Basic panel from the export's XMP with sharpening, noise reduction and lens-profile corrections off, from a sidecar-free symlink, 16-bit sRGB at the export's long edge, registers every reference export by a consensus shift search and samples both engines on a grid. Every sample and registration carries its provenance (the run's binding id, CLI and tool hashes, the raw, the recipe or export, frame and shift); a run-folder lock, exclusive manifest creation and identity checks before each write keep concurrent renders apart. CLI calls have time limits; any failure is recorded for its photo and retried on resume. - score: per band of Lightroom's reference luminance, LightCraft's share of Lightroom's log-luminance response, the signed bias, the per-position error, CIE76 dE, the colour-change error, clipping and black transitions both ways, support retention and out-of-support errors, with contributor counts, tune and check apart. A pair is scored only when its raw passed the importer check, its samples' and registration's provenance matches the manifest and the pair, and its two Lightroom exports are framed alike; every other pair is listed with its reason. - report: a Markdown summary to paste into an issue: numbers only, photos under per-run salted labels, and a CSV appendix of every band and transition. - selftest: the XMP, clean-recipe and pairing rules, registration, the scoring maths, the raw guard, run-state validation and a 20-mode CLI fault matrix on synthetic data; with --cli, the raw guard and the importer check against that build's own XMP reader. On three of the maintainers' photos with main 76b5377, it pairs the 34 pairs their private scripts scored identically and reproduces all 7158 statistics exactly. docs/gaps.md gap 3 and the LR-BEHAV-RENDER-FIDELITY row in docs/parity-checklist.md say what exists and what is still missing; gap 3 no longer says only process V1 exists (V2 landed in storytold#645). cargo xtask assets and parity pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t's single-slider responses against Lightroom exports A shareable render-fidelity measurement for gap 3 (docs/render-fidelity.md). It compares a user's own Lightroom TIFF exports with LightCraft renders of the same recipes from the same raws. It reads no Adobe application file, profile, preset or table, keeps only the names of an export's profile and look, and the Lightroom presets it writes are generated from the recipe values. It needs numpy and tifffile (tools/requirements-render-fidelity.txt) and the standard library. - plan: Lightroom develop presets for Basic-slider recipes (default: the Neutral and every Basic slider at two amounts) and export instructions: one export operation into one new folder per session, 16-bit sRGB TIFF, All Metadata. - pair: reads each export's embedded XMP and checks the clean recipe affirmatively (the settings the measurement depends on stated, everything else neutral, identity curves, Adobe Standard / Adobe Color, no crop or local edits). Finds the raw by crs:RawFileName and identifies photos by the raw's sha256; refuses a raw whose own XMP, read where LightCraft's reader reads it, carries develop settings. Pairs each single-slider export with a Neutral, else the same slider's smallest other amount, from the same session (export folder and time segment) and size. Photos split into tune and check by hash. - render: measures a private copy of the given lightcraft-cli. Each raw is first checked with LightCraft's own importer (run --import, develop.get, develop.reset, develop.get: any changed field refuses it). Renders the Basic panel from the export's XMP with sharpening, noise reduction and lens-profile corrections off, from a sidecar-free symlink, 16-bit sRGB at the export's long edge, registers every reference export by a consensus shift search and samples both engines on a grid. Every sample and registration carries its provenance (the run's binding id, CLI and tool hashes, the raw, the recipe or export, frame and shift); a run-folder lock, exclusive manifest creation and identity checks before each write keep concurrent renders apart. CLI calls have time limits; any failure is recorded for its photo and retried on resume. - score: per band of Lightroom's reference luminance, LightCraft's share of Lightroom's log-luminance response, the signed bias, the per-position error, CIE76 dE, the colour-change error, clipping and black transitions both ways, support retention and out-of-support errors, with contributor counts, tune and check apart. A pair is scored only when its raw passed the importer check, its samples' and registration's provenance matches the manifest and the pair, and its two Lightroom exports are framed alike; every other pair is listed with its reason. - report: a Markdown summary to paste into an issue: numbers only, photos under per-run salted labels, and a CSV appendix of every band and transition. - selftest: the XMP, clean-recipe and pairing rules, registration, the scoring maths, the raw guard, run-state validation and a 20-mode CLI fault matrix on synthetic data; with --cli, the raw guard and the importer check against that build's own XMP reader. On three of the maintainers' photos with main 76b5377, it pairs the 34 pairs their private scripts scored identically and reproduces all 7158 statistics exactly. docs/gaps.md gap 3 and the LR-BEHAV-RENDER-FIDELITY row in docs/parity-checklist.md say what exists and what is still missing; gap 3 no longer says only process V1 exists (V2 landed in storytold#645). cargo xtask assets and parity pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t's single-slider responses against Lightroom exports A shareable render-fidelity measurement for gap 3 (docs/render-fidelity.md). It compares a user's own Lightroom TIFF exports with LightCraft renders of the same recipes from the same raws. It reads no Adobe application file, profile, preset or table, keeps only the names of an export's profile and look, and the Lightroom presets it writes are generated from the recipe values. It needs numpy and tifffile (tools/requirements-render-fidelity.txt) and the standard library. - plan: Lightroom develop presets for Basic-slider recipes (default: the Neutral and every Basic slider at two amounts) and export instructions: one export operation into one new folder per session, 16-bit sRGB TIFF, All Metadata. - pair: reads each export's embedded XMP and checks the clean recipe affirmatively (the settings the measurement depends on stated, everything else neutral, identity curves, Adobe Standard / Adobe Color, no crop or local edits). Finds the raw by crs:RawFileName and identifies photos by the raw's sha256; refuses a raw whose own XMP, read where LightCraft's reader reads it, carries develop settings. Pairs each single-slider export with a Neutral, else the same slider's smallest other amount, from the same session (export folder and time segment) and size. Photos split into tune and check by hash. - render: measures a private copy of the given lightcraft-cli. Each raw is first checked with LightCraft's own importer (run --import, develop.get, develop.reset, develop.get: any changed field refuses it). Renders the Basic panel from the export's XMP with sharpening, noise reduction and lens-profile corrections off, from a sidecar-free symlink, 16-bit sRGB at the export's long edge, registers every reference export by a consensus shift search and samples both engines on a grid. Every sample and registration carries its provenance (the run's binding id, CLI and tool hashes, the raw, the recipe or export, frame and shift); a run-folder lock, exclusive manifest creation and identity checks before each write keep concurrent renders apart. CLI calls have time limits; any failure is recorded for its photo and retried on resume. - score: per band of Lightroom's reference luminance, LightCraft's share of Lightroom's log-luminance response, the signed bias, the per-position error, CIE76 dE, the colour-change error, clipping and black transitions both ways, support retention and out-of-support errors, with contributor counts, tune and check apart. A pair is scored only when its raw passed the importer check, its samples' and registration's provenance matches the manifest and the pair, and its two Lightroom exports are framed alike; every other pair is listed with its reason. - report: a Markdown summary to paste into an issue: numbers only, photos under per-run salted labels, and a CSV appendix of every band and transition. - selftest: the XMP, clean-recipe and pairing rules, registration, the scoring maths, the raw guard, run-state validation and a 20-mode CLI fault matrix on synthetic data; with --cli, the raw guard and the importer check against that build's own XMP reader. On three of the maintainers' photos with main 76b5377, it pairs the 34 pairs their private scripts scored identically and reproduces all 7158 statistics exactly. docs/gaps.md gap 3 and the LR-BEHAV-RENDER-FIDELITY row in docs/parity-checklist.md say what exists and what is still missing; gap 3 no longer says only process V1 exists (V2 landed in storytold#645). cargo xtask assets and parity pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Library: search boxes in the Metadata columns and the People view (carries storytold#643)
…t's single-slider responses against Lightroom exports A shareable render-fidelity measurement for gap 3 (docs/render-fidelity.md). It compares a user's own Lightroom TIFF exports with LightCraft renders of the same recipes from the same raws. It reads no Adobe application file, profile, preset or table, keeps only the names of an export's profile and look, and the Lightroom presets it writes are generated from the recipe values. It needs numpy and tifffile (tools/requirements-render-fidelity.txt) and the standard library. - plan: Lightroom develop presets for Basic-slider recipes (default: the Neutral and every Basic slider at two amounts) and export instructions: one export operation into one new folder per session, 16-bit sRGB TIFF, All Metadata. - pair: reads each export's embedded XMP and checks the clean recipe affirmatively (the settings the measurement depends on stated, everything else neutral, identity curves, Adobe Standard / Adobe Color, no crop or local edits). Finds the raw by crs:RawFileName and identifies photos by the raw's sha256; refuses a raw whose own XMP, read where LightCraft's reader reads it, carries develop settings. Pairs each single-slider export with a Neutral, else the same slider's smallest other amount, from the same session (export folder and time segment) and size. Photos split into tune and check by hash. - render: measures a private copy of the given lightcraft-cli. Each raw is first checked with LightCraft's own importer (run --import, develop.get, develop.reset, develop.get: any changed field refuses it). Renders the Basic panel from the export's XMP with sharpening, noise reduction and lens-profile corrections off, from a sidecar-free symlink, 16-bit sRGB at the export's long edge, registers every reference export by a consensus shift search and samples both engines on a grid. Every sample and registration carries its provenance (the run's binding id, CLI and tool hashes, the raw, the recipe or export, frame and shift); a run-folder lock, exclusive manifest creation and identity checks before each write keep concurrent renders apart. CLI calls have time limits; any failure is recorded for its photo and retried on resume. - score: per band of Lightroom's reference luminance, LightCraft's share of Lightroom's log-luminance response, the signed bias, the per-position error, CIE76 dE, the colour-change error, clipping and black transitions both ways, support retention and out-of-support errors, with contributor counts, tune and check apart. A pair is scored only when its raw passed the importer check, its samples' and registration's provenance matches the manifest and the pair, and its two Lightroom exports are framed alike; every other pair is listed with its reason. - report: a Markdown summary to paste into an issue: numbers only, photos under per-run salted labels, and a CSV appendix of every band and transition. - selftest: the XMP, clean-recipe and pairing rules, registration, the scoring maths, the raw guard, run-state validation and a 20-mode CLI fault matrix on synthetic data; with --cli, the raw guard and the importer check against that build's own XMP reader. On three of the maintainers' photos with main 76b5377, it pairs the 34 pairs their private scripts scored identically and reproduces all 7158 statistics exactly. docs/gaps.md gap 3 and the LR-BEHAV-RENDER-FIDELITY row in docs/parity-checklist.md say what exists and what is still missing; gap 3 no longer says only process V1 exists (V2 landed in storytold#645). cargo xtask assets and parity pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Highlights no longer flattens the detail in bright areas, and Shadows no longer flattens it in dark areas. Fixes #634 (reported in #632).
What was wrong
Both sliders shift tone in log luminance according to an edge-aware base layer (
crates/pipeline/src/local.rs, fast guided filter). The guided filter keeps any edge stronger than about 0.6 EV, however thin. So twigs, trim and wires against a bright sky end up in the base, and get a different shift than the sky around them.Change
The base is now the same guided filter run on a median of log luminance:
median_hv(a sliding sorted window) andtone_baseincrates/pipeline/src/local.rs.median_h/median_vkernels incrates/gpu/src/wgsl/blur.wgsl, wired in throughrender.rs/ctx.rs. The median is a pure selection, so the CPU and GPU paths agree exactly. The GPU equivalence tests pass, max 1 LSB at 3000 × 2000.Measurements
Pixels between 80 % and 98.5 % brightness (bright) or below 20 % (dark) in the unedited render. "Detail" is the standard deviation of a 9 × 9 high-pass of luminance, divided by the region's mean. Renders are 4000 px.
Results on the other files tested (Leica V-Lux 4, Samsung S7, Ricoh GR III, Sigma sd Quattro and Quattro H, OM System OM-1):
From left to right: no edit, main at Highlights −100, this PR at Highlights −100, and Exposure −1 for reference. Sky with twigs at the top, gable wall at the bottom. 2218 is a "lossy after split" NEF that main can't decode yet, so these renders use #633's decoder; this PR doesn't include that change.
Tests
crates/pipeline/src/tests_tone.rsadds six tests:The contrast tests fail with the median turned off.
The full workspace test run (
--no-fail-fast, with craft-fonts) passes, apart from two existing failures:browse_a_local_folder, the Windows-only failure already on main (browse_a_local_folder test fails on Windows (path separator in assertion) #538);offline_originals_never_block_a_frame, a timing test that failed once under load and passes 3 of 3 on its own.Process V2 (after review)
This now ships as a new rendering process, as
docs/process-versions.mdrequires:Process::V2(version 2) is added and madeLATEST. New photos and Reset get it. Existing edits stay on V1 until Photo ▸ Update to Current Process, and settings saved without the field still load as V1.local::tone_base_detailis 0 under V1, sotone_baseis exactly the oldguided_fast(l, sigma, BASE_EPS). A test checks this bit for bit. On Pentax 645D 2401 at 4000 px, main and this branch with{"process":1}give identical files for plain, Highlights −100 and Shadows +100.local::prepareand the GPU prepare. GPU and CPU agree to within 1 LSB at 720 and 2400 px on both processes.(sigma, process, median radius)(local::BaseKey). A test switches a warm cache between V1 and V2, and fails without the process in the key.RENDER_CACHE_VERSIONis 43, past main's 37. Our other open PRs use 38–42, so each is distinct and none can merge silently onto another's number.Trade-offs
RENDER_CACHE_VERSIONis 43 here (main is 37), so adjust it at merge.