LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge PR #645
Claude8c4898ec04fb
diff --cc crates/engine/src/media.rsindex 1d11f225c,9c1566d53..1ecbfa204--- a/crates/engine/src/media.rs+++ b/crates/engine/src/media.rs@@@ -62,7 -62,7 +62,7 @@@ impl SettingsHashes}/// Bump when the pipeline's output changes, to invalidate cached thumbnails.- pub const RENDER_CACHE_VERSION: u64 = 59;-pub const RENDER_CACHE_VERSION: u64 = 54;++pub const RENDER_CACHE_VERSION: u64 = 60;/// Thumbnails render at one of these long edges (so window/cell size changes reuse the cache).pub const THUMB_SIZES: [usize; 4] = [128, 256, 384, 512];diff --cc crates/pipeline/src/finish.rsindex d15f377a2,c58b99e86..eb65d51a2--- a/crates/pipeline/src/finish.rs+++ b/crates/pipeline/src/finish.rs@@@ -280,8 -279,9 +280,9 @@@ impl FinishParamspub fn base_tone(s: &DevelopSettings, info: &SourceInfo, peak: f32) -> ToneMap {let l = &s.light;match s.process.process() {- Process::V1 => match info.camera_tone.as_ref().filter(|_| info.raw) {+ // V2 changes the Highlights/Shadows base (`local::tone_base`), not the tone map- Process::V1 | Process::V2 => match info.camera_tone.as_ref().filter(|_| info.raw && peak <= 1.0) {- Some(curve) => ToneMap::camera(curve, l.contrast, l.whites, l.blacks),++ Process::V1 | Process::V2 => match info.camera_tone.as_ref().filter(|_| info.raw) {+ Some(curve) => ToneMap::camera_hdr(curve, l.contrast, l.whites, l.blacks, peak),None if info.raw => ToneMap::hdr(l.contrast, l.whites, l.blacks, peak),None => ToneMap::display_hdr(l.contrast, l.whites, l.blacks, peak),},diff --cc crates/pipeline/src/local.rsindex f2e46f18b,f51d75cb3..ce3994cd8--- a/crates/pipeline/src/local.rs+++ b/crates/pipeline/src/local.rs@@@ -1,9 -1,9 +1,9 @@@//! Scene-linear preparation: white balance + exposure, and the spatial planes the per-pixel stage//! needs (edge-aware base layer for highlights/shadows, clarity/texture bands, dehaze veil).-use lightcraft_color::cct::{temp_tint_to_xy, wb_matrix};+use lightcraft_color::cct::{temp_tint_to_xy, wb_matrix, xy_to_temp_tint};use lightcraft_color::{REC2020, luminance_2020};- use lightcraft_develop::DevelopSettings;+ use lightcraft_develop::{DevelopSettings, Process};use lightcraft_raster::blur::gaussian;use std::sync::Arc;@@@ -296,10 -290,9 +376,11 @@@ pub fn log_lum(c: [f32; 3]) -> f32#[derive(Clone, Default)]pub(crate) struct Planes {pub key: u64,+ /// The image's key without its noise reduction (`Plan::pre_nr_key`).+ pub pre_nr: u64,pub log_l: Option<Arc<Plane>>,- pub base: Option<(u32, Arc<Plane>)>,+ /// Keyed by its radius, process and median radius ([`BaseKey`]).+ pub base: Option<(BaseKey, Arc<Plane>)>,pub clarity: Option<(u32, Arc<Plane>)>,pub texture: Option<(u32, Arc<Plane>)>,/// Dark channel and its airlight.@@@ -308,22 -301,24 +389,33 @@@pub chroma: Option<(u32, Arc<Rgb32f>)>,}+impl Planes {+ /// The planes that still fit an image differing from this one only in noise reduction, close+ /// enough for a draft: the wide blurs (base, clarity, dehaze, chromaticity). Its `key` matches+ /// no image, so only another draft takes them.+ pub fn for_other_nr(self) -> Planes {+ Planes { key: 0, pre_nr: self.pre_nr, log_l: None, texture: None, ..self }+ }+}+- /// Reuse `slot` if it was computed at `sigma`, else compute and store it.- fn plane_at(slot: &mut Option<(u32, Arc<Plane>)>, sigma: f32, f: impl FnOnce() -> Plane) -> Arc<Plane> {+ /// What the highlights/shadows base plane was computed with: its radius (`f32` bits), the+ /// rendering process and the median radius ([`tone_base_detail`]). The base differs between+ /// processes, so a photo moved to another one (Update to Current Process, undo) recomputes it.+ pub type BaseKey = (u32, Process, usize);++ /// The [`BaseKey`] of a base at `sigma` for `s` (`detail`: [`PlaneSigmas::base_detail`]).+ pub fn base_key(s: &DevelopSettings, sigma: f32, detail: usize) -> BaseKey {+ (sigma.to_bits(), s.process.process(), detail)+ }++ /// Reuse `slot` if it was computed with `key` (a radius's `f32` bits, or a [`BaseKey`]), else+ /// compute and store it.+ pub fn plane_at<K: Copy + PartialEq, P>(slot: &mut Option<(K, Arc<P>)>, key: K, f: impl FnOnce() -> P) -> Arc<P> {match slot {- Some((k, p)) if *k == sigma.to_bits() => p.clone(),+ Some((k, p)) if *k == key => p.clone(),_ => {let p = Arc::new(f());- *slot = Some((sigma.to_bits(), p.clone()));+ *slot = Some((key, p.clone()));p}}diff --cc docs/parity-checklist.mdindex 5151299a0,8ce93a287..8a468f800--- a/docs/parity-checklist.md+++ b/docs/parity-checklist.md@@@ -175,11 -241,11 +175,11 @@@ differences and missing bindings are i|---|---|---|---|---|---|| LR-EDIT-AUTO | Auto settings | P0 | ✅ | `cmd:develop.auto`, `crates/pipeline/src/auto.rs` | a Lightroom-like recipe calibrated black-box on Lightroom's Auto results for 24 Sony raws: Exposure from the scene's scene-linear log-average luminance (Lightroom's observed slope, -0.41 EV per EV), Highlights -66 and Shadows +52 (Lightroom's average Auto values), Contrast +68 and Vibrance +30 fitted on our scales. Held out one photo at a time: on the 16 photos whose start Sony's DRO doesn't brighten, a median dE76 of 6.4 from Lightroom's Auto results against 8.3 unedited; on all 24, 7.7 against 7.9 (issues #318, #209). Calibrated on Sony files only; Whites and Blacks stay 0 || LR-EDIT-BW | Black & white | P0 | ✅ | `cmd:develop.treatment` | |-| LR-EDIT-HDR-MODE | HDR editing | P2 | ✅ | `cmd:develop.hdr`, `ctl:hdr.maxEv`, `crates/ui-egui/src/panels/edit.rs` (`hdr_row`) | HDR switch in the Light panel; see Q. HDR |+| LR-EDIT-HDR-MODE | HDR editing | P2 | ✅ | `cmd:develop.hdr`, `ctl:hdr.maxEv`, `crates/ui-egui/src/panels/edit.rs` (`hdr_row`) | HDR button next to B&W in the Edit panel header, as Lightroom (Visualize HDR and the headroom limit in the Light panel while it's on); see Q. HDR || LR-EDIT-LIGHT-EXPOSURE | Exposure | P0 | ✅ | `ctl:light.exposure` | || LR-EDIT-LIGHT-CONTRAST | Contrast | P0 | ✅ | `ctl:light.contrast` | |- | LR-EDIT-LIGHT-HIGHLIGHTS | Highlights | P0 | ✅ | `ctl:light.highlights`, `crates/raw/src/highlight.rs` | sensor-clipped highlights stay neutral when Highlights (or Exposure, Whites) darkens them: fully clipped content is rebuilt to the neutral of the colour model applied after it, partly clipped content takes its colour from reliable unclipped content nearby (not from dark objects, lens fringes or another surface beside it) and white where there is none, and pale partly clipped content (a white sky) turns white on its way to clipping (#523); binned previews and thumbnails decide clipping per sample before averaging (`develop_binned_masked`, `highlight::reconstruct_masked`), so a block with one clipped specular sample keeps its mean instead of jumping to the clip level, which reconstruction turned into green speckles at 500 px (#548) |- | LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | |+ | LR-EDIT-LIGHT-HIGHLIGHTS | Highlights | P0 | ✅ | `ctl:light.highlights`, `crates/raw/src/highlight.rs` | sensor-clipped highlights stay neutral when Highlights (or Exposure, Whites) darkens them: fully clipped content is rebuilt to the neutral of the colour model applied after it, partly clipped content takes its colour from reliable unclipped content nearby (not from dark objects, lens fringes or another surface beside it) and white where there is none, and pale partly clipped content (a white sky) turns white on its way to clipping (#523); binned previews and thumbnails decide clipping per sample before averaging (`develop_binned_masked`, `highlight::reconstruct_masked`), so a block with one clipped specular sample keeps its mean instead of jumping to the clip level, which reconstruction turned into green speckles at 500 px (#548) From process V2 the Highlights/Shadows base is the edge-aware filter of the 0.15 %-of-long-edge median of log luminance: twigs and fine texture take their surroundings' shift, so bright areas keep their local contrast as with Exposure (V1's base kept ~0.6 of it at −100, #632); region edges stay sharp |+ | LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | From process V2, the same base as Highlights: dark areas keep their local contrast when lifted (#632) || LR-EDIT-LIGHT-WHITES | Whites | P0 | ✅ | `ctl:light.whites` | || LR-EDIT-LIGHT-BLACKS | Blacks | P0 | ✅ | `ctl:light.blacks` | || LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*` | |