From 26a8f4e706ee52d1fb96448593356873e5f1f2ac Mon Sep 17 00:00:00 2001 From: Dimitrij Denissenko Date: Tue, 10 Nov 2026 09:07:59 +0000 Subject: [PATCH 1/6] LR-MASK-BRUSH: Flow as in Lightroom (process V8): coverage per brush radius travelled Measured in Lightroom Classic on a grey card (#4045), a stroke's centre is covered by 41 % at Flow 25 and 76 % at Flow 50; here every dab added the full flow, r/4 apart (closer on a slow drag), so 90 % and over 99 %. From process V8 a dab adds 1 - (1 - flow)^(d / r) for its distance d from the previous dab, so a point a stroke passes over for a length L is covered by 1 - (1 - flow)^(L / r) however densely the dabs lie: 44 % and 75 %. CPU, GPU (a flow per dab in the brush data) and the live stroke alike; V1 to V7 render as before. --- crates/develop/src/settings.rs | 9 +++- crates/gpu/src/render.rs | 7 +-- crates/gpu/src/wgsl/mask.wgsl | 11 ++-- crates/gpu/tests/it/equivalence.rs | 14 +++++ crates/pipeline/src/finish.rs | 6 +-- crates/pipeline/src/geometry.rs | 4 ++ crates/pipeline/src/light_v3.rs | 2 +- crates/pipeline/src/local.rs | 2 +- crates/pipeline/src/masks.rs | 58 ++++++++++++++++++-- crates/pipeline/src/masks/tests.rs | 66 +++++++++++++++++++++++ crates/pipeline/src/tests_grain.rs | 2 +- crates/ui-egui/src/brush_live.rs | 48 +++++++++++++++-- crates/ui-egui/src/panels/detail/masks.rs | 1 + crates/ui-egui/src/tests/masking.rs | 27 ++++++++++ docs/parity-checklist.md | 3 +- docs/process-versions.md | 4 +- docs/whats-new.md | 5 ++ 17 files changed, 245 insertions(+), 24 deletions(-) diff --git a/crates/develop/src/settings.rs b/crates/develop/src/settings.rs index 85bb3b90f2..8a6a7168b5 100644 --- a/crates/develop/src/settings.rs +++ b/crates/develop/src/settings.rs @@ -99,12 +99,16 @@ pub enum Process { /// V6, with film grain from a stack of crystal layers (after Aurélien Pierre's model): resolution /// independent, fading out at black and white; V1 to V6 keep their value noise. V7, + /// V7, with brush Flow as the coverage a stroke adds per brush radius it travels, as in + /// Lightroom: a dab adds `1 − (1 − flow)^(distance from the previous dab / radius)`, so a + /// stroke's strength no longer depends on how densely its dabs lie; V1 to V7 add `flow` per dab. + V8, } impl Process { /// Every process, oldest first. - pub const ALL: [Process; 7] = [Process::V1, Process::V2, Process::V3, Process::V4, Process::V5, Process::V6, Process::V7]; - pub const LATEST: Process = Process::V7; + pub const ALL: [Process; 8] = [Process::V1, Process::V2, Process::V3, Process::V4, Process::V5, Process::V6, Process::V7, Process::V8]; + pub const LATEST: Process = Process::V8; pub const fn version(self) -> ProcessVersion { match self { @@ -115,6 +119,7 @@ impl Process { Process::V5 => ProcessVersion(5), Process::V6 => ProcessVersion(6), Process::V7 => ProcessVersion(7), + Process::V8 => ProcessVersion(8), } } } diff --git a/crates/gpu/src/render.rs b/crates/gpu/src/render.rs index 4d658c3ca0..12254a475f 100644 --- a/crates/gpu/src/render.rs +++ b/crates/gpu/src/render.rs @@ -1459,7 +1459,8 @@ fn prepare(cx: &mut Cx<'_>, lin: &Buf, plan: &Plan<'_>, req: &RenderRequest, pla const MAX_DABS: usize = 4096; /// The `shape` kernel's brush data for `dabs`: stroke records (12 words: dab offset, dab count, -/// r, hard, flow, density, erase, bbox x0 y0 x1 y1, auto) then the dab centres. +/// r, hard, flow, density, erase, bbox x0 y0 x1 y1, auto) then each dab's centre and the flow it +/// adds (3 words; the stroke's flow before process V8, [`lightcraft_pipeline::masks::BrushDabs::dab`]). fn brush_aux(dabs: &[&lightcraft_pipeline::masks::BrushDabs], erase: bool) -> Vec { let mut aux = Vec::new(); let mut off = 12 * dabs.len(); @@ -1471,10 +1472,10 @@ fn brush_aux(dabs: &[&lightcraft_pipeline::masks::BrushDabs], erase: bool) -> Ve aux.extend([off as f32, d.dabs.len() as f32, d.r as f32, d.hard as f32, d.flow, d.density, (erase && d.erase) as u8 as f32]); aux.extend([x0, y0, x1, y1].map(|v| v as f32)); aux.push(d.auto as u8 as f32); - off += 2 * d.dabs.len(); + off += 3 * d.dabs.len(); } for d in dabs { - aux.extend(d.dabs.iter().flat_map(|q| [q.x as f32, q.y as f32])); + aux.extend(d.dabs.iter().enumerate().flat_map(|(i, q)| [q.x as f32, q.y as f32, d.dab(i).2])); } aux } diff --git a/crates/gpu/src/wgsl/mask.wgsl b/crates/gpu/src/wgsl/mask.wgsl index c2d15b64a2..6157b5f866 100644 --- a/crates/gpu/src/wgsl/mask.wgsl +++ b/crates/gpu/src/wgsl/mask.wgsl @@ -92,11 +92,12 @@ fn shape(@builtin(global_invocation_id) g: vec3) { let cnt = u32(aux[o + 1u]); let r = aux[o + 2u]; let hard = aux[o + 3u]; - let flow = aux[o + 4u]; var keep = 1.0; for (var j = 0u; j < cnt; j++) { - let dx = px - aux[off + 2u * j]; - let dy = py - aux[off + 2u * j + 1u]; + // dab record: centre x, y and the flow it adds (the stroke's before process V8) + let dx = px - aux[off + 3u * j]; + let dy = py - aux[off + 3u * j + 1u]; + let flow = aux[off + 3u * j + 2u]; let dd = sqrt(dx * dx + dy * dy); if (dd > r) { continue; @@ -106,8 +107,8 @@ fn shape(@builtin(global_invocation_id) g: vec3) { a = 1.0 - sstep(hard, r, dd); } if (auto_mask) { - let rx = min(u32(max(floor(aux[off + 2u * j]), 0.0)), w - 1u); - let ry = min(u32(max(floor(aux[off + 2u * j + 1u]), 0.0)), h - 1u); + let rx = min(u32(max(floor(aux[off + 3u * j]), 0.0)), w - 1u); + let ry = min(u32(max(floor(aux[off + 3u * j + 1u]), 0.0)), h - 1u); let ri = ry * w + rx; a *= auto_similarity(lp, chp, log_l[ri], chroma_at(ri)); } diff --git a/crates/gpu/tests/it/equivalence.rs b/crates/gpu/tests/it/equivalence.rs index 427afe424d..15550cfb74 100644 --- a/crates/gpu/tests/it/equivalence.rs +++ b/crates/gpu/tests/it/equivalence.rs @@ -434,6 +434,20 @@ fn cases() -> Vec<(&'static str, Edit)> { }, ]; }), + ("masks (brush, process V7: flow per dab)", |s| { + s.process = lightcraft_develop::Process::V7.version(); + let stroke = BrushStroke { + points: vec![Point::new(0.1, 0.3), Point::new(0.5, 0.4), Point::new(0.8, 0.35)], + size: 0.04, + flow: 25.0, + ..Default::default() + }; + s.masks = vec![Mask { + components: vec![MaskComponent { name: None, op: MaskOp::Add, invert: false, shape: MaskShape::Brush { strokes: vec![stroke] } }], + adjust: lightcraft_develop::LocalAdjustments { exposure: -1.0, ..Default::default() }, + ..Default::default() + }]; + }), ("masks (brush + ranges)", |s| { let stroke = BrushStroke { points: vec![Point::new(0.1, 0.3), Point::new(0.5, 0.4), Point::new(0.8, 0.35)], diff --git a/crates/pipeline/src/finish.rs b/crates/pipeline/src/finish.rs index 3bce268a68..a4ec7ddec3 100644 --- a/crates/pipeline/src/finish.rs +++ b/crates/pipeline/src/finish.rs @@ -148,8 +148,8 @@ impl GrainModel { seed: g.seed, }) }), - Process::V7 if draft => crate::crystal::CrystalGrain::draft(g, px_per_long).map(GrainModel::Crystal), - Process::V7 => crate::crystal::CrystalGrain::new(g, px_per_long).map(GrainModel::Crystal), + Process::V7 | Process::V8 if draft => crate::crystal::CrystalGrain::draft(g, px_per_long).map(GrainModel::Crystal), + Process::V7 | Process::V8 => crate::crystal::CrystalGrain::new(g, px_per_long).map(GrainModel::Crystal), } } } @@ -407,7 +407,7 @@ pub fn base_tone(s: &DevelopSettings, info: &SourceInfo, peak: f32) -> ToneMap { }, // V4, with a raw's tone curve rolling off into white in stops: a camera curve past its last // knot, the generic curve from half a stop below its white point instead of clipping (issue #1632) - Process::V5 | Process::V6 | Process::V7 => match info.camera_tone.as_ref().filter(|_| info.raw) { + Process::V5 | Process::V6 | Process::V7 | Process::V8 => match info.camera_tone.as_ref().filter(|_| info.raw) { Some(curve) => ToneMap::camera_rolloff_hdr(curve, 0.0, l.whites, 0.0, peak), None if info.raw => ToneMap::rolloff_hdr(l.contrast, l.whites, l.blacks, peak), None => ToneMap::display_hdr(l.contrast, l.whites, l.blacks, peak), diff --git a/crates/pipeline/src/geometry.rs b/crates/pipeline/src/geometry.rs index 5d8a07489a..3ed3268474 100644 --- a/crates/pipeline/src/geometry.rs +++ b/crates/pipeline/src/geometry.rs @@ -37,6 +37,9 @@ pub struct Frame { /// `lightcraft_develop::Mask::on_photo`); otherwise they are normalized coordinates of this /// frame's transformed image, like spots and the crop. pub masks_on_photo: bool, + /// Brush Flow is coverage per brush radius travelled (process V8, [`crate::masks::flow_per_radius`]), + /// not per dab. + pub brush_flow_per_radius: bool, } /// Where a windowed [`Frame`]'s pixels sit in the full output: its offset and the full output's @@ -82,6 +85,7 @@ impl Frame { warp: (!warp.is_identity()).then_some(warp), view: None, masks_on_photo: false, + brush_flow_per_radius: crate::masks::flow_per_radius(s), }; if apply_crop { f.constrain_to_image(s.geometry.constrain_crop); diff --git a/crates/pipeline/src/light_v3.rs b/crates/pipeline/src/light_v3.rs index a7db45ec06..5f3e0f9bf2 100644 --- a/crates/pipeline/src/light_v3.rs +++ b/crates/pipeline/src/light_v3.rs @@ -284,7 +284,7 @@ pub fn applies(s: &DevelopSettings, info: &SourceInfo) -> bool { let camera_look = info.raw && info.camera_tone.is_some(); match s.process.process() { Process::V1 | Process::V2 | Process::V3 => false, - Process::V4 | Process::V5 | Process::V6 | Process::V7 => camera_look, + Process::V4 | Process::V5 | Process::V6 | Process::V7 | Process::V8 => camera_look, } } diff --git a/crates/pipeline/src/local.rs b/crates/pipeline/src/local.rs index 5fb9ad84ce..0401c31533 100644 --- a/crates/pipeline/src/local.rs +++ b/crates/pipeline/src/local.rs @@ -375,7 +375,7 @@ pub fn base_detail_radius(px_per_long: f64) -> usize { pub fn tone_base_detail(s: &DevelopSettings, px_per_long: f64) -> usize { match s.process.process() { Process::V1 => 0, - Process::V2 | Process::V3 | Process::V4 | Process::V5 | Process::V6 | Process::V7 => base_detail_radius(px_per_long), + Process::V2 | Process::V3 | Process::V4 | Process::V5 | Process::V6 | Process::V7 | Process::V8 => base_detail_radius(px_per_long), } } diff --git a/crates/pipeline/src/masks.rs b/crates/pipeline/src/masks.rs index b40e3dcd97..a30ecf7e4a 100644 --- a/crates/pipeline/src/masks.rs +++ b/crates/pipeline/src/masks.rs @@ -511,11 +511,21 @@ pub struct BrushDabs { pub auto: bool, /// Pen pressure (0..1) of each dab, parallel to `dabs`; empty when the stroke has no pressure data (full pressure). pub pressure: Vec, + /// What each dab adds under process V8 ([`travel_flow`], pressure applied), parallel to `dabs`; + /// empty before V8, where every dab adds the stroke's flow. + pub flows: Vec, } impl BrushDabs { - /// Radius, hard core and flow of dab `i`, pen pressure applied ([`pressure_radius`], [`pressure_flow`]). + /// Radius, hard core and flow of dab `i`, pen pressure applied ([`pressure_radius`], [`pressure_flow`]); + /// under process V8 the flow is what the dab adds for the distance it travelled ([`travel_flow`]). pub fn dab(&self, i: usize) -> (f64, f64, f32) { + let (r, hard, flow) = self.pressed(i); + (r, hard, self.flows.get(i).copied().unwrap_or(flow)) + } + + /// [`Self::dab`] with the stroke's flow for every dab, as before process V8. + fn pressed(&self, i: usize) -> (f64, f64, f32) { match self.pressure.get(i) { Some(&p) => { let r = pressure_radius(self.r, p); @@ -524,6 +534,46 @@ impl BrushDabs { None => (self.r, self.hard, self.flow), } } + + /// Give every dab what it adds for the distance it travelled ([`travel_flow`], process V8). + fn flow_by_travel(mut self) -> BrushDabs { + let flows = (0..self.dabs.len()) + .map(|i| { + let (r, _, flow) = self.pressed(i); + // the first dab counts one radius: a click paints its flow, as before + let dist = match (i.checked_sub(1).and_then(|j| self.dabs.get(j)), self.dabs.get(i)) { + (Some(a), Some(b)) => a.dist(*b), + _ => r, + }; + travel_flow(flow, dist, r) + }) + .collect(); + self.flows = flows; + self + } +} + +/// Whether brush Flow is the coverage a stroke adds per brush radius it travels (process V8 on), as +/// in Lightroom, rather than what every dab adds whatever the spacing of the dabs. +pub fn flow_per_radius(s: &lightcraft_develop::DevelopSettings) -> bool { + s.process.process() >= lightcraft_develop::Process::V8 +} + +/// What one dab adds to a stroke's coverage when Flow is coverage per brush radius travelled +/// (process V8): `1 − (1 − flow)^(dist / r)` for a dab `dist` past the previous one, brush radius +/// `r`. A stroke then covers a point it passes over for a length `L` by `1 − (1 − flow)^(L / r)` +/// however densely its dabs lie: a straight stroke's centre (`L` = 2 r) by 44 % at Flow 25, 75 % at +/// Flow 50 and fully at 100, as Lightroom Classic's strokes measure on a grey card (#4045). +pub fn travel_flow(flow: f32, dist: f64, r: f64) -> f32 { + if flow.is_nan() || flow <= 0.0 { + return 0.0; + } + if flow >= 1.0 { + return 1.0; + } + // (a degenerate radius or distance counts one radius; a long jump at most saturates) + let t = if r > 0.0 && dist.is_finite() { (dist / r).clamp(0.0, 64.0) } else { 1.0 }; + 1.0 - (1.0 - flow).powf(t as f32) } /// The radius of a dab of a brush of radius `r` (pixels) painted at pen pressure `p` (0..1): from a tenth of the @@ -604,7 +654,7 @@ pub fn brush_dabs_within(s: &BrushStroke, frame: &Frame, w: usize, h: usize, max prev_p = pq; } } - BrushDabs { + let bd = BrushDabs { dabs, r, hard, @@ -613,7 +663,9 @@ pub fn brush_dabs_within(s: &BrushStroke, frame: &Frame, w: usize, h: usize, max erase: s.erase, auto: s.auto_mask, pressure, - } + flows: Vec::new(), + }; + if frame.brush_flow_per_radius { bd.flow_by_travel() } else { bd } } /// Distance between consecutive dabs of a brush of radius `r` (pixels): a quarter of the radius, diff --git a/crates/pipeline/src/masks/tests.rs b/crates/pipeline/src/masks/tests.rs index b57f9f6688..649e5cc30a 100644 --- a/crates/pipeline/src/masks/tests.rs +++ b/crates/pipeline/src/masks/tests.rs @@ -456,6 +456,72 @@ fn holding_the_brush_still_adds_no_coverage() { assert_eq!(brush_dabs(&paused, &f, w, h).dabs, brush_dabs(&smooth, &f, w, h).dabs); } +/// A straight Feather 0 stroke of radius 20 px along row 50 of a 400 × 100 frame on `process`. +fn straight_stroke(process: lightcraft_develop::Process, flow: f64, points: Vec) -> Plane { + let (w, h) = (400, 100); + let d = DevelopSettings { process: process.version(), ..Default::default() }; + let f = Frame::new(w, h, &d, true); + let s = BrushStroke { points, size: 0.05, feather: 0.0, flow, ..Default::default() }; + shape_alpha(&MaskShape::Brush { strokes: vec![s] }, &f, w, h, &Rgb32f::new(w, h), &Plane::new(w, h), 0.0, None) +} + +/// Process V8: Flow is the coverage a stroke adds per brush radius it travels, as Lightroom +/// Classic's strokes measure on a grey card (Feather 0, straight strokes, #4045): a point the brush +/// passes over for a length `L` is covered by `1 − (1 − flow)^(L / r)`, so the centre of a stroke +/// (L = 2 r) by 41 % at Flow 25, 76 % at 50 and fully at 100 (Lightroom), and a point 0.6 radii off +/// the centre line less. Process V7 adds the flow per dab, r/4 apart: 90 % at Flow 25. +#[test] +fn flow_is_coverage_per_radius_travelled_as_in_lightroom() { + use lightcraft_develop::Process; + let line = vec![Point::new(0.1, 0.5), Point::new(0.9, 0.5)]; + for (flow, lightroom) in [(25.0, 0.41), (50.0, 0.76), (100.0, 1.0)] { + let a = straight_stroke(Process::V8, flow, line.clone()); + let keep = 1.0 - flow as f32 / 100.0; + let centre = a.get(200, 50); + assert!((centre - (1.0 - keep.powi(2))).abs() < 0.03, "Flow {flow}: centre {centre}"); + assert!((centre - lightroom).abs() < 0.05, "Flow {flow}: Lightroom covers {lightroom}, here {centre}"); + // pixel row 62 is 12.5 px = 0.625 r off the line, under the brush for 2·√(1 − 0.625²) radii + let chord = 2.0 * (1.0 - 0.625f32 * 0.625).sqrt(); + let off = a.get(200, 62); + assert!((off - (1.0 - keep.powf(chord))).abs() < 0.05, "Flow {flow}: 0.6 r off the line {off}"); + assert!(off <= centre + 1e-6); + } + let old = straight_stroke(Process::V7, 25.0, line).get(200, 50); + assert!(old > 0.85, "V7 keeps the flow per dab: {old}"); +} + +/// Process V8: a stroke covers the same however densely its samples lie (a slow drag samples +/// every pixel, a fast one far apart); before V8 a slow stroke laid more dabs and built up more. +#[test] +fn flow_does_not_depend_on_how_fast_the_stroke_was_painted() { + use lightcraft_develop::Process; + let fast = vec![Point::new(0.1, 0.5), Point::new(0.9, 0.5)]; + // one sample per output pixel + let slow: Vec = (40..=360).map(|x| Point::new(x as f64 / 400.0, 0.5)).collect(); + let (f, s) = (straight_stroke(Process::V8, 25.0, fast.clone()).get(200, 50), straight_stroke(Process::V8, 25.0, slow.clone()).get(200, 50)); + assert!((f - s).abs() < 0.02, "fast {f} vs slow {s}"); + let (f7, s7) = (straight_stroke(Process::V7, 25.0, fast).get(200, 50), straight_stroke(Process::V7, 25.0, slow).get(200, 50)); + assert!(s7 > f7, "before V8 a slow stroke builds up more: {f7} vs {s7}"); +} + +/// A click (one dab) paints its flow on every process; Flow 100 paints fully. +#[test] +fn a_click_paints_its_flow() { + use lightcraft_develop::Process; + for p in [Process::V7, Process::V8] { + let a = straight_stroke(p, 40.0, vec![Point::new(0.5, 0.5)]); + assert!((a.get(200, 50) - 0.4).abs() < 1e-4, "{p:?}: {}", a.get(200, 50)); + } + assert_eq!(travel_flow(1.0, 0.25, 1.0), 1.0); + assert_eq!(travel_flow(0.0, 1.0, 1.0), 0.0); + assert_eq!(travel_flow(f32::NAN, 1.0, 1.0), 0.0); + assert!((travel_flow(0.25, 1.0, 1.0) - 0.25).abs() < 1e-6, "one radius adds the flow"); + assert!((travel_flow(0.25, 0.0, 0.0) - 0.25).abs() < 1e-6, "a degenerate radius counts one radius"); + assert!((travel_flow(0.25, f64::INFINITY, 1.0) - 0.25).abs() < 1e-6); + assert!(travel_flow(0.25, 1e12, 1.0) > 0.999 && travel_flow(0.25, 1e12, 1.0) <= 1.0); + assert!(travel_flow(0.25, -5.0, 1.0) == 0.0, "no distance adds nothing"); +} + /// Flow builds up by passes: going back over an area in the same stroke adds coverage. #[test] fn a_second_pass_builds_up_with_low_flow() { diff --git a/crates/pipeline/src/tests_grain.rs b/crates/pipeline/src/tests_grain.rs index 14172a516c..9dc4892453 100644 --- a/crates/pipeline/src/tests_grain.rs +++ b/crates/pipeline/src/tests_grain.rs @@ -35,7 +35,7 @@ fn processes_before_v7_keep_the_value_noise() { Process::V1 | Process::V2 | Process::V3 | Process::V4 | Process::V5 | Process::V6 => { assert!(matches!(model, Some(GrainModel::Value(_))), "{p:?}") } - Process::V7 => assert!(matches!(model, Some(GrainModel::Crystal(_))), "{p:?}"), + Process::V7 | Process::V8 => assert!(matches!(model, Some(GrainModel::Crystal(_))), "{p:?}"), } assert!(GrainModel::new(&on(p, 0.0), 2000.0, false).is_none(), "{p:?}: no grain at Amount 0"); } diff --git a/crates/ui-egui/src/brush_live.rs b/crates/ui-egui/src/brush_live.rs index 1d31d44d28..19d25f2a8f 100644 --- a/crates/ui-egui/src/brush_live.rs +++ b/crates/ui-egui/src/brush_live.rs @@ -9,7 +9,7 @@ use egui::{Color32, ColorImage, Pos2, Rect, TextureHandle, TextureOptions, pos2}; use lightcraft_geom::Point; -use lightcraft_pipeline::masks::{accumulate, dab_alpha, pressure_flow, pressure_radius, push_dabs_counted, push_pressures}; +use lightcraft_pipeline::masks::{accumulate, dab_alpha, pressure_flow, pressure_radius, push_dabs_counted, push_pressures, travel_flow}; /// The largest live-stroke buffer edge (pixels); a bigger canvas is painted at a lower resolution. const MAX_SIDE: usize = 4096; @@ -28,6 +28,9 @@ pub struct LiveParams { /// Flow and density, 0..1. pub flow: f32, pub density: f32, + /// Flow is coverage per brush radius travelled (process V8, `masks::flow_per_radius`), as the + /// committed stroke paints it. + pub per_radius: bool, /// Overlay colour and its opacity (0..1) at full coverage. pub color: [u8; 3], pub opacity: f32, @@ -46,6 +49,8 @@ pub struct LiveStroke { last: Option, /// The pen pressure of the last stamped sample. last_pressure: f32, + /// The last dab painted (buffer pixels): how far the next one travelled. + last_dab: Option, /// Buffer pixels painted since the last upload: (x0, y0, x1, y1), exclusive ends. dirty: Option<(usize, usize, usize, usize)>, texture: Option, @@ -56,7 +61,19 @@ impl LiveStroke { let scale = buffer_scale(params.clip, params.scale); let params = LiveParams { scale, ..params }; let (w, h) = buffer_size(params.clip, scale); - LiveStroke { params, w, h, alpha: vec![0.0; w * h], placed: 0, emitted: 0, last: None, last_pressure: 1.0, dirty: None, texture: None } + LiveStroke { + params, + w, + h, + alpha: vec![0.0; w * h], + placed: 0, + emitted: 0, + last: None, + last_pressure: 1.0, + last_dab: None, + dirty: None, + texture: None, + } } /// Stroke coverage (0..1) at buffer pixel `(x, y)`; 0 outside. @@ -80,7 +97,7 @@ impl LiveStroke { if new.is_empty() { return false; } - let LiveParams { clip, scale, r, hard, flow, density, .. } = self.params; + let LiveParams { clip, scale, r, hard, flow, density, per_radius, .. } = self.params; let (r, hard) = ((r * scale) as f64, (hard * scale) as f64); let mut dabs = Vec::new(); let mut pressures = Vec::new(); @@ -105,6 +122,10 @@ impl LiveStroke { let r = pressure_radius(base.0, p); let hard = if base.0 > 0.0 { base.1 * r / base.0 } else { base.1 }; let flow = pressure_flow(flow, p); + // the first dab counts one radius, as the committed stroke's does + let travelled = self.last_dab.map_or(r, |a| a.dist(d)); + self.last_dab = Some(d); + let flow = if per_radius { travel_flow(flow, travelled, r) } else { flow }; let x0 = (d.x - r).floor().clamp(0.0, self.w as f64) as usize; let x1 = (d.x + r).ceil().clamp(0.0, self.w as f64) as usize; let y0 = (d.y - r).floor().clamp(0.0, self.h as f64) as usize; @@ -220,12 +241,33 @@ mod tests { hard: 5.0, flow: 1.0, density: 1.0, + per_radius: true, color: [230, 30, 40], opacity: 0.5, } } /// Issue #517: two samples far apart (a fast stroke) paint a continuous band between them, + /// Process V8: the live stroke adds Flow per brush radius travelled, as the committed one does, + /// so a slow drag (a sample every point) and a fast one cover a point the same; a stroke's centre + /// at Flow 25 is covered by 1 − 0.75² (Feather 0 here). Before V8 the slow drag built up more. + #[test] + fn flow_per_radius_does_not_depend_on_the_drag_speed() { + let p = LiveParams { flow: 0.25, hard: 10.0, ..params() }; + let paint = |per_radius: bool, step: usize| { + let mut s = LiveStroke::new(LiveParams { per_radius, ..p }); + let pts: Vec = (20..=380).step_by(step).map(|x| pos2(x as f32, 100.0)).collect(); + for n in 1..=pts.len() { + s.stamp(&pts[..n], &[]); + } + s.coverage(200, 100) + }; + let (fast, slow) = (paint(true, 360), paint(true, 1)); + assert!((fast - 0.4375).abs() < 0.03, "{fast}"); + assert!((fast - slow).abs() < 0.02, "fast {fast} vs slow {slow}"); + assert!(paint(false, 1) > paint(false, 360), "before V8 a slow drag builds up more"); + } + /// not two separate dabs. #[test] fn a_fast_segment_is_painted_continuously() { diff --git a/crates/ui-egui/src/panels/detail/masks.rs b/crates/ui-egui/src/panels/detail/masks.rs index ebcb35e611..06891373c1 100644 --- a/crates/ui-egui/src/panels/detail/masks.rs +++ b/crates/ui-egui/src/panels/detail/masks.rs @@ -716,6 +716,7 @@ fn brush_tool( hard: r * (1.0 - (app.ui.brush_feather / 100.0).clamp(0.0, 1.0)), flow: (app.ui.brush_flow / 100.0).clamp(0.0, 1.0), density: 1.0, + per_radius: lightcraft_pipeline::masks::flow_per_radius(d), color: app.ui.mask_overlay_color, opacity: opacity.clamp(0.0, 1.0), }; diff --git a/crates/ui-egui/src/tests/masking.rs b/crates/ui-egui/src/tests/masking.rs index f7fbc60536..72aa10cca6 100644 --- a/crates/ui-egui/src/tests/masking.rs +++ b/crates/ui-egui/src/tests/masking.rs @@ -2021,6 +2021,33 @@ fn a_fast_brush_stroke_shows_without_gaps_before_the_button_is_released() { } } +/// Process V8: a Flow 25 stroke shows while the button is held as it will once committed, both +/// adding Flow per brush radius travelled (#4045): partly covered along its centre, not almost fully. +#[test] +fn a_low_flow_stroke_shows_as_it_will_be_committed() { + let mut h = detail("panel.masking"); + h.settle(SETTLE); + exec(&mut h, "tool.brush", json!({"new": true})); + let r = h.request("ui.set", json!({"brushSize": 0.03, "brushFeather": 0.0, "brushFlow": 25.0}), T); + assert_eq!(r["ok"], true, "{r}"); + let y = 0.4; + let (photo, held) = hold_fast_stroke(&mut h, y); + let col = h.app.ui.mask_overlay_color.map(|v| v as f32); + let op = h.app.ui.mask_overlay_opacity / 100.0; + // the tint along the centreline: about 1 − 0.75² of full coverage, not the 90 % of a flow per dab + let cover: Vec = photo.iter().zip(&held).map(|(p, l)| (l[0] - p[0]) / ((col[0] - p[0]) * op)).collect(); + let mid = cover[cover.len() / 2]; + assert!((mid - 0.4375).abs() < 0.08, "live coverage {mid}"); + pointer(&mut h, json!([{"kind": "up", "x": 0.85, "y": y}])); + // (the committed mask's pin sits on the stroke) + h.app.ui.mask_pins = false; + h.settle(SETTLE); + let done = stroke_centreline(&h, y); + for (l, k) in held.iter().zip(&done) { + assert!((0..3).all(|i| (l[i] - k[i]).abs() < 24.0), "live {l:?} vs committed {k:?}"); + } +} + /// What the photo shows along the centreline of [`hold_fast_stroke`]'s stroke at height `y`, away /// from the cursor ring at its end. fn stroke_centreline(h: &Headless, y: f32) -> Vec<[f32; 3]> { diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 471263c055..098f54d002 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -298,7 +298,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-MASK-OBJECTS | Object selection | P2 | 🟡 | `cmd:mask.add` (`object`, `prompt`), `cmd:mask.objectPoint`, `cmd:mask.refineDetail`, `cmd:segment.prepare`, `cmd:segment.model.status`, `cmd:segment.model.download`, `cmd:segment.model.cancel`, `cmd:app.openSamModelFolder`, `crates/segment`, `crates/engine/src/segment.rs` | SAM 3 in pure Rust (candle; Metal on macOS, CPU elsewhere): Object tile → click to include, ⌥-click to leave out; Describe tile → a text prompt selects every instance ("sky", "the red car"); both also as Add/Subtract/Intersect components; + / − under the selected mask; comma lists (`car, road`); a zoomed-in detail pass for 5–10× finer edges on small objects; per-selection Edge (hard ↔ soft); the stored grid is enlarged along the photo's edges (a guided filter of its logits by log luminance, so no outline spills onto the background under a raised Exposure, #3272). The model runs on its own worker thread (the UI never waits; panics become errors; a job that fails on the Mac's GPU runs again on the CPU, which then serves the rest of the session, #1974), is unloaded after 10 min idle, and is optional: the segmentation is stored with the mask (288² logits), so renders and exports never need it. Weights are never bundled (SAM License): without them the app offers a consented background download (mirrors, resume, timeouts, SHA-256) — **but no default download location is configured yet** (users set `LIGHTCRAFT_SAM3_MIRRORS` or install by hand: the dialog names the three files, opens the configured model folder with the host opener, preserves setup on an open error, and links docs/ai-masks.md; Meta's original checkpoint installed in place of the Hugging Face one is named as such, #3378). Not verified against Lightroom's Select Object; no brush/box object mode; the first click on a photo waits for its analysis (~4 s on an M4 Pro, much longer on CPU) | | LR-MASK-PEOPLE | People parts | P2 | ⬜ | | shape exists (no UI): uses the photo's person / skin / hair / teeth / glasses mattes when it carries them (DNG semantic masks), else the subject heuristic | | LR-MASK-LANDSCAPE | Landscape classes | P2 | ⬜ | | shape exists, evaluates empty | -| LR-MASK-BRUSH | Brush mask | P0 | 🟡 | `cmd:tool.brush`, `cmd:mask.brushStroke` (`autoMask`), `crates/pipeline/src/masks.rs`, `crates/ui-egui/src/brush_live.rs` | size/feather/flow/density/erase; Create New Mask starts a separate brush in paint mode; the stroke shows while the button is held with the committed stroke's dab spacing, feather and flow, so fast strokes have no gaps (#517); with the mask overlay hidden (O / the eye, or after a mask slider hid it) or a colour overlay at opacity 0 it is not tinted while painting either, so dodging and burning is judged on the photo, and its effect shows once the stroke is committed (#2549); coverage builds up by passes, not hold time (holding the brush still adds nothing, live or committed, #518); oversized path segments skip intermediate dabs instead of allocating a million samples; Auto Mask: dabs weighted by similarity to the colour under the dab centre, refined by a guided filter on luminance (CPU + GPU); ⇧-click draws a straight stroke from where the last stroke ended (`connect`), tapering size, feather and flow from that stroke's values when they changed; no A/B brushes; pen pressure (Brush ▸ Pen Pressure, on by default; `pressure` per point in `mask.brushStroke`) scales each dab's size (a tenth to all of it) and flow, live and committed alike, where winit reports a pen force (Windows; not macOS / Linux tablets yet); no tilt | +| LR-MASK-BRUSH | Brush mask | P0 | 🟡 | `cmd:tool.brush`, `cmd:mask.brushStroke` (`autoMask`), `crates/pipeline/src/masks.rs`, `crates/ui-egui/src/brush_live.rs` | size/feather/flow/density/erase; Create New Mask starts a separate brush in paint mode; the stroke shows while the button is held with the committed stroke's dab spacing, feather and flow, so fast strokes have no gaps (#517); with the mask overlay hidden (O / the eye, or after a mask slider hid it) or a colour overlay at opacity 0 it is not tinted while painting either, so dodging and burning is judged on the photo, and its effect shows once the stroke is committed (#2549); coverage builds up by passes, not hold time (holding the brush still adds nothing, live or committed, #518); from process V8 Flow is the coverage a stroke adds per brush radius travelled, as in Lightroom Classic (a stroke's centre: 44 % at Flow 25, 75 % at 50; measured in Lightroom 41 % and 76 %), whatever the drag speed; oversized path segments skip intermediate dabs instead of allocating a million samples; Auto Mask: dabs weighted by similarity to the colour under the dab centre, refined by a guided filter on luminance (CPU + GPU); ⇧-click draws a straight stroke from where the last stroke ended (`connect`), tapering size, feather and flow from that stroke's values when they changed; no A/B brushes; pen pressure (Brush ▸ Pen Pressure, on by default; `pressure` per point in `mask.brushStroke`) scales each dab's size (a tenth to all of it) and flow, live and committed alike, where winit reports a pen force (Windows; not macOS / Linux tablets yet); no tilt | | LR-MASK-LINEAR | Linear gradient | P0 | ✅ | `cmd:tool.linear`, `cmd:mask.update`, `crates/pipeline/src/mask_space.rs` | gradients, brushes and AI selections stay on the photo's content when lens corrections, Upright, Transform or Rotate Left / Right change (`Mask.on_photo`; CPU and GPU) | | LR-MASK-RADIAL | Radial gradient | P0 | ✅ | `cmd:tool.radial`, `cmd:mask.update`, `crates/ui-egui/src/panels/detail.rs` | drag the selected ellipse's body or centre pin to move; edge grips resize, outer grip rotates; rotated and compound radial components, hidden pins, outside hit rejection and one-step undo tested | | LR-MASK-COLORRANGE | Colour range | P1 | ✅ | `cmd:mask.add` (`colorRange`), `cmd:mask.sampleColor`, `cmd:mask.update`, `crates/pipeline/src/lib.rs` (`color_range_sample`) | Color tile → click the photo to sample (⇧-click adds, up to 5; samples taken in the space the mask compares in, respecting section eyes and the requested HDR/SDR rendition), Pick button, Refine slider; at most 64 samples (`MAX_COLOR_RANGE_SAMPLES`, render cost is pixels × samples) however the mask arrives: `mask.add` / `mask.update`, a sidecar's `lc:settings`, a preset, `develop.merge`, `render --settings` or the catalog and history keep the first 64 (issue #2556) | @@ -802,6 +802,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | Date | Change | Summary | |---|---|---| +| 2026-11-10 | minor | LR-MASK-BRUSH: process V8 makes Flow coverage per brush radius travelled, as Lightroom Classic's strokes measure on a grey card, live and committed, CPU and GPU (`masks::travel_flow`; `flow_is_coverage_per_radius_travelled_as_in_lightroom`); a stroke no longer builds up more when painted slowly; status unchanged (🟡: no A/B brushes) | | 2026-11-07 | correction | Compressed ORF sensor support withdrawn pending provenance review; embedded preview fallback remains. Coverage regenerated without the removed decoder: 557 verified, 665 unverified, 187 preview-only, 37 unsupported; 94% use-weighted coverage. | | 2026-11-04 | minor | Compressed ORF support was introduced in #3775; subsequently withdrawn pending provenance review. Earlier clean-room and verification claims are withdrawn; compressed files use embedded previews when available. See [ORF status](orf-compression.md). | | 2026-10-28 | minor | KEY-HIDEPINS ✅ → 🟡: in the Masking panel an unmodified H toggles the mask pins (`view.maskPins`, the View ▸ Show Mask Pins switch) instead of opening Remove; the toggle yields only to an explicit assignment of H itself, a Remove key reassigned to anything else still opens Remove there, and outside Masking — and the full-screen preview, where no panel shows — H keeps its own binding (Remove, by default). Remove's spot pins keep ⇧H as their only hide toggle (`tests/keymap` `h_toggles_the_mask_pins_while_masking`, `a_remapped_remove_key_still_opens_remove_while_masking`, `h_still_toggles_the_pins_when_remove_moves_to_another_key`) | diff --git a/docs/process-versions.md b/docs/process-versions.md index b27367ed6f..cdf7f6c4a2 100644 --- a/docs/process-versions.md +++ b/docs/process-versions.md @@ -15,7 +15,8 @@ stronger Light sliders, issue #196) without changing a single photo someone has | **V4** | V3 plus calibrated global Contrast (per channel) and Blacks (per-channel/luminance mix) on raws with a camera tone curve. Whites behaves exactly as V2, both signs; its calibration is a planned follow-up. Other sources and local adjustments retain V2 operators. See [calibrated Light operators](light-v3.md). | | **V5** | V4 plus: a raw's tone curve rolls off into white in stops instead of reaching it within about a stop of the sensor's white, so raising Exposure keeps the highlights the sensor recorded (issue #1632). **Camera curve** (the look fitted to the embedded JPEG, or a DNG's `ProfileToneCurve`; `CameraTone`): past its last knot `CameraTone::apply_rolloff` closes the gap to white by `gap / (1 + c·(2^t − 1))` at `t` stops past the knot, with `c` matching the curve's slope there and the gap halving every stop in the end (`tone::ROLLOFF_STOPS`); `ToneMap::camera_rolloff_hdr` builds the table from it. Under V1 to V4 the curve past its last knot (fitted only to camera JPEG tones below 0.85, so 1 to 3 stops below the sensor's white on most photos) closes on white exponentially in linear light: the sensor's white renders at 8-bit 246 to 254 at Exposure 0 and 254 to 255 from Exposure +1. On the 11 CC0 corpus files with a fitted look (8 Sony, 2 Nikon, 1 Fujifilm) it now renders at 239 to 250 at Exposure 0 and 247 to 253 at +1. A DNG curve that reaches white at the sensor's white renders as before. **Generic curve** (raws without a camera curve, `ToneMap::rolloff_hdr`): from half a stop below its white point (`tone::GENERIC_KNEE_STOPS`) the same shoulder takes over, with the extended Reinhard curve's value and slope at the join, where V1 to V4 clip at the white point (scene 1.18 at default settings, ¼ stop above the sensor's white). The sensor's white renders at about 235, 248 and 252 at Exposure 0, +1 and +2 (V1 to V4: 239, 255, 255; the CC0 Canon R8 file and 6 CC0 DNGs without a camera curve). Content past the old clip point, such as a clipped sky, now renders up to 15 codes below white at Exposure 0 and reaches 255 about 5 stops past the sensor's white. Below the last knot or the join, JPEGs and other display-referred sources, and the camera fit itself are unchanged; CPU and GPU share the tone LUT. | | **V6** | V5 plus: colour noise reduction filters the linear colour differences R−Y and B−Y with the joint method (issue #815, `docs/nr-color-joint.md`): edge-aware weights from a denoised guide shared by both differences, anisotropic diffusion over scales, a brake for isolated colour specks; Y is kept exactly. V1 to V5 keep the blurred chromaticity (`local::denoise`). CPU (`local::denoise`) and GPU (`render::denoise`) branch on `local::joint_colour_nr`. Renders with Color 0 are the same as V2's. | -| **V7** (the latest) | V6 plus: film grain from crystal layers ([grain.md](grain.md), `crates/pipeline/src/crystal.rs`), after Aurélien Pierre's model: resolution independent (a preview is the export's grain box-downscaled), fading out at black and white, calibrated to Lightroom Classic's strength and width at mid grey. V1 to V6 keep their two-octave value noise exactly (`finish::ValueGrain`; on the GPU `F_GRAIN_MODEL` 0); `finish::GrainModel::new` picks the model per process. Renders without grain don't depend on this. | +| **V7** | V6 plus: film grain from crystal layers ([grain.md](grain.md), `crates/pipeline/src/crystal.rs`), after Aurélien Pierre's model: resolution independent (a preview is the export's grain box-downscaled), fading out at black and white, calibrated to Lightroom Classic's strength and width at mid grey. V1 to V6 keep their two-octave value noise exactly (`finish::ValueGrain`; on the GPU `F_GRAIN_MODEL` 0); `finish::GrainModel::new` picks the model per process. Renders without grain don't depend on this. | +| **V8** (the latest) | V7 plus: brush Flow is the coverage a stroke adds per brush radius it travels, as in Lightroom Classic (#4045): each dab adds `1 − (1 − flow)^(d / r)` for a dab `d` past the previous one (the first dab counts one radius, so a click paints its flow), `masks::travel_flow`. A point a stroke passes over for a length `L` is then covered by `1 − (1 − flow)^(L / r)` however densely the dabs lie: a straight stroke's centre by 44 % at Flow 25 and 75 % at Flow 50, where Lightroom Classic measures 41 % and 76 % on a grey card. V1 to V7 add the full flow per dab (r/4 apart on a fast drag, closer on a slow one): 90 % at Flow 25 on a fast stroke, more on a slow one. CPU (`masks::brush_dabs_within`), GPU (a flow per dab in the `shape` kernel's brush data) and the live stroke (`brush_live`) all branch on `masks::flow_per_radius`. Renders without brush masks, or with Flow 100 only, are the same as V7's. | ## The rule @@ -111,6 +112,7 @@ extra field and retain their existing cached renders. No cache-version bump is n | Date | Change | Summary | |---|---|---| +| 2026-11-10 | minor | V8: brush Flow per brush radius travelled, as in Lightroom Classic; V1 to V7 keep the flow per dab | | 2026-11-07 | minor | V7: film grain from crystal layers ([grain.md](grain.md)); V1 to V6 keep their value noise | | 2026-11-05 | minor | V5: a raw's tone curve rolls off into white in stops, so raising Exposure keeps recorded highlights (#1632) | | 2026-10-12 | minor | Calibrated Contrast and Blacks, V2 Whites, resolved-process cache keys and number coordination | diff --git a/docs/whats-new.md b/docs/whats-new.md index 56fc27ed79..dff197e848 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -2,6 +2,11 @@ ## Unreleased +### Brush Flow as in Lightroom (process V8) +- Flow now builds up the way it does in Lightroom: one stroke at Flow 25 covers a little under half, at Flow 50 about + three quarters, where it used to cover 90 % and more, and a slow stroke covers the same as a fast one (issue #4045). + New photos (and Reset) get it; photos you already edited keep their brushes until Photo ▸ Update to Current Process. + ### Film grain that looks like film (process V7) - Grain now comes from a simulated emulsion of crystal layers (after Aurélien Pierre's model): dense, soft and cloudy rather than dots on top of the photo. It fades out towards black and white as on a print, so shadows keep their depth From fb2085c77e4f53ead86c34b832bb0b31dd3d86f4 Mon Sep 17 00:00:00 2001 From: Dimitrij Denissenko Date: Tue, 10 Nov 2026 10:09:08 +0000 Subject: [PATCH 2/6] LR-MASK-BRUSH: GPU equivalence of a Flow 25 brush on process V8 (review of #4047) --- crates/gpu/tests/it/equivalence.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/gpu/tests/it/equivalence.rs b/crates/gpu/tests/it/equivalence.rs index 15550cfb74..780f31a130 100644 --- a/crates/gpu/tests/it/equivalence.rs +++ b/crates/gpu/tests/it/equivalence.rs @@ -434,6 +434,20 @@ fn cases() -> Vec<(&'static str, Edit)> { }, ]; }), + ("masks (brush, process V8: flow per radius travelled)", |s| { + s.process = lightcraft_develop::Process::V8.version(); + let stroke = BrushStroke { + points: vec![Point::new(0.1, 0.3), Point::new(0.5, 0.4), Point::new(0.8, 0.35)], + size: 0.04, + flow: 25.0, + ..Default::default() + }; + s.masks = vec![Mask { + components: vec![MaskComponent { name: None, op: MaskOp::Add, invert: false, shape: MaskShape::Brush { strokes: vec![stroke] } }], + adjust: lightcraft_develop::LocalAdjustments { exposure: -1.0, ..Default::default() }, + ..Default::default() + }]; + }), ("masks (brush, process V7: flow per dab)", |s| { s.process = lightcraft_develop::Process::V7.version(); let stroke = BrushStroke { From 368376552cb1409691a13f576062e4a64d4163de Mon Sep 17 00:00:00 2001 From: tecari0 <121329615+tecari0@users.noreply.github.com> Date: Wed, 18 Nov 2026 04:34:57 -0800 Subject: [PATCH 3/6] LR-MASK-BRUSH: a brush stroke is feathered as one dab is (process V10) A stroke accumulated every dab's falloff times its flow, and its dabs lie r/4 apart, so their soft edges piled up into a nearly hard one: at Feather 100 and Flow 100, halfway out from a straight stroke's centre line was 0.90 covered, where one dab covers 0.50. Process V10 keeps a stroke's Flow build-up (each dab that reaches a pixel adds its flow, masks::feather_dab) apart from its edge (the highest falloff of those dabs) and covers their product up to Density (masks::stroke_coverage). At Flow 100 a stroke's edge then falls off over the feather exactly as one dab's; below it the centre builds up by Flow per radius travelled (V9) whatever the feather. CPU, GPU (a 13th stroke-record word in the shape kernel) and the live stroke share the helpers. V1 to V9 render as before; Feather 0 brushes render as on V9. Stacked on #4047 (V9). Co-Authored-By: Claude Opus 5.5 --- crates/develop/src/settings.rs | 11 ++- crates/gpu/src/render.rs | 8 ++- crates/gpu/src/wgsl/mask.wgsl | 21 ++++-- crates/gpu/tests/it/equivalence.rs | 36 ++++++++++ crates/pipeline/src/finish.rs | 8 ++- crates/pipeline/src/geometry.rs | 3 + crates/pipeline/src/light_v3.rs | 2 +- crates/pipeline/src/local.rs | 2 +- crates/pipeline/src/masks.rs | 39 ++++++++++- crates/pipeline/src/masks/tests.rs | 67 ++++++++++++++++++ crates/pipeline/src/tests_grain.rs | 2 +- crates/ui-egui/src/brush_live.rs | 68 ++++++++++++++++--- crates/ui-egui/src/panels/detail/lens_blur.rs | 3 +- crates/ui-egui/src/panels/detail/masks.rs | 1 + docs/parity-checklist.md | 3 +- docs/process-versions.md | 4 +- docs/whats-new.md | 6 ++ 17 files changed, 255 insertions(+), 29 deletions(-) diff --git a/crates/develop/src/settings.rs b/crates/develop/src/settings.rs index dcb902be10..dd920fc5cb 100644 --- a/crates/develop/src/settings.rs +++ b/crates/develop/src/settings.rs @@ -106,13 +106,17 @@ pub enum Process { /// Lightroom: a dab adds `1 − (1 − flow)^(distance from the previous dab / radius)`, so a /// stroke's strength no longer depends on how densely its dabs lie; V1 to V8 add `flow` per dab. V9, + /// V9, with a brush stroke's edge feathered as one dab's is: a stroke's coverage is its Flow + /// build-up times the highest falloff of the dabs that reach a point, so overlapping dabs no + /// longer pile their soft edges up into a hard one; V1 to V9 accumulate each dab's falloff. + V10, } impl Process { /// Every process, oldest first. - pub const ALL: [Process; 9] = - [Process::V1, Process::V2, Process::V3, Process::V4, Process::V5, Process::V6, Process::V7, Process::V8, Process::V9]; - pub const LATEST: Process = Process::V9; + pub const ALL: [Process; 10] = + [Process::V1, Process::V2, Process::V3, Process::V4, Process::V5, Process::V6, Process::V7, Process::V8, Process::V9, Process::V10]; + pub const LATEST: Process = Process::V10; pub const fn version(self) -> ProcessVersion { match self { @@ -125,6 +129,7 @@ impl Process { Process::V7 => ProcessVersion(7), Process::V8 => ProcessVersion(8), Process::V9 => ProcessVersion(9), + Process::V10 => ProcessVersion(10), } } } diff --git a/crates/gpu/src/render.rs b/crates/gpu/src/render.rs index ea05b45094..b55b28642a 100644 --- a/crates/gpu/src/render.rs +++ b/crates/gpu/src/render.rs @@ -1485,12 +1485,13 @@ fn prepare(cx: &mut Cx<'_>, lin: &Buf, plan: &Plan<'_>, req: &RenderRequest, pla /// Most brush dabs the mask kernel evaluates per pixel (more: the CPU rasterizes the brush). const MAX_DABS: usize = 4096; -/// The `shape` kernel's brush data for `dabs`: stroke records (12 words: dab offset, dab count, -/// r, hard, flow, density, erase, bbox x0 y0 x1 y1, auto) then each dab's centre and the flow it +/// The `shape` kernel's brush data for `dabs`: stroke records (13 words: dab offset, dab count, +/// r, hard, flow, density, erase, bbox x0 y0 x1 y1, auto, the edge feathered by stroke (process +/// V10, [`lightcraft_pipeline::masks::stroke_feather`])) then each dab's centre and the flow it /// adds (3 words; the stroke's flow before process V9, [`lightcraft_pipeline::masks::BrushDabs::dab`]). fn brush_aux(dabs: &[&lightcraft_pipeline::masks::BrushDabs], erase: bool) -> Vec { let mut aux = Vec::new(); - let mut off = 12 * dabs.len(); + let mut off = 13 * dabs.len(); for d in dabs { let (mut x0, mut y0, mut x1, mut y1) = (f64::MAX, f64::MAX, f64::MIN, f64::MIN); for q in &d.dabs { @@ -1499,6 +1500,7 @@ fn brush_aux(dabs: &[&lightcraft_pipeline::masks::BrushDabs], erase: bool) -> Ve aux.extend([off as f32, d.dabs.len() as f32, d.r as f32, d.hard as f32, d.flow, d.density, (erase && d.erase) as u8 as f32]); aux.extend([x0, y0, x1, y1].map(|v| v as f32)); aux.push(d.auto as u8 as f32); + aux.push(d.feather_by_stroke as u8 as f32); off += 3 * d.dabs.len(); } for d in dabs { diff --git a/crates/gpu/src/wgsl/mask.wgsl b/crates/gpu/src/wgsl/mask.wgsl index e058f6bf6d..82a6838861 100644 --- a/crates/gpu/src/wgsl/mask.wgsl +++ b/crates/gpu/src/wgsl/mask.wgsl @@ -77,14 +77,16 @@ fn shape(@builtin(global_invocation_id) g: vec3) { } v = 1.0 - sstep(tol * 0.5, tol, best); } else if (kind == 4u) { - // stroke record: dab offset, dab count, r, hard, flow, density, erase, bbox x0 y0 x1 y1, auto + // stroke record: dab offset, dab count, r, hard, flow, density, erase, bbox x0 y0 x1 y1, auto, + // the edge feathered by stroke (process V10: build-up times the highest dab falloff) let px = f32(g.x) + 0.5; let py = f32(g.y) + 0.5; let lp = log_l[i]; let chp = chroma_at(i); for (var k = 0u; k < pu(10u); k++) { - let o = 12u * k; + let o = 13u * k; let auto_mask = aux[o + 11u] != 0.0; + let by_stroke = aux[o + 12u] != 0.0; if (px < aux[o + 7u] || py < aux[o + 8u] || px > aux[o + 9u] || py > aux[o + 10u]) { continue; } @@ -93,6 +95,7 @@ fn shape(@builtin(global_invocation_id) g: vec3) { let r = aux[o + 2u]; let hard = aux[o + 3u]; var keep = 1.0; + var edge = 0.0; for (var j = 0u; j < cnt; j++) { // dab record: centre x, y and the flow it adds (the stroke's before process V9) let dx = px - aux[off + 3u * j]; @@ -112,9 +115,19 @@ fn shape(@builtin(global_invocation_id) g: vec3) { let ri = ry * w + rx; a *= auto_similarity(lp, chp, log_l[ri], chroma_at(ri)); } - keep *= 1.0 - a * flow; + if (by_stroke) { + // masks::feather_dab: the build-up grows by the flow, the edge keeps the highest falloff + keep *= 1.0 - flow; + edge = max(edge, a); + } else { + keep *= 1.0 - a * flow; + } + } + var sa = min(1.0 - keep, aux[o + 5u]); + if (by_stroke) { + // masks::stroke_coverage + sa = min((1.0 - keep) * edge, aux[o + 5u]); } - let sa = min(1.0 - keep, aux[o + 5u]); if (aux[o + 6u] != 0.0) { v = v * (1.0 - sa); } else { diff --git a/crates/gpu/tests/it/equivalence.rs b/crates/gpu/tests/it/equivalence.rs index 2c4c2b1357..2b9f82ef12 100644 --- a/crates/gpu/tests/it/equivalence.rs +++ b/crates/gpu/tests/it/equivalence.rs @@ -448,6 +448,42 @@ fn cases() -> Vec<(&'static str, Edit)> { ..Default::default() }]; }), + ("masks (brush, process V10: a soft stroke feathered as one dab)", |s| { + s.process = lightcraft_develop::Process::V10.version(); + let stroke = |flow: f64, erase: bool, y: f64| BrushStroke { + points: vec![Point::new(0.1, y), Point::new(0.5, y + 0.1), Point::new(0.8, y + 0.05)], + size: 0.06, + feather: 100.0, + flow, + erase, + ..Default::default() + }; + s.masks = vec![Mask { + components: vec![MaskComponent { + name: None, + op: MaskOp::Add, + invert: false, + shape: MaskShape::Brush { strokes: vec![stroke(100.0, false, 0.3), stroke(50.0, false, 0.55), stroke(100.0, true, 0.45)] }, + }], + adjust: lightcraft_develop::LocalAdjustments { exposure: -1.0, ..Default::default() }, + ..Default::default() + }]; + }), + ("masks (brush, process V9: a soft stroke's dabs accumulated)", |s| { + s.process = lightcraft_develop::Process::V9.version(); + let stroke = BrushStroke { + points: vec![Point::new(0.1, 0.3), Point::new(0.5, 0.4), Point::new(0.8, 0.35)], + size: 0.06, + feather: 100.0, + flow: 100.0, + ..Default::default() + }; + s.masks = vec![Mask { + components: vec![MaskComponent { name: None, op: MaskOp::Add, invert: false, shape: MaskShape::Brush { strokes: vec![stroke] } }], + adjust: lightcraft_develop::LocalAdjustments { exposure: -1.0, ..Default::default() }, + ..Default::default() + }]; + }), ("masks (brush, process V8: flow per dab)", |s| { s.process = lightcraft_develop::Process::V8.version(); let stroke = BrushStroke { diff --git a/crates/pipeline/src/finish.rs b/crates/pipeline/src/finish.rs index b3d0408bc2..ce4103f805 100644 --- a/crates/pipeline/src/finish.rs +++ b/crates/pipeline/src/finish.rs @@ -148,8 +148,10 @@ impl GrainModel { seed: g.seed, }) }), - Process::V7 | Process::V8 | Process::V9 if draft => crate::crystal::CrystalGrain::draft(g, px_per_long).map(GrainModel::Crystal), - Process::V7 | Process::V8 | Process::V9 => crate::crystal::CrystalGrain::new(g, px_per_long).map(GrainModel::Crystal), + Process::V7 | Process::V8 | Process::V9 | Process::V10 if draft => { + crate::crystal::CrystalGrain::draft(g, px_per_long).map(GrainModel::Crystal) + } + Process::V7 | Process::V8 | Process::V9 | Process::V10 => crate::crystal::CrystalGrain::new(g, px_per_long).map(GrainModel::Crystal), } } } @@ -407,7 +409,7 @@ pub fn base_tone(s: &DevelopSettings, info: &SourceInfo, peak: f32) -> ToneMap { }, // V4, with a raw's tone curve rolling off into white in stops: a camera curve past its last // knot, the generic curve from half a stop below its white point instead of clipping (issue #1632) - Process::V5 | Process::V6 | Process::V7 | Process::V8 | Process::V9 => match info.camera_tone.as_ref().filter(|_| info.raw) { + Process::V5 | Process::V6 | Process::V7 | Process::V8 | Process::V9 | Process::V10 => match info.camera_tone.as_ref().filter(|_| info.raw) { Some(curve) => ToneMap::camera_rolloff_hdr(curve, 0.0, l.whites, 0.0, peak), None if info.raw => ToneMap::rolloff_hdr(l.contrast, l.whites, l.blacks, peak), None => ToneMap::display_hdr(l.contrast, l.whites, l.blacks, peak), diff --git a/crates/pipeline/src/geometry.rs b/crates/pipeline/src/geometry.rs index b51f36d233..81010e190f 100644 --- a/crates/pipeline/src/geometry.rs +++ b/crates/pipeline/src/geometry.rs @@ -40,6 +40,8 @@ pub struct Frame { /// Brush Flow is coverage per brush radius travelled (process V9, [`crate::masks::flow_per_radius`]), /// not per dab. pub brush_flow_per_radius: bool, + /// A brush stroke's edge is feathered as one dab's is (process V10, [`crate::masks::stroke_feather`]). + pub brush_stroke_feather: bool, } /// Where a windowed [`Frame`]'s pixels sit in the full output: its offset and the full output's @@ -86,6 +88,7 @@ impl Frame { view: None, masks_on_photo: false, brush_flow_per_radius: crate::masks::flow_per_radius(s), + brush_stroke_feather: crate::masks::stroke_feather(s), }; if apply_crop { f.constrain_to_image(s.geometry.constrain_crop); diff --git a/crates/pipeline/src/light_v3.rs b/crates/pipeline/src/light_v3.rs index da245e7995..ccf031ca5b 100644 --- a/crates/pipeline/src/light_v3.rs +++ b/crates/pipeline/src/light_v3.rs @@ -284,7 +284,7 @@ pub fn applies(s: &DevelopSettings, info: &SourceInfo) -> bool { let camera_look = info.raw && info.camera_tone.is_some(); match s.process.process() { Process::V1 | Process::V2 | Process::V3 => false, - Process::V4 | Process::V5 | Process::V6 | Process::V7 | Process::V8 | Process::V9 => camera_look, + Process::V4 | Process::V5 | Process::V6 | Process::V7 | Process::V8 | Process::V9 | Process::V10 => camera_look, } } diff --git a/crates/pipeline/src/local.rs b/crates/pipeline/src/local.rs index be3fb758f9..73ffe65256 100644 --- a/crates/pipeline/src/local.rs +++ b/crates/pipeline/src/local.rs @@ -375,7 +375,7 @@ pub fn base_detail_radius(px_per_long: f64) -> usize { pub fn tone_base_detail(s: &DevelopSettings, px_per_long: f64) -> usize { match s.process.process() { Process::V1 => 0, - Process::V2 | Process::V3 | Process::V4 | Process::V5 | Process::V6 | Process::V7 | Process::V8 | Process::V9 => { + Process::V2 | Process::V3 | Process::V4 | Process::V5 | Process::V6 | Process::V7 | Process::V8 | Process::V9 | Process::V10 => { base_detail_radius(px_per_long) } } diff --git a/crates/pipeline/src/masks.rs b/crates/pipeline/src/masks.rs index 2dc7e236f4..d93d7ee33a 100644 --- a/crates/pipeline/src/masks.rs +++ b/crates/pipeline/src/masks.rs @@ -520,6 +520,8 @@ pub struct BrushDabs { /// What each dab adds under process V9 ([`travel_flow`], pressure applied), parallel to `dabs`; /// empty before V9, where every dab adds the stroke's flow. pub flows: Vec, + /// The stroke's edge is feathered as one dab's is (process V10, [`stroke_feather`]). + pub feather_by_stroke: bool, } impl BrushDabs { @@ -559,6 +561,30 @@ impl BrushDabs { } } +/// Whether a brush stroke's edge is feathered as one dab's is (process V10 on): its coverage is +/// [`stroke_coverage`] of its Flow build-up and its dabs' highest falloff, not every dab's falloff +/// accumulated ([`accumulate`]), which piles the soft edges of overlapping dabs up into a hard one. +pub fn stroke_feather(s: &lightcraft_develop::DevelopSettings) -> bool { + s.process.process() >= lightcraft_develop::Process::V10 +} + +/// One dab's paint at a pixel of a stroke under [`stroke_feather`]: the Flow build-up `build` grows +/// by the dab's `flow` wherever the dab reaches, and the edge `edge` keeps the highest falloff `a`. +#[inline] +pub fn feather_dab(build: &mut f32, edge: &mut f32, a: f32, flow: f32) { + *build = accumulate(*build, 1.0, flow, 1.0); + *edge = edge.max(a); +} + +/// A stroke's coverage under [`stroke_feather`] from its Flow build-up and its edge +/// ([`feather_dab`]), up to its density. At Flow 100 the build-up is full wherever a dab reaches, +/// so a stroke's edge falls off over the feather exactly as one dab's does; below it, the build-up +/// is [`travel_flow`]'s, as under V9, shaped by the same edge. +#[inline] +pub fn stroke_coverage(build: f32, edge: f32, density: f32) -> f32 { + (build * edge).min(density) +} + /// Whether brush Flow is the coverage a stroke adds per brush radius it travels (process V9 on), as /// in Lightroom, rather than what every dab adds whatever the spacing of the dabs. pub fn flow_per_radius(s: &lightcraft_develop::DevelopSettings) -> bool { @@ -670,6 +696,7 @@ pub fn brush_dabs_within(s: &BrushStroke, frame: &Frame, w: usize, h: usize, max auto: s.auto_mask, pressure, flows: Vec::new(), + feather_by_stroke: frame.brush_stroke_feather, }; if frame.brush_flow_per_radius { bd.flow_by_travel() } else { bd } } @@ -882,6 +909,8 @@ fn rasterize_brush(strokes: &[BrushStroke], frame: &Frame, w: usize, h: usize, i let bd = brush_dabs(s, frame, w, h); let (dens, erase, auto) = (bd.density, bd.erase, bd.auto); let mut stroke_alpha = Plane::new(w, h); + // process V10: the Flow build-up goes in `stroke_alpha`, the edge in `edge` (`feather_dab`) + let mut edge = bd.feather_by_stroke.then(|| Plane::new(w, h)); for (k, d) in bd.dabs.iter().enumerate() { let (r, hard, flow) = bd.dab(k); let refc = auto.then(|| { @@ -902,11 +931,17 @@ fn rasterize_brush(strokes: &[BrushStroke], frame: &Frame, w: usize, h: usize, i a *= auto_similarity(log_l.data[i], chromaticity(img.data[i]), rl, rch); } let v = &mut stroke_alpha.data[i]; - // flow accumulates within a stroke up to density - *v = accumulate(*v, a, flow, dens); + match edge.as_mut().and_then(|e| e.data.get_mut(i)) { + Some(e) => feather_dab(v, e, a, flow), + // flow accumulates within a stroke up to density + None => *v = accumulate(*v, a, flow, dens), + } } } } + if let Some(edge) = &edge { + stroke_alpha = stroke_alpha.zip_map(edge, |b, e| stroke_coverage(b, e, dens)); + } if auto { let (sigma, eps) = auto_refine(bd.r); let q = guided_cross(log_l, &stroke_alpha, sigma, eps); diff --git a/crates/pipeline/src/masks/tests.rs b/crates/pipeline/src/masks/tests.rs index 2f125bc56f..bb1b6c7810 100644 --- a/crates/pipeline/src/masks/tests.rs +++ b/crates/pipeline/src/masks/tests.rs @@ -706,3 +706,70 @@ fn intersect_first_component_selects_its_shape() { let a = evaluate_one(&m, &f, 100, 100, &img, &l, 0.0, None); assert!(a.get(50, 50) > 0.99 && a.get(5, 5) < 0.01, "intersect first: {} {}", a.get(50, 50), a.get(5, 5)); } + +/// A straight stroke of radius 20 px along y = 50 of a 400 × 100 frame on `process`. +fn feathered_stroke(process: lightcraft_develop::Process, flow: f64, feather: f64) -> Plane { + let (w, h) = (400, 100); + let d = DevelopSettings { process: process.version(), ..Default::default() }; + let f = Frame::new(w, h, &d, true); + let s = BrushStroke { points: vec![Point::new(0.1, 0.5), Point::new(0.9, 0.5)], size: 0.05, feather, flow, ..Default::default() }; + shape_alpha(&MaskShape::Brush { strokes: vec![s] }, &f, w, h, &Rgb32f::new(w, h), &Plane::new(w, h), 0.0, None) +} + +/// Process V10: at Flow 100 a stroke's edge falls off over the feather exactly as one dab's does; +/// V1 to V9 accumulate the soft edges of overlapping dabs (r/4 apart) into a nearly hard one. +#[test] +fn a_stroke_is_feathered_as_one_dab_is() { + use lightcraft_develop::Process; + let r = 20.0; + for feather in [100.0, 50.0] { + let hard = r * (1.0 - feather / 100.0); + let new = feathered_stroke(Process::V10, 100.0, feather); + let old = feathered_stroke(Process::V9, 100.0, feather); + // rows below the line: pixel centre y + 0.5 is that far from it + for row in 50..72 { + let dd = row as f64 + 0.5 - 50.0; + let want = dab_alpha(dd, r, hard); + let got = new.get(200, row); + assert!((got - want).abs() < 0.02, "Feather {feather}: {dd} px off the line, {got} where one dab paints {want}"); + assert!(old.get(200, row) >= got - 1e-6, "V9 is never the softer"); + } + // halfway out at Feather 100 one dab paints 0.5; V9's stroke about 0.9 + if feather == 100.0 { + assert!((new.get(200, 60) - 0.5).abs() < 0.05, "{}", new.get(200, 60)); + assert!(old.get(200, 60) > 0.85, "V9 keeps its hard edge: {}", old.get(200, 60)); + } + } +} + +/// Process V10 below Flow 100: the centre builds up by Flow per radius travelled whatever the +/// feather, as a hard brush's does under V9 (`1 − (1 − flow)²` for a straight stroke, 44 % at Flow 25, +/// as Lightroom Classic measures, #4045), and the feather shapes only the edge. Under V9 a soft +/// brush's falloff also weakened its centre (25 % at Flow 25), as each dab's flow was scaled by it. +#[test] +fn below_full_flow_the_centre_builds_up_whatever_the_feather_and_the_edge_falls_off() { + use lightcraft_develop::Process; + for flow in [25.0, 50.0] { + let new = feathered_stroke(Process::V10, flow, 100.0); + let hard = feathered_stroke(Process::V10, flow, 0.0); + let want = 1.0 - (1.0 - flow as f32 / 100.0).powi(2); + let n = new.get(200, 50); + assert!((n - want).abs() < 0.03, "Flow {flow}: centre {n}, {want} by Flow per radius travelled"); + assert!((n - hard.get(200, 50)).abs() < 0.03, "Flow {flow}: as a hard brush's centre"); + for row in 51..72 { + assert!(new.get(200, row) <= new.get(200, row - 1) + 1e-6, "Flow {flow}: falls off away from the line (row {row})"); + assert!(new.get(200, row) <= hard.get(200, row) + 1e-6, "Flow {flow}: never more than the hard brush (row {row})"); + } + } + let old = feathered_stroke(Process::V9, 25.0, 100.0).get(200, 50); + assert!(old < 0.3, "V9's soft brush is weaker at its centre: {old}"); +} + +/// A hard brush (Feather 0) paints the same on V9 and V10. +#[test] +fn a_hard_brush_is_unchanged_by_the_stroke_feather() { + use lightcraft_develop::Process; + for flow in [25.0, 100.0] { + assert_eq!(feathered_stroke(Process::V10, flow, 0.0).data, feathered_stroke(Process::V9, flow, 0.0).data, "Flow {flow}"); + } +} diff --git a/crates/pipeline/src/tests_grain.rs b/crates/pipeline/src/tests_grain.rs index 4da1820d36..b9b83217be 100644 --- a/crates/pipeline/src/tests_grain.rs +++ b/crates/pipeline/src/tests_grain.rs @@ -35,7 +35,7 @@ fn processes_before_v7_keep_the_value_noise() { Process::V1 | Process::V2 | Process::V3 | Process::V4 | Process::V5 | Process::V6 => { assert!(matches!(model, Some(GrainModel::Value(_))), "{p:?}") } - Process::V7 | Process::V8 | Process::V9 => assert!(matches!(model, Some(GrainModel::Crystal(_))), "{p:?}"), + Process::V7 | Process::V8 | Process::V9 | Process::V10 => assert!(matches!(model, Some(GrainModel::Crystal(_))), "{p:?}"), } assert!(GrainModel::new(&on(p, 0.0), 2000.0, false).is_none(), "{p:?}: no grain at Amount 0"); } diff --git a/crates/ui-egui/src/brush_live.rs b/crates/ui-egui/src/brush_live.rs index 466348eb1d..7a996643f7 100644 --- a/crates/ui-egui/src/brush_live.rs +++ b/crates/ui-egui/src/brush_live.rs @@ -9,7 +9,9 @@ use egui::{Color32, ColorImage, Pos2, Rect, TextureHandle, TextureOptions, pos2}; use lightcraft_geom::Point; -use lightcraft_pipeline::masks::{accumulate, dab_alpha, pressure_flow, pressure_radius, push_dabs_counted, push_pressures, travel_flow}; +use lightcraft_pipeline::masks::{ + accumulate, dab_alpha, feather_dab, pressure_flow, pressure_radius, push_dabs_counted, push_pressures, stroke_coverage, travel_flow, +}; /// The largest live-stroke buffer edge (pixels); a bigger canvas is painted at a lower resolution. const MAX_SIDE: usize = 4096; @@ -31,6 +33,9 @@ pub struct LiveParams { /// Flow is coverage per brush radius travelled (process V9, `masks::flow_per_radius`), as the /// committed stroke paints it. pub per_radius: bool, + /// The stroke's edge is feathered as one dab's is (process V10, `masks::stroke_feather`), as + /// the committed stroke paints it. + pub by_stroke: bool, /// Overlay colour and its opacity (0..1) at full coverage. pub color: [u8; 3], pub opacity: f32, @@ -42,6 +47,9 @@ pub struct LiveStroke { w: usize, h: usize, alpha: Vec, + /// Under `by_stroke`, the Flow build-up and the edge `alpha` is made of (`masks::feather_dab`). + build: Vec, + edge: Vec, /// Samples stamped so far, and the last one (buffer pixels). placed: usize, /// Total dabs emitted across every stamp, including the first sample. @@ -66,6 +74,8 @@ impl LiveStroke { w, h, alpha: vec![0.0; w * h], + build: if params.by_stroke { vec![0.0; w * h] } else { Vec::new() }, + edge: if params.by_stroke { vec![0.0; w * h] } else { Vec::new() }, placed: 0, emitted: 0, last: None, @@ -97,7 +107,7 @@ impl LiveStroke { if new.is_empty() { return false; } - let LiveParams { clip, scale, r, hard, flow, density, per_radius, .. } = self.params; + let LiveParams { clip, scale, r, hard, flow, density, per_radius, by_stroke, .. } = self.params; let (r, hard) = ((r * scale) as f64, (hard * scale) as f64); let mut dabs = Vec::new(); let mut pressures = Vec::new(); @@ -134,13 +144,29 @@ impl LiveStroke { continue; } for y in y0..y1 { - let Some(row) = self.alpha.get_mut(y * self.w + x0..y * self.w + x1) else { continue }; - for (x, v) in (x0..x1).zip(row.iter_mut()) { - let dd = Point::new(x as f64 + 0.5, y as f64 + 0.5).dist(d); - if dd > r { - continue; + let span = y * self.w + x0..y * self.w + x1; + let Some(row) = self.alpha.get_mut(span.clone()) else { continue }; + let (build, edge) = (self.build.get_mut(span.clone()), self.edge.get_mut(span)); + match (build, edge) { + (Some(build), Some(edge)) if by_stroke => { + for (x, ((v, b), e)) in (x0..x1).zip(row.iter_mut().zip(build.iter_mut()).zip(edge.iter_mut())) { + let dd = Point::new(x as f64 + 0.5, y as f64 + 0.5).dist(d); + if dd > r { + continue; + } + feather_dab(b, e, dab_alpha(dd, r, hard), flow); + *v = stroke_coverage(*b, *e, density); + } + } + _ => { + for (x, v) in (x0..x1).zip(row.iter_mut()) { + let dd = Point::new(x as f64 + 0.5, y as f64 + 0.5).dist(d); + if dd > r { + continue; + } + *v = accumulate(*v, dab_alpha(dd, r, hard), flow, density); + } } - *v = accumulate(*v, dab_alpha(dd, r, hard), flow, density); } } self.dirty = Some(match self.dirty { @@ -242,6 +268,7 @@ mod tests { flow: 1.0, density: 1.0, per_radius: true, + by_stroke: false, color: [230, 30, 40], opacity: 0.5, } @@ -283,6 +310,31 @@ mod tests { assert_eq!(s.coverage(200, 111), 0.0); } + /// Process V10 (`by_stroke`): the live stroke's edge falls off over the feather as one dab's + /// does, as the committed stroke's does (`masks::stroke_coverage`), where accumulating every + /// dab piles the soft edges up; stamped a frame at a time it is the same. + #[test] + fn by_stroke_the_live_edge_is_feathered_as_one_dab() { + let soft = LiveParams { hard: 0.0, by_stroke: true, ..params() }; + let mut s = LiveStroke::new(soft); + s.stamp(&[pos2(20.0, 100.0), pos2(380.0, 100.0)], &[]); + for dy in 0..10 { + let want = dab_alpha(dy as f64 + 0.5, 10.0, 0.0); + let got = s.coverage(200, 100 + dy); + assert!((got - want).abs() < 0.02, "{dy} px off the line: {got}, one dab paints {want}"); + } + let mut old = LiveStroke::new(LiveParams { by_stroke: false, ..soft }); + old.stamp(&[pos2(20.0, 100.0), pos2(380.0, 100.0)], &[]); + assert!(old.coverage(200, 105) > s.coverage(200, 105) + 0.2, "{} vs {}", old.coverage(200, 105), s.coverage(200, 105)); + let pts = [pos2(30.0, 40.0), pos2(200.0, 150.0), pos2(390.0, 20.0)]; + let (mut once, mut steps) = (LiveStroke::new(LiveParams { flow: 0.4, ..soft }), LiveStroke::new(LiveParams { flow: 0.4, ..soft })); + once.stamp(&pts, &[]); + for n in 1..=pts.len() { + steps.stamp(&pts[..n], &[]); + } + assert_eq!(once.alpha, steps.alpha); + } + /// Painting the samples one frame at a time gives the same coverage as all at once (what the /// committed stroke does). #[test] diff --git a/crates/ui-egui/src/panels/detail/lens_blur.rs b/crates/ui-egui/src/panels/detail/lens_blur.rs index 1f5cf3d8d1..f57c812935 100644 --- a/crates/ui-egui/src/panels/detail/lens_blur.rs +++ b/crates/ui-egui/src/panels/detail/lens_blur.rs @@ -122,8 +122,9 @@ pub(super) fn lens_blur_brush_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui hard: r * (1.0 - (app.ui.brush_feather / 100.0).clamp(0.0, 1.0)), flow: (app.ui.brush_flow / 100.0).clamp(0.0, 1.0), density: (app.ui.lens_blur_brush_amount / 100.0).clamp(0.0, 1.0), - // (its strokes render as a mask brush does, Flow per radius travelled from V9) + // (its strokes render as a mask brush does: Flow per radius travelled from V9, the edge by stroke from V10) per_radius: lightcraft_pipeline::masks::flow_per_radius(d), + by_stroke: lightcraft_pipeline::masks::stroke_feather(d), color: if focus { [70, 200, 120] } else { [230, 70, 70] }, opacity: 0.45, }; diff --git a/crates/ui-egui/src/panels/detail/masks.rs b/crates/ui-egui/src/panels/detail/masks.rs index 5b75e31e29..e94b9d2bbb 100644 --- a/crates/ui-egui/src/panels/detail/masks.rs +++ b/crates/ui-egui/src/panels/detail/masks.rs @@ -717,6 +717,7 @@ fn brush_tool( flow: (app.ui.brush_flow / 100.0).clamp(0.0, 1.0), density: 1.0, per_radius: lightcraft_pipeline::masks::flow_per_radius(d), + by_stroke: lightcraft_pipeline::masks::stroke_feather(d), color: app.ui.mask_overlay_color, opacity: opacity.clamp(0.0, 1.0), }; diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 6738321334..bc3b2ca114 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -298,7 +298,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-MASK-OBJECTS | Object selection | P2 | 🟡 | `cmd:mask.add` (`object`, `prompt`), `cmd:mask.objectPoint`, `cmd:mask.refineDetail`, `cmd:segment.prepare`, `cmd:segment.model.status`, `cmd:segment.model.download`, `cmd:segment.model.cancel`, `cmd:app.openSamModelFolder`, `crates/segment`, `crates/engine/src/segment.rs` | SAM 3 in pure Rust (candle; Metal on macOS, CPU elsewhere): Object tile → click to include, ⌥-click to leave out; Describe tile → a text prompt selects every instance ("sky", "the red car"); both also as Add/Subtract/Intersect components; + / − under the selected mask; comma lists (`car, road`); a zoomed-in detail pass for 5–10× finer edges on small objects; per-selection Edge (hard ↔ soft); the stored grid is enlarged along the photo's edges (a guided filter of its logits by log luminance, so no outline spills onto the background under a raised Exposure, #3272). The model runs on its own worker thread (the UI never waits; panics become errors; a job that fails on the Mac's GPU runs again on the CPU, which then serves the rest of the session, #1974), is unloaded after 10 min idle, and is optional: the segmentation is stored with the mask (288² logits), so renders and exports never need it. Weights are never bundled (SAM License): without them the app offers a consented background download (mirrors, resume, timeouts, SHA-256) — **but no default download location is configured yet** (users set `LIGHTCRAFT_SAM3_MIRRORS` or install by hand: the dialog names the three files, opens the configured model folder with the host opener, preserves setup on an open error, and links docs/ai-masks.md; Meta's original checkpoint installed in place of the Hugging Face one is named as such, #3378). Not verified against Lightroom's Select Object; no brush/box object mode; the first click on a photo waits for its analysis (~4 s on an M4 Pro, much longer on CPU) | | LR-MASK-PEOPLE | People parts | P2 | ⬜ | | shape exists (no UI): uses the photo's person / skin / hair / teeth / glasses mattes when it carries them (DNG semantic masks), else the subject heuristic | | LR-MASK-LANDSCAPE | Landscape classes | P2 | ⬜ | | shape exists, evaluates empty | -| LR-MASK-BRUSH | Brush mask | P0 | 🟡 | `cmd:tool.brush`, `cmd:mask.brushStroke` (`autoMask`), `crates/pipeline/src/masks.rs`, `crates/ui-egui/src/brush_live.rs` | size/feather/flow/density/erase; Create New Mask starts a separate brush in paint mode; the stroke shows while the button is held with the committed stroke's dab spacing, feather and flow, so fast strokes have no gaps (#517); with the mask overlay hidden (O / the eye, or after a mask slider hid it) or a colour overlay at opacity 0 it is not tinted while painting either, so dodging and burning is judged on the photo, and its effect shows once the stroke is committed (#2549); coverage builds up by passes, not hold time (holding the brush still adds nothing, live or committed, #518); from process V9 Flow is the coverage a stroke adds per brush radius travelled, as in Lightroom Classic (a stroke's centre: 44 % at Flow 25, 75 % at 50; measured in Lightroom 41 % and 76 %), whatever the drag speed; oversized path segments skip intermediate dabs instead of allocating a million samples; Auto Mask: dabs weighted by similarity to the colour under the dab centre, refined by a guided filter on luminance (CPU + GPU); ⇧-click draws a straight stroke from where the last stroke ended (`connect`), tapering size, feather and flow from that stroke's values when they changed; no A/B brushes; pen pressure (Brush ▸ Pen Pressure, on by default; `pressure` per point in `mask.brushStroke`) scales each dab's size (a tenth to all of it) and flow, live and committed alike, where winit reports a pen force (Windows; not macOS / Linux tablets yet); no tilt | +| LR-MASK-BRUSH | Brush mask | P0 | 🟡 | `cmd:tool.brush`, `cmd:mask.brushStroke` (`autoMask`), `crates/pipeline/src/masks.rs`, `crates/ui-egui/src/brush_live.rs` | size/feather/flow/density/erase; a stroke's edge falls off over its Feather as one dab's does (process V10, `masks::stroke_coverage`; V1 to V9 pile overlapping soft edges up); Create New Mask starts a separate brush in paint mode; the stroke shows while the button is held with the committed stroke's dab spacing, feather and flow, so fast strokes have no gaps (#517); with the mask overlay hidden (O / the eye, or after a mask slider hid it) or a colour overlay at opacity 0 it is not tinted while painting either, so dodging and burning is judged on the photo, and its effect shows once the stroke is committed (#2549); coverage builds up by passes, not hold time (holding the brush still adds nothing, live or committed, #518); from process V9 Flow is the coverage a stroke adds per brush radius travelled, as in Lightroom Classic (a stroke's centre: 44 % at Flow 25, 75 % at 50; measured in Lightroom 41 % and 76 %), whatever the drag speed; oversized path segments skip intermediate dabs instead of allocating a million samples; Auto Mask: dabs weighted by similarity to the colour under the dab centre, refined by a guided filter on luminance (CPU + GPU); ⇧-click draws a straight stroke from where the last stroke ended (`connect`), tapering size, feather and flow from that stroke's values when they changed; no A/B brushes; pen pressure (Brush ▸ Pen Pressure, on by default; `pressure` per point in `mask.brushStroke`) scales each dab's size (a tenth to all of it) and flow, live and committed alike, where winit reports a pen force (Windows; not macOS / Linux tablets yet); no tilt | | LR-MASK-LINEAR | Linear gradient | P0 | ✅ | `cmd:tool.linear`, `cmd:mask.update`, `crates/pipeline/src/mask_space.rs` | gradients, brushes and AI selections stay on the photo's content when lens corrections, Upright, Transform or Rotate Left / Right change (`Mask.on_photo`; CPU and GPU) | | LR-MASK-RADIAL | Radial gradient | P0 | ✅ | `cmd:tool.radial`, `cmd:mask.update`, `crates/ui-egui/src/panels/detail.rs` | drag the selected ellipse's body or centre pin to move; edge grips resize, outer grip rotates; rotated and compound radial components, hidden pins, outside hit rejection and one-step undo tested | | LR-MASK-COLORRANGE | Colour range | P1 | ✅ | `cmd:mask.add` (`colorRange`), `cmd:mask.sampleColor`, `cmd:mask.update`, `crates/pipeline/src/lib.rs` (`color_range_sample`) | Color tile → click the photo to sample (⇧-click adds, up to 5; samples taken in the space the mask compares in, respecting section eyes and the requested HDR/SDR rendition), Pick button, Refine slider; at most 64 samples (`MAX_COLOR_RANGE_SAMPLES`, render cost is pixels × samples) however the mask arrives: `mask.add` / `mask.update`, a sidecar's `lc:settings`, a preset, `develop.merge`, `render --settings` or the catalog and history keep the first 64 (issue #2556) | @@ -803,6 +803,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | Date | Change | Summary | |---|---|---| | 2026-11-10 | minor | LR-MASK-BRUSH: process V9 makes Flow coverage per brush radius travelled, as Lightroom Classic's strokes measure on a grey card, live and committed, CPU and GPU (`masks::travel_flow`; `flow_is_coverage_per_radius_travelled_as_in_lightroom`); a stroke no longer builds up more when painted slowly; status unchanged (🟡: no A/B brushes) | +| 2026-11-17 | minor | LR-MASK-BRUSH: a stroke's edge is feathered as one dab's is (process V10); status unchanged | | 2026-11-07 | correction | Compressed ORF sensor support withdrawn pending provenance review; embedded preview fallback remains. Coverage regenerated without the removed decoder: 557 verified, 665 unverified, 187 preview-only, 37 unsupported; 94% use-weighted coverage. | | 2026-11-05 | minor | LR-EDIT-LENSBLUR: ⬜ → 🟡 (Lens Blur section: Apply, Blur Amount, Boost, focus on the subject or a mask; no depth map yet); LR-MASK-SLIDERS: a Lens Blur block in every mask (selection or outside, Amount, Boost, Transition); KEY-SECTIONS: ⌘6 opens Lens Blur | | 2026-11-04 | minor | Compressed ORF support was introduced in #3775; subsequently withdrawn pending provenance review. Earlier clean-room and verification claims are withdrawn; compressed files use embedded previews when available. See [ORF status](orf-compression.md). | diff --git a/docs/process-versions.md b/docs/process-versions.md index 78ee0b30c0..479dd7bdda 100644 --- a/docs/process-versions.md +++ b/docs/process-versions.md @@ -17,7 +17,8 @@ stronger Light sliders, issue #196) without changing a single photo someone has | **V6** | V5 plus: colour noise reduction filters the linear colour differences R−Y and B−Y with the joint method (issue #815, `docs/nr-color-joint.md`): edge-aware weights from a denoised guide shared by both differences, anisotropic diffusion over scales, a brake for isolated colour specks; Y is kept exactly. V1 to V5 keep the blurred chromaticity (`local::denoise`). CPU (`local::denoise`) and GPU (`render::denoise`) branch on `local::joint_colour_nr`. Renders with Color 0 are the same as V2's. | | **V7** | V6 plus: film grain from crystal layers ([grain.md](grain.md), `crates/pipeline/src/crystal.rs`), after Aurélien Pierre's model: resolution independent (a preview is the export's grain box-downscaled), fading out at black and white, calibrated to Lightroom Classic's strength and width at mid grey. V1 to V6 keep their two-octave value noise exactly (`finish::ValueGrain`; on the GPU `F_GRAIN_MODEL` 0); `finish::GrainModel::new` picks the model per process. Renders without grain don't depend on this. | | **V8** | V7 plus: Highlights and Shadows take their edge-aware filter of log luminance without its fine detail (`local::detail_free`: each value clamped between its separable median at the V2 radius and the median of a 3× wider neighbourhood) instead of V2's plain median (`local::base_keeps_gaps`), so the gaps in dark lettering on a bright panel are not lifted into bright blocks (issue #3460). CPU (`local::tone_base`) and GPU (`render::tone_base`) branch on it; the base plane is keyed by process. Renders without Highlights or Shadows (global or local) are the same as V7's. | -| **V9** (the latest) | V8 plus: brush Flow is the coverage a stroke adds per brush radius it travels, as in Lightroom Classic (#4045): each dab adds `1 − (1 − flow)^(d / r)` for a dab `d` past the previous one (the first dab counts one radius, so a click paints its flow), `masks::travel_flow`. A point a stroke passes over for a length `L` is then covered by `1 − (1 − flow)^(L / r)` however densely the dabs lie: a straight stroke's centre by 44 % at Flow 25 and 75 % at Flow 50, where Lightroom Classic measures 41 % and 76 % on a grey card. V1 to V8 add the full flow per dab (r/4 apart on a fast drag, closer on a slow one): 90 % at Flow 25 on a fast stroke, more on a slow one. CPU (`masks::brush_dabs_within`), GPU (a flow per dab in the `shape` kernel's brush data) and the live stroke (`brush_live`) all branch on `masks::flow_per_radius`. Renders without brush masks, or with Flow 100 only, are the same as V8's. | +| **V9** | V8 plus: brush Flow is the coverage a stroke adds per brush radius it travels, as in Lightroom Classic (#4045): each dab adds `1 − (1 − flow)^(d / r)` for a dab `d` past the previous one (the first dab counts one radius, so a click paints its flow), `masks::travel_flow`. A point a stroke passes over for a length `L` is then covered by `1 − (1 − flow)^(L / r)` however densely the dabs lie: a straight stroke's centre by 44 % at Flow 25 and 75 % at Flow 50, where Lightroom Classic measures 41 % and 76 % on a grey card. V1 to V8 add the full flow per dab (r/4 apart on a fast drag, closer on a slow one): 90 % at Flow 25 on a fast stroke, more on a slow one. CPU (`masks::brush_dabs_within`), GPU (a flow per dab in the `shape` kernel's brush data) and the live stroke (`brush_live`) all branch on `masks::flow_per_radius`. Renders without brush masks, or with Flow 100 only, are the same as V8's. | +| **V10** (the latest) | V9 plus: a brush stroke's edge is feathered as one dab's is. Each stroke keeps its Flow build-up (every dab that reaches a pixel adds its flow, `masks::feather_dab`) apart from its edge (the highest falloff of those dabs), and covers their product up to Density (`masks::stroke_coverage`). V1 to V9 accumulate each dab's falloff times its flow, so the soft edges of dabs r/4 apart piled up: at Feather 100 and Flow 100 a straight stroke covered 0.90 halfway out from its centre line, where one dab covers 0.50; V10 covers 0.50. Below Flow 100 the centre now builds up by Flow per radius travelled whatever the Feather (a straight stroke's 44 % at Flow 25), where V9 also weakened a soft brush's centre (25 %). CPU (`masks::rasterize_brush`), GPU (a stroke-record word in the `shape` kernel's brush data) and the live stroke (`brush_live`) branch on `masks::stroke_feather`. Renders without brush masks, or with Feather 0 brushes only, are the same as V9's. | ## The rule @@ -127,6 +128,7 @@ extra field and retain their existing cached renders. No cache-version bump is n | Date | Change | Summary | |---|---|---| +| 2026-11-17 | minor | V10: a brush stroke's edge is feathered as one dab's is; V1 to V9 keep the accumulated soft edges | | 2026-11-11 | minor | V9: brush Flow per brush radius travelled, as in Lightroom Classic; V1 to V8 keep the flow per dab | | 2026-11-08 | minor | V8: the Highlights/Shadows base keeps the gaps in dark lettering (#3460) | | 2026-11-07 | minor | V7: film grain from crystal layers ([grain.md](grain.md)); V1 to V6 keep their value noise | diff --git a/docs/whats-new.md b/docs/whats-new.md index bd33f1a6ba..221672c6b0 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -2,6 +2,12 @@ ## Unreleased +### Brush Feather works on strokes (process V10) +- A brush stroke's edge now fades over the Feather you set. Overlapping dabs used to pile their soft edges up into an + almost hard one: at Feather 100, halfway out from a stroke's centre line was 90 % covered, and is now 50 %, as one + dab is. A soft brush at low Flow also builds up at its centre as a hard one does. New photos (and Reset) get it; + photos you already edited keep their brushes until Photo ▸ Update to Current Process. + ### Brush Flow as in Lightroom (process V9) - Flow now builds up the way it does in Lightroom: one stroke at Flow 25 covers a little under half, at Flow 50 about three quarters, where it used to cover 90 % and more, and a slow stroke covers the same as a fast one (issue #4045). From 115bace396b3f3c460f6573362caca0958e49f8d Mon Sep 17 00:00:00 2001 From: tecari0 <121329615+tecari0@users.noreply.github.com> Date: Wed, 18 Nov 2026 18:44:56 -0800 Subject: [PATCH 4/6] LR-MASK-BRUSH: V10 review fixes (no-Flow dabs, stroke bounds, Auto Mask) - A dab with no Flow (at pen pressure 0) no longer sets the stroke's edge: it could make a light pen stroke stronger. - The edge plane covers only the stroke's bounds and is combined in place, instead of a full-frame plane per stroke (about 92 MiB on 24 MP). - Auto Mask strokes keep V9's accumulation: their edge follows the photo's, not the feather, and V10's build-up made their colour weighting count for far dabs too (a rejected dab added Flow, and a window render drifted from the whole frame by up to 10 LSB). - whats-new and the LR-MASK-BRUSH row say the 90 % to 50 % example is at Flow 100, and that Auto Mask strokes are unchanged. Co-Authored-By: Claude Opus 5.5 --- crates/gpu/src/wgsl/mask.wgsl | 14 ++++-- crates/gpu/tests/it/equivalence.rs | 16 ++++++ crates/pipeline/src/masks.rs | 59 +++++++++++++++++------ crates/pipeline/src/masks/tests.rs | 57 ++++++++++++++++++++++ crates/ui-egui/src/panels/detail/masks.rs | 3 +- crates/ui-egui/src/tests/masking.rs | 5 +- docs/parity-checklist.md | 2 +- docs/process-versions.md | 2 +- docs/whats-new.md | 5 +- 9 files changed, 137 insertions(+), 26 deletions(-) diff --git a/crates/gpu/src/wgsl/mask.wgsl b/crates/gpu/src/wgsl/mask.wgsl index 82a6838861..5aeaa5f447 100644 --- a/crates/gpu/src/wgsl/mask.wgsl +++ b/crates/gpu/src/wgsl/mask.wgsl @@ -109,18 +109,22 @@ fn shape(@builtin(global_invocation_id) g: vec3) { if (dd > hard) { a = 1.0 - sstep(hard, r, dd); } + var sim = 1.0; if (auto_mask) { let rx = min(u32(max(floor(aux[off + 3u * j]), 0.0)), w - 1u); let ry = min(u32(max(floor(aux[off + 3u * j + 1u]), 0.0)), h - 1u); let ri = ry * w + rx; - a *= auto_similarity(lp, chp, log_l[ri], chroma_at(ri)); + sim = auto_similarity(lp, chp, log_l[ri], chroma_at(ri)); } if (by_stroke) { - // masks::feather_dab: the build-up grows by the flow, the edge keeps the highest falloff - keep *= 1.0 - flow; - edge = max(edge, a); + // masks::feather_dab (never an Auto Mask stroke): the build-up grows by the flow, + // the edge keeps the highest falloff; a dab with no Flow changes neither + if (flow > 0.0) { + keep *= 1.0 - flow; + edge = max(edge, a); + } } else { - keep *= 1.0 - a * flow; + keep *= 1.0 - a * sim * flow; } } var sa = min(1.0 - keep, aux[o + 5u]); diff --git a/crates/gpu/tests/it/equivalence.rs b/crates/gpu/tests/it/equivalence.rs index 2b9f82ef12..3d130d4300 100644 --- a/crates/gpu/tests/it/equivalence.rs +++ b/crates/gpu/tests/it/equivalence.rs @@ -469,6 +469,22 @@ fn cases() -> Vec<(&'static str, Edit)> { ..Default::default() }]; }), + ("masks (brush, process V10: an Auto Mask stroke keeps V9 accumulation)", |s| { + s.process = lightcraft_develop::Process::V10.version(); + let stroke = BrushStroke { + points: vec![Point::new(0.1, 0.3), Point::new(0.5, 0.45), Point::new(0.85, 0.4)], + size: 0.06, + feather: 100.0, + flow: 40.0, + auto_mask: true, + ..Default::default() + }; + s.masks = vec![Mask { + components: vec![MaskComponent { name: None, op: MaskOp::Add, invert: false, shape: MaskShape::Brush { strokes: vec![stroke] } }], + adjust: lightcraft_develop::LocalAdjustments { exposure: -1.0, ..Default::default() }, + ..Default::default() + }]; + }), ("masks (brush, process V9: a soft stroke's dabs accumulated)", |s| { s.process = lightcraft_develop::Process::V9.version(); let stroke = BrushStroke { diff --git a/crates/pipeline/src/masks.rs b/crates/pipeline/src/masks.rs index d93d7ee33a..2295390fe2 100644 --- a/crates/pipeline/src/masks.rs +++ b/crates/pipeline/src/masks.rs @@ -520,7 +520,9 @@ pub struct BrushDabs { /// What each dab adds under process V9 ([`travel_flow`], pressure applied), parallel to `dabs`; /// empty before V9, where every dab adds the stroke's flow. pub flows: Vec, - /// The stroke's edge is feathered as one dab's is (process V10, [`stroke_feather`]). + /// The stroke's edge is feathered as one dab's is (process V10, [`stroke_feather`]), unless it + /// is an Auto Mask stroke: its edge follows the photo's, not the feather, and it keeps V9's + /// accumulation, which its colour weighting stays stable under. pub feather_by_stroke: bool, } @@ -569,11 +571,16 @@ pub fn stroke_feather(s: &lightcraft_develop::DevelopSettings) -> bool { } /// One dab's paint at a pixel of a stroke under [`stroke_feather`]: the Flow build-up `build` grows -/// by the dab's `flow` wherever the dab reaches, and the edge `edge` keeps the highest falloff `a`. +/// by the dab's `flow` wherever the dab reaches, and the edge `edge` keeps the highest falloff +/// `falloff`. A dab with no Flow (at pen pressure 0) paints nothing and shapes nothing. (Auto Mask +/// strokes don't take this: [`BrushDabs::feather_by_stroke`].) #[inline] -pub fn feather_dab(build: &mut f32, edge: &mut f32, a: f32, flow: f32) { +pub fn feather_dab(build: &mut f32, edge: &mut f32, falloff: f32, flow: f32) { + if flow.is_nan() || flow <= 0.0 { + return; + } *build = accumulate(*build, 1.0, flow, 1.0); - *edge = edge.max(a); + *edge = edge.max(falloff); } /// A stroke's coverage under [`stroke_feather`] from its Flow build-up and its edge @@ -696,7 +703,7 @@ pub fn brush_dabs_within(s: &BrushStroke, frame: &Frame, w: usize, h: usize, max auto: s.auto_mask, pressure, flows: Vec::new(), - feather_by_stroke: frame.brush_stroke_feather, + feather_by_stroke: frame.brush_stroke_feather && !s.auto_mask, }; if frame.brush_flow_per_radius { bd.flow_by_travel() } else { bd } } @@ -898,6 +905,21 @@ fn guided_cross_fast(guide: &Plane, p: &mut Plane, sigma: f32, eps: f32, weight: }); } +/// The pixels stroke `bd`'s dabs can reach in a `w × h` output, `(x0, y0, x1, y1)` (end +/// exclusive, empty when it has no dabs): its dabs' centres ± its radius (pen pressure only shrinks it). +fn stroke_bounds(bd: &BrushDabs, w: usize, h: usize) -> (usize, usize, usize, usize) { + let (mut x0, mut y0, mut x1, mut y1) = (f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY); + for d in bd.dabs.iter().filter(|d| d.x.is_finite() && d.y.is_finite()) { + (x0, y0, x1, y1) = (x0.min(d.x - bd.r), y0.min(d.y - bd.r), x1.max(d.x + bd.r), y1.max(d.y + bd.r)); + } + if x0 > x1 || y0 > y1 { + return (0, 0, 0, 0); + } + let clip = |v: f64, n: usize| v.clamp(0.0, n as f64) as usize; + let (x0, y0) = (clip(x0.floor(), w), clip(y0.floor(), h)); + (x0, y0, clip(x1.ceil(), w).max(x0), clip(y1.ceil(), h).max(y0)) +} + /// Stamp brush strokes into `out` (max-combine; erase strokes subtract). Auto Mask strokes weight /// each dab by [`auto_similarity`] to the pixel under its centre and are refined with /// [`guided_cross`] on log luminance. @@ -910,7 +932,9 @@ fn rasterize_brush(strokes: &[BrushStroke], frame: &Frame, w: usize, h: usize, i let (dens, erase, auto) = (bd.density, bd.erase, bd.auto); let mut stroke_alpha = Plane::new(w, h); // process V10: the Flow build-up goes in `stroke_alpha`, the edge in `edge` (`feather_dab`) - let mut edge = bd.feather_by_stroke.then(|| Plane::new(w, h)); + // (the edge plane covers only the stroke's bounds: a short stroke on a big render is small) + let bounds = stroke_bounds(&bd, w, h); + let mut edge = bd.feather_by_stroke.then(|| Plane::new(bounds.2 - bounds.0, bounds.3 - bounds.1)); for (k, d) in bd.dabs.iter().enumerate() { let (r, hard, flow) = bd.dab(k); let refc = auto.then(|| { @@ -925,22 +949,29 @@ fn rasterize_brush(strokes: &[BrushStroke], frame: &Frame, w: usize, h: usize, i if dd > r { continue; } - let mut a = dab_alpha(dd, r, hard); let i = y * w + x; - if let Some((rl, rch)) = refc { - a *= auto_similarity(log_l.data[i], chromaticity(img.data[i]), rl, rch); - } + let sim = refc.map_or(1.0, |(rl, rch)| auto_similarity(log_l.data[i], chromaticity(img.data[i]), rl, rch)); + let falloff = dab_alpha(dd, r, hard); let v = &mut stroke_alpha.data[i]; - match edge.as_mut().and_then(|e| e.data.get_mut(i)) { - Some(e) => feather_dab(v, e, a, flow), + let ei = y.saturating_sub(bounds.1) * (bounds.2 - bounds.0) + x.saturating_sub(bounds.0); + match edge.as_mut().and_then(|e| e.data.get_mut(ei)) { + Some(e) => feather_dab(v, e, falloff, flow), // flow accumulates within a stroke up to density - None => *v = accumulate(*v, a, flow, dens), + None => *v = accumulate(*v, falloff * sim, flow, dens), } } } } if let Some(edge) = &edge { - stroke_alpha = stroke_alpha.zip_map(edge, |b, e| stroke_coverage(b, e, dens)); + // in place, within the bounds (outside them nothing was painted) + let ew = bounds.2 - bounds.0; + for y in bounds.1..bounds.3 { + for x in bounds.0..bounds.2 { + if let (Some(v), Some(e)) = (stroke_alpha.data.get_mut(y * w + x), edge.data.get((y - bounds.1) * ew + (x - bounds.0))) { + *v = stroke_coverage(*v, *e, dens); + } + } + } } if auto { let (sigma, eps) = auto_refine(bd.r); diff --git a/crates/pipeline/src/masks/tests.rs b/crates/pipeline/src/masks/tests.rs index bb1b6c7810..04bfc4dc31 100644 --- a/crates/pipeline/src/masks/tests.rs +++ b/crates/pipeline/src/masks/tests.rs @@ -773,3 +773,60 @@ fn a_hard_brush_is_unchanged_by_the_stroke_feather() { assert_eq!(feathered_stroke(Process::V10, flow, 0.0).data, feathered_stroke(Process::V9, flow, 0.0).data, "Flow {flow}"); } } + +/// Process V10: a dab with no Flow (pen pressure 0) neither builds up nor sets the edge. +#[test] +fn a_dab_with_no_flow_shapes_nothing() { + let (mut build, mut edge) = (0.2, 0.3); + feather_dab(&mut build, &mut edge, 1.0, 0.0); + assert_eq!((build, edge), (0.2, 0.3)); + feather_dab(&mut build, &mut edge, 0.6, 0.5); + assert!((build - 0.6).abs() < 1e-6 && (edge - 0.6).abs() < 1e-6, "{build} {edge}"); +} + +/// An Auto Mask stroke keeps V9's accumulation on V10: its edge follows the photo, not the feather. +#[test] +fn an_auto_mask_stroke_keeps_v9_accumulation() { + use lightcraft_develop::Process; + let (w, h) = (400, 100); + let img = Rgb32f::new(w, h); + let paint = |p: Process| { + let d = DevelopSettings { process: p.version(), ..Default::default() }; + let f = Frame::new(w, h, &d, true); + let s = BrushStroke { + points: vec![Point::new(0.1, 0.5), Point::new(0.9, 0.5)], + size: 0.05, + feather: 100.0, + auto_mask: true, + ..Default::default() + }; + assert!(!brush_dabs(&s, &f, w, h).feather_by_stroke); + shape_alpha(&MaskShape::Brush { strokes: vec![s] }, &f, w, h, &img, &Plane::new(w, h), 0.0, None) + }; + assert_eq!(paint(Process::V10).data, paint(Process::V9).data); +} + +/// Process V10's edge plane covers only the stroke's bounds: a stroke across the corner of the +/// frame and one in the middle paint as a full-frame plane would (nothing outside the bounds). +#[test] +fn the_stroke_bounds_hold_every_dab() { + let (w, h) = (400, 100); + let d = DevelopSettings::default(); + let f = Frame::new(w, h, &d, true); + for points in [vec![Point::new(-0.05, -0.1), Point::new(0.1, 0.2)], vec![Point::new(0.4, 0.5), Point::new(0.6, 0.55)]] { + let s = BrushStroke { points, size: 0.05, feather: 100.0, ..Default::default() }; + let bd = brush_dabs(&s, &f, w, h); + let (x0, y0, x1, y1) = stroke_bounds(&bd, w, h); + assert!(x0 <= x1 && y0 <= y1 && x1 <= w && y1 <= h); + let a = shape_alpha(&MaskShape::Brush { strokes: vec![s] }, &f, w, h, &Rgb32f::new(w, h), &Plane::new(w, h), 0.0, None); + for y in 0..h { + for x in 0..w { + if !(x0..x1).contains(&x) || !(y0..y1).contains(&y) { + assert_eq!(a.get(x, y), 0.0, "({x}, {y}) outside {:?}", (x0, y0, x1, y1)); + } + } + } + assert!(a.data.iter().any(|v| *v > 0.5), "it painted"); + } + assert_eq!(stroke_bounds(&brush_dabs(&BrushStroke::default(), &f, w, h), w, h), (0, 0, 0, 0), "no dabs"); +} diff --git a/crates/ui-egui/src/panels/detail/masks.rs b/crates/ui-egui/src/panels/detail/masks.rs index e94b9d2bbb..effb141f27 100644 --- a/crates/ui-egui/src/panels/detail/masks.rs +++ b/crates/ui-egui/src/panels/detail/masks.rs @@ -717,7 +717,8 @@ fn brush_tool( flow: (app.ui.brush_flow / 100.0).clamp(0.0, 1.0), density: 1.0, per_radius: lightcraft_pipeline::masks::flow_per_radius(d), - by_stroke: lightcraft_pipeline::masks::stroke_feather(d), + // (an Auto Mask stroke keeps V9's accumulation, as the committed one does) + by_stroke: lightcraft_pipeline::masks::stroke_feather(d) && !app.ui.brush_auto_mask, color: app.ui.mask_overlay_color, opacity: opacity.clamp(0.0, 1.0), }; diff --git a/crates/ui-egui/src/tests/masking.rs b/crates/ui-egui/src/tests/masking.rs index 3b4559c9a7..4246b79260 100644 --- a/crates/ui-egui/src/tests/masking.rs +++ b/crates/ui-egui/src/tests/masking.rs @@ -2021,8 +2021,9 @@ fn a_fast_brush_stroke_shows_without_gaps_before_the_button_is_released() { } } -/// Process V9: a Flow 25 stroke shows while the button is held as it will once committed, both -/// adding Flow per brush radius travelled (#4045): partly covered along its centre, not almost fully. +/// Process V9 (and V10, the same for this Feather 0 brush): a Flow 25 stroke shows while the button +/// is held as it will once committed, both adding Flow per brush radius travelled (#4045): partly +/// covered along its centre, not almost fully. #[test] fn a_low_flow_stroke_shows_as_it_will_be_committed() { let mut h = detail("panel.masking"); diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index bc3b2ca114..7f416dc499 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -298,7 +298,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-MASK-OBJECTS | Object selection | P2 | 🟡 | `cmd:mask.add` (`object`, `prompt`), `cmd:mask.objectPoint`, `cmd:mask.refineDetail`, `cmd:segment.prepare`, `cmd:segment.model.status`, `cmd:segment.model.download`, `cmd:segment.model.cancel`, `cmd:app.openSamModelFolder`, `crates/segment`, `crates/engine/src/segment.rs` | SAM 3 in pure Rust (candle; Metal on macOS, CPU elsewhere): Object tile → click to include, ⌥-click to leave out; Describe tile → a text prompt selects every instance ("sky", "the red car"); both also as Add/Subtract/Intersect components; + / − under the selected mask; comma lists (`car, road`); a zoomed-in detail pass for 5–10× finer edges on small objects; per-selection Edge (hard ↔ soft); the stored grid is enlarged along the photo's edges (a guided filter of its logits by log luminance, so no outline spills onto the background under a raised Exposure, #3272). The model runs on its own worker thread (the UI never waits; panics become errors; a job that fails on the Mac's GPU runs again on the CPU, which then serves the rest of the session, #1974), is unloaded after 10 min idle, and is optional: the segmentation is stored with the mask (288² logits), so renders and exports never need it. Weights are never bundled (SAM License): without them the app offers a consented background download (mirrors, resume, timeouts, SHA-256) — **but no default download location is configured yet** (users set `LIGHTCRAFT_SAM3_MIRRORS` or install by hand: the dialog names the three files, opens the configured model folder with the host opener, preserves setup on an open error, and links docs/ai-masks.md; Meta's original checkpoint installed in place of the Hugging Face one is named as such, #3378). Not verified against Lightroom's Select Object; no brush/box object mode; the first click on a photo waits for its analysis (~4 s on an M4 Pro, much longer on CPU) | | LR-MASK-PEOPLE | People parts | P2 | ⬜ | | shape exists (no UI): uses the photo's person / skin / hair / teeth / glasses mattes when it carries them (DNG semantic masks), else the subject heuristic | | LR-MASK-LANDSCAPE | Landscape classes | P2 | ⬜ | | shape exists, evaluates empty | -| LR-MASK-BRUSH | Brush mask | P0 | 🟡 | `cmd:tool.brush`, `cmd:mask.brushStroke` (`autoMask`), `crates/pipeline/src/masks.rs`, `crates/ui-egui/src/brush_live.rs` | size/feather/flow/density/erase; a stroke's edge falls off over its Feather as one dab's does (process V10, `masks::stroke_coverage`; V1 to V9 pile overlapping soft edges up); Create New Mask starts a separate brush in paint mode; the stroke shows while the button is held with the committed stroke's dab spacing, feather and flow, so fast strokes have no gaps (#517); with the mask overlay hidden (O / the eye, or after a mask slider hid it) or a colour overlay at opacity 0 it is not tinted while painting either, so dodging and burning is judged on the photo, and its effect shows once the stroke is committed (#2549); coverage builds up by passes, not hold time (holding the brush still adds nothing, live or committed, #518); from process V9 Flow is the coverage a stroke adds per brush radius travelled, as in Lightroom Classic (a stroke's centre: 44 % at Flow 25, 75 % at 50; measured in Lightroom 41 % and 76 %), whatever the drag speed; oversized path segments skip intermediate dabs instead of allocating a million samples; Auto Mask: dabs weighted by similarity to the colour under the dab centre, refined by a guided filter on luminance (CPU + GPU); ⇧-click draws a straight stroke from where the last stroke ended (`connect`), tapering size, feather and flow from that stroke's values when they changed; no A/B brushes; pen pressure (Brush ▸ Pen Pressure, on by default; `pressure` per point in `mask.brushStroke`) scales each dab's size (a tenth to all of it) and flow, live and committed alike, where winit reports a pen force (Windows; not macOS / Linux tablets yet); no tilt | +| LR-MASK-BRUSH | Brush mask | P0 | 🟡 | `cmd:tool.brush`, `cmd:mask.brushStroke` (`autoMask`), `crates/pipeline/src/masks.rs`, `crates/ui-egui/src/brush_live.rs` | size/feather/flow/density/erase; at Flow 100 a stroke's edge falls off over its Feather as one dab's does, and below it the Flow build-up is shaped by that falloff (process V10, `masks::stroke_coverage`; V1 to V9 pile overlapping soft edges up); Create New Mask starts a separate brush in paint mode; the stroke shows while the button is held with the committed stroke's dab spacing, feather and flow, so fast strokes have no gaps (#517); with the mask overlay hidden (O / the eye, or after a mask slider hid it) or a colour overlay at opacity 0 it is not tinted while painting either, so dodging and burning is judged on the photo, and its effect shows once the stroke is committed (#2549); coverage builds up by passes, not hold time (holding the brush still adds nothing, live or committed, #518); from process V9 Flow is the coverage a stroke adds per brush radius travelled, as in Lightroom Classic (a stroke's centre: 44 % at Flow 25, 75 % at 50; measured in Lightroom 41 % and 76 %), whatever the drag speed; oversized path segments skip intermediate dabs instead of allocating a million samples; Auto Mask: dabs weighted by similarity to the colour under the dab centre, refined by a guided filter on luminance (CPU + GPU); ⇧-click draws a straight stroke from where the last stroke ended (`connect`), tapering size, feather and flow from that stroke's values when they changed; no A/B brushes; pen pressure (Brush ▸ Pen Pressure, on by default; `pressure` per point in `mask.brushStroke`) scales each dab's size (a tenth to all of it) and flow, live and committed alike, where winit reports a pen force (Windows; not macOS / Linux tablets yet); no tilt | | LR-MASK-LINEAR | Linear gradient | P0 | ✅ | `cmd:tool.linear`, `cmd:mask.update`, `crates/pipeline/src/mask_space.rs` | gradients, brushes and AI selections stay on the photo's content when lens corrections, Upright, Transform or Rotate Left / Right change (`Mask.on_photo`; CPU and GPU) | | LR-MASK-RADIAL | Radial gradient | P0 | ✅ | `cmd:tool.radial`, `cmd:mask.update`, `crates/ui-egui/src/panels/detail.rs` | drag the selected ellipse's body or centre pin to move; edge grips resize, outer grip rotates; rotated and compound radial components, hidden pins, outside hit rejection and one-step undo tested | | LR-MASK-COLORRANGE | Colour range | P1 | ✅ | `cmd:mask.add` (`colorRange`), `cmd:mask.sampleColor`, `cmd:mask.update`, `crates/pipeline/src/lib.rs` (`color_range_sample`) | Color tile → click the photo to sample (⇧-click adds, up to 5; samples taken in the space the mask compares in, respecting section eyes and the requested HDR/SDR rendition), Pick button, Refine slider; at most 64 samples (`MAX_COLOR_RANGE_SAMPLES`, render cost is pixels × samples) however the mask arrives: `mask.add` / `mask.update`, a sidecar's `lc:settings`, a preset, `develop.merge`, `render --settings` or the catalog and history keep the first 64 (issue #2556) | diff --git a/docs/process-versions.md b/docs/process-versions.md index 479dd7bdda..d78f920cb2 100644 --- a/docs/process-versions.md +++ b/docs/process-versions.md @@ -18,7 +18,7 @@ stronger Light sliders, issue #196) without changing a single photo someone has | **V7** | V6 plus: film grain from crystal layers ([grain.md](grain.md), `crates/pipeline/src/crystal.rs`), after Aurélien Pierre's model: resolution independent (a preview is the export's grain box-downscaled), fading out at black and white, calibrated to Lightroom Classic's strength and width at mid grey. V1 to V6 keep their two-octave value noise exactly (`finish::ValueGrain`; on the GPU `F_GRAIN_MODEL` 0); `finish::GrainModel::new` picks the model per process. Renders without grain don't depend on this. | | **V8** | V7 plus: Highlights and Shadows take their edge-aware filter of log luminance without its fine detail (`local::detail_free`: each value clamped between its separable median at the V2 radius and the median of a 3× wider neighbourhood) instead of V2's plain median (`local::base_keeps_gaps`), so the gaps in dark lettering on a bright panel are not lifted into bright blocks (issue #3460). CPU (`local::tone_base`) and GPU (`render::tone_base`) branch on it; the base plane is keyed by process. Renders without Highlights or Shadows (global or local) are the same as V7's. | | **V9** | V8 plus: brush Flow is the coverage a stroke adds per brush radius it travels, as in Lightroom Classic (#4045): each dab adds `1 − (1 − flow)^(d / r)` for a dab `d` past the previous one (the first dab counts one radius, so a click paints its flow), `masks::travel_flow`. A point a stroke passes over for a length `L` is then covered by `1 − (1 − flow)^(L / r)` however densely the dabs lie: a straight stroke's centre by 44 % at Flow 25 and 75 % at Flow 50, where Lightroom Classic measures 41 % and 76 % on a grey card. V1 to V8 add the full flow per dab (r/4 apart on a fast drag, closer on a slow one): 90 % at Flow 25 on a fast stroke, more on a slow one. CPU (`masks::brush_dabs_within`), GPU (a flow per dab in the `shape` kernel's brush data) and the live stroke (`brush_live`) all branch on `masks::flow_per_radius`. Renders without brush masks, or with Flow 100 only, are the same as V8's. | -| **V10** (the latest) | V9 plus: a brush stroke's edge is feathered as one dab's is. Each stroke keeps its Flow build-up (every dab that reaches a pixel adds its flow, `masks::feather_dab`) apart from its edge (the highest falloff of those dabs), and covers their product up to Density (`masks::stroke_coverage`). V1 to V9 accumulate each dab's falloff times its flow, so the soft edges of dabs r/4 apart piled up: at Feather 100 and Flow 100 a straight stroke covered 0.90 halfway out from its centre line, where one dab covers 0.50; V10 covers 0.50. Below Flow 100 the centre now builds up by Flow per radius travelled whatever the Feather (a straight stroke's 44 % at Flow 25), where V9 also weakened a soft brush's centre (25 %). CPU (`masks::rasterize_brush`), GPU (a stroke-record word in the `shape` kernel's brush data) and the live stroke (`brush_live`) branch on `masks::stroke_feather`. Renders without brush masks, or with Feather 0 brushes only, are the same as V9's. | +| **V10** (the latest) | V9 plus: a brush stroke's edge is feathered as one dab's is. Each stroke keeps its Flow build-up (every dab that reaches a pixel adds its flow, `masks::feather_dab`) apart from its edge (the highest falloff of those dabs), and covers their product up to Density (`masks::stroke_coverage`). V1 to V9 accumulate each dab's falloff times its flow, so the soft edges of dabs r/4 apart piled up: at Feather 100 and Flow 100 a straight stroke covered 0.90 halfway out from its centre line, where one dab covers 0.50; V10 covers 0.50. Below Flow 100 the centre now builds up by Flow per radius travelled whatever the Feather (a straight stroke's 44 % at Flow 25), where V9 also weakened a soft brush's centre (25 %). CPU (`masks::rasterize_brush`), GPU (a stroke-record word in the `shape` kernel's brush data) and the live stroke (`brush_live`) branch on `masks::stroke_feather`. Auto Mask strokes keep V9's accumulation (their edge follows the photo's edges, not the feather). Renders without brush masks, or with Feather 0 or Auto Mask brushes only, are the same as V9's. | ## The rule diff --git a/docs/whats-new.md b/docs/whats-new.md index 221672c6b0..69910c778f 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -4,8 +4,9 @@ ### Brush Feather works on strokes (process V10) - A brush stroke's edge now fades over the Feather you set. Overlapping dabs used to pile their soft edges up into an - almost hard one: at Feather 100, halfway out from a stroke's centre line was 90 % covered, and is now 50 %, as one - dab is. A soft brush at low Flow also builds up at its centre as a hard one does. New photos (and Reset) get it; + almost hard one: at Feather 100 and Flow 100, halfway out from a stroke's centre line was 90 % covered, and is + now 50 %, as one dab is. A soft brush at low Flow also builds up at its centre as a hard one does. Auto Mask strokes, whose edge + follows the photo's, are unchanged. New photos (and Reset) get it; photos you already edited keep their brushes until Photo ▸ Update to Current Process. ### Brush Flow as in Lightroom (process V9) From d51c3da2cc108178f72d3004a47bdf2c2b3a0939 Mon Sep 17 00:00:00 2001 From: Dimitrij Denissenko Date: Tue, 24 Nov 2026 18:40:21 +0000 Subject: [PATCH 5/6] Heal: the pinned heal is checked on V14 and every later process, not only while V14 is the latest the_process_picks_the_heal asserted Process::LATEST == V14; V15 (brush Flow) is newer and keeps the pinned heal. --- crates/pipeline/src/spots/pinned.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/pipeline/src/spots/pinned.rs b/crates/pipeline/src/spots/pinned.rs index 983afe014d..8d4e36bd43 100644 --- a/crates/pipeline/src/spots/pinned.rs +++ b/crates/pipeline/src/spots/pinned.rs @@ -301,8 +301,10 @@ mod tests { for p in [Process::V8, Process::V10, Process::V13] { assert_eq!(HealMethod::of(&on(p)), HealMethod::Averaged, "{p:?}"); } - assert_eq!(HealMethod::of(&on(Process::V14)), HealMethod::Pinned); - assert_eq!(Process::LATEST, Process::V14); + // V14 and every later process keep the pinned heal + for p in Process::ALL.into_iter().filter(|p| *p >= Process::V14) { + assert_eq!(HealMethod::of(&on(p)), HealMethod::Pinned, "{p:?}"); + } assert_eq!(HealMethod::of(&DevelopSettings::default()), HealMethod::Pinned, "new photos get the latest process"); } From ee824f37fd6afff1dd29daf5779a8ebbae1d8a85 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 2 Dec 2026 12:51:08 +0700 Subject: [PATCH 6/6] LR-MASK-BRUSH: the Lens Blur brush preview keeps an Auto Mask stroke's V15 accumulation (review) --- crates/ui-egui/src/panels/detail/lens_blur.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/detail/lens_blur.rs b/crates/ui-egui/src/panels/detail/lens_blur.rs index 765fc8289a..171d10e799 100644 --- a/crates/ui-egui/src/panels/detail/lens_blur.rs +++ b/crates/ui-egui/src/panels/detail/lens_blur.rs @@ -122,9 +122,10 @@ pub(super) fn lens_blur_brush_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui hard: r * (1.0 - (app.ui.brush_feather / 100.0).clamp(0.0, 1.0)), flow: (app.ui.brush_flow / 100.0).clamp(0.0, 1.0), density: (app.ui.lens_blur_brush_amount / 100.0).clamp(0.0, 1.0), - // (its strokes render as a mask brush does: Flow per radius travelled from V15, the edge by stroke from V16) + // (its strokes render as a mask brush does: Flow per radius travelled from V15, the edge by stroke from V16, + // except an Auto Mask stroke, which keeps V15's accumulation as the committed one does) per_radius: lightcraft_pipeline::masks::flow_per_radius(d), - by_stroke: lightcraft_pipeline::masks::stroke_feather(d), + by_stroke: lightcraft_pipeline::masks::stroke_feather(d) && !app.ui.brush_auto_mask, color: if focus { [70, 200, 120] } else { [230, 70, 70] }, opacity: 0.45, };