mirror of
https://github.com/storytold/lightcraft.git
synced 2026-12-02 20:19:40 -05:00
Merge pull request #4517 from john01px2022/brush-stroke-feather
LR-MASK-BRUSH: a brush stroke is feathered as one dab is (process V16)
This commit is contained in:
18 files changed
+653
-49
No files matched your search
@@ -109,20 +109,27 @@ pub enum Process {
|
||||
/// V10, calibrated against Lightroom exports of real edits: global Shadows answers large amounts
|
||||
/// compressively (`lightcraft_pipeline::finish::tone_slider`), a negative Texture smooths less
|
||||
/// (`finish::texture_slider`) and the Global grading wheel tints less (`colorops::global_wheel`).
|
||||
/// `ProcessVersion(11)` and `ProcessVersion(12)` name no process here (12 is left to the open claim
|
||||
/// of #4047): a saved 11 or 12 renders as V10.
|
||||
/// `ProcessVersion(11)` and `ProcessVersion(12)` name no process: a saved 11 or 12 renders as V10.
|
||||
V13,
|
||||
/// V13, with Heal and Remove spots pinned to the photo on the spot's edge: the correction is a
|
||||
/// membrane fill of the log ratio of photo to source, the source's fine detail is matched to its
|
||||
/// surroundings, and every spot reads its source at whole pixels
|
||||
/// (`lightcraft_pipeline::spots::HealMethod`).
|
||||
V14,
|
||||
/// V14, 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 V14 add `flow` per dab.
|
||||
V15,
|
||||
/// V15, 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 V15 accumulate each dab's falloff.
|
||||
V16,
|
||||
}
|
||||
|
||||
impl Process {
|
||||
/// Every process, oldest first (`ProcessVersion(9)` names none and renders as V8; 11 and 12 name none and
|
||||
/// render as V10, 12 being claimed by an open pull request).
|
||||
pub const ALL: [Process; 11] = [
|
||||
/// render as V10).
|
||||
pub const ALL: [Process; 13] = [
|
||||
Process::V1,
|
||||
Process::V2,
|
||||
Process::V3,
|
||||
@@ -134,8 +141,10 @@ impl Process {
|
||||
Process::V10,
|
||||
Process::V13,
|
||||
Process::V14,
|
||||
Process::V15,
|
||||
Process::V16,
|
||||
];
|
||||
pub const LATEST: Process = Process::V14;
|
||||
pub const LATEST: Process = Process::V16;
|
||||
|
||||
pub const fn version(self) -> ProcessVersion {
|
||||
match self {
|
||||
@@ -150,6 +159,8 @@ impl Process {
|
||||
Process::V10 => ProcessVersion(10),
|
||||
Process::V13 => ProcessVersion(13),
|
||||
Process::V14 => ProcessVersion(14),
|
||||
Process::V15 => ProcessVersion(15),
|
||||
Process::V16 => ProcessVersion(16),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1493,11 +1493,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 the dab centres.
|
||||
/// 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
|
||||
/// V16, [`lightcraft_pipeline::masks::stroke_feather`])) then each dab's centre and the flow it
|
||||
/// adds (3 words; the stroke's flow before process V15, [`lightcraft_pipeline::masks::BrushDabs::dab`]).
|
||||
fn brush_aux(dabs: &[&lightcraft_pipeline::masks::BrushDabs], erase: bool) -> Vec<f32> {
|
||||
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 {
|
||||
@@ -1506,10 +1508,11 @@ 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();
|
||||
aux.push(d.feather_by_stroke as u8 as f32);
|
||||
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
|
||||
}
|
||||
|
||||
@@ -77,14 +77,16 @@ fn shape(@builtin(global_invocation_id) g: vec3<u32>) {
|
||||
}
|
||||
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 V16: 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;
|
||||
}
|
||||
@@ -92,11 +94,13 @@ fn shape(@builtin(global_invocation_id) g: vec3<u32>) {
|
||||
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;
|
||||
var edge = 0.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 V15)
|
||||
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;
|
||||
@@ -105,15 +109,29 @@ fn shape(@builtin(global_invocation_id) g: vec3<u32>) {
|
||||
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 + 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));
|
||||
sim = auto_similarity(lp, chp, log_l[ri], chroma_at(ri));
|
||||
}
|
||||
if (by_stroke) {
|
||||
// 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 * sim * flow;
|
||||
}
|
||||
keep *= 1.0 - a * flow;
|
||||
}
|
||||
let sa = min(1.0 - keep, aux[o + 5u]);
|
||||
var sa = min(1.0 - keep, aux[o + 5u]);
|
||||
if (by_stroke) {
|
||||
// masks::stroke_coverage
|
||||
sa = min((1.0 - keep) * edge, aux[o + 5u]);
|
||||
}
|
||||
if (aux[o + 6u] != 0.0) {
|
||||
v = v * (1.0 - sa);
|
||||
} else {
|
||||
|
||||
@@ -511,6 +511,86 @@ fn cases() -> Vec<(&'static str, Edit)> {
|
||||
},
|
||||
];
|
||||
}),
|
||||
("masks (brush, process V15: flow per radius travelled)", |s| {
|
||||
s.process = lightcraft_develop::Process::V15.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 V16: a soft stroke feathered as one dab)", |s| {
|
||||
s.process = lightcraft_develop::Process::V16.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 V16: an Auto Mask stroke keeps V15 accumulation)", |s| {
|
||||
s.process = lightcraft_develop::Process::V16.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 V15: a soft stroke's dabs accumulated)", |s| {
|
||||
s.process = lightcraft_develop::Process::V15.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 V14: flow per dab)", |s| {
|
||||
s.process = lightcraft_develop::Process::V14.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)],
|
||||
|
||||
@@ -103,10 +103,10 @@ impl GrainModel {
|
||||
seed: g.seed,
|
||||
})
|
||||
}),
|
||||
Process::V7 | Process::V8 | Process::V10 | Process::V13 | Process::V14 if draft => {
|
||||
Process::V7 | Process::V8 | Process::V10 | Process::V13 | Process::V14 | Process::V15 | Process::V16 if draft => {
|
||||
crate::crystal::CrystalGrain::draft(g, px_per_long).map(GrainModel::Crystal)
|
||||
}
|
||||
Process::V7 | Process::V8 | Process::V10 | Process::V13 | Process::V14 => {
|
||||
Process::V7 | Process::V8 | Process::V10 | Process::V13 | Process::V14 | Process::V15 | Process::V16 => {
|
||||
crate::crystal::CrystalGrain::new(g, px_per_long).map(GrainModel::Crystal)
|
||||
}
|
||||
}
|
||||
@@ -418,7 +418,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::V10 | Process::V13 | Process::V14 => {
|
||||
Process::V5 | Process::V6 | Process::V7 | Process::V8 | Process::V10 | Process::V13 | Process::V14 | Process::V15 | Process::V16 => {
|
||||
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),
|
||||
|
||||
@@ -37,9 +37,14 @@ 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 V15, [`crate::masks::flow_per_radius`]),
|
||||
/// not per dab.
|
||||
pub brush_flow_per_radius: bool,
|
||||
/// Filter of the area downscale ahead of the bilinear resample ([`Frame::sample`]); see
|
||||
/// [`crate::Downscale`].
|
||||
pub downscale: Filter,
|
||||
/// A brush stroke's edge is feathered as one dab's is (process V16, [`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
|
||||
@@ -85,7 +90,9 @@ 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),
|
||||
downscale: Filter::Mitchell,
|
||||
brush_stroke_feather: crate::masks::stroke_feather(s),
|
||||
};
|
||||
if apply_crop {
|
||||
f.constrain_to_image(s.geometry.constrain_crop);
|
||||
|
||||
@@ -517,11 +517,25 @@ 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<f32>,
|
||||
/// What each dab adds under process V15 ([`travel_flow`], pressure applied), parallel to `dabs`;
|
||||
/// empty before V15, where every dab adds the stroke's flow.
|
||||
pub flows: Vec<f32>,
|
||||
/// The stroke's edge is feathered as one dab's is (process V16, [`stroke_feather`]), unless it
|
||||
/// is an Auto Mask stroke: its edge follows the photo's, not the feather, and it keeps V15's
|
||||
/// accumulation, which its colour weighting stays stable under.
|
||||
pub feather_by_stroke: bool,
|
||||
}
|
||||
|
||||
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 V15 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 V15.
|
||||
fn pressed(&self, i: usize) -> (f64, f64, f32) {
|
||||
match self.pressure.get(i) {
|
||||
Some(&p) => {
|
||||
let r = pressure_radius(self.r, p);
|
||||
@@ -530,6 +544,75 @@ impl BrushDabs {
|
||||
None => (self.r, self.hard, self.flow),
|
||||
}
|
||||
}
|
||||
|
||||
/// Give every dab what it adds for the distance it travelled ([`travel_flow`], process V15).
|
||||
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 a brush stroke's edge is feathered as one dab's is (process V16 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::V16
|
||||
}
|
||||
|
||||
/// 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
|
||||
/// `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, falloff: f32, flow: f32) {
|
||||
if flow.is_nan() || flow <= 0.0 {
|
||||
return;
|
||||
}
|
||||
*build = accumulate(*build, 1.0, flow, 1.0);
|
||||
*edge = edge.max(falloff);
|
||||
}
|
||||
|
||||
/// 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 V15, 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 V15 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::V15
|
||||
}
|
||||
|
||||
/// What one dab adds to a stroke's coverage when Flow is coverage per brush radius travelled
|
||||
/// (process V15): `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
|
||||
@@ -610,7 +693,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,
|
||||
@@ -619,7 +702,10 @@ 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(),
|
||||
feather_by_stroke: frame.brush_stroke_feather && !s.auto_mask,
|
||||
};
|
||||
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,
|
||||
@@ -844,6 +930,21 @@ pub fn brush_over_budget(strokes: &[BrushStroke], frame: &Frame, w: usize, h: us
|
||||
false
|
||||
}
|
||||
|
||||
/// 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.
|
||||
@@ -862,6 +963,10 @@ fn rasterize_brush(strokes: &[BrushStroke], frame: &Frame, w: usize, h: usize, i
|
||||
room = room.saturating_sub(bd.dabs.len());
|
||||
let (dens, erase, auto) = (bd.density, bd.erase, bd.auto);
|
||||
let mut stroke_alpha = Plane::new(w, h);
|
||||
// process V16: the Flow build-up goes in `stroke_alpha`, the edge in `edge` (`feather_dab`)
|
||||
// (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(|| {
|
||||
@@ -876,14 +981,27 @@ 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];
|
||||
// flow accumulates within a stroke up to density
|
||||
*v = accumulate(*v, a, flow, dens);
|
||||
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, falloff * sim, flow, dens),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(edge) = &edge {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Point>) -> 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 V15: 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 V14 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::V15, 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::V14, 25.0, line).get(200, 50);
|
||||
assert!(old > 0.85, "V14 keeps the flow per dab: {old}");
|
||||
}
|
||||
|
||||
/// Process V15: a stroke covers the same however densely its samples lie (a slow drag samples
|
||||
/// every pixel, a fast one far apart); before V15 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<Point> = (40..=360).map(|x| Point::new(x as f64 / 400.0, 0.5)).collect();
|
||||
let (f, s) = (straight_stroke(Process::V15, 25.0, fast.clone()).get(200, 50), straight_stroke(Process::V15, 25.0, slow.clone()).get(200, 50));
|
||||
assert!((f - s).abs() < 0.02, "fast {f} vs slow {s}");
|
||||
let (f8, s8) = (straight_stroke(Process::V14, 25.0, fast).get(200, 50), straight_stroke(Process::V14, 25.0, slow).get(200, 50));
|
||||
assert!(s8 > f8, "before V15 a slow stroke builds up more: {f8} vs {s8}");
|
||||
}
|
||||
|
||||
/// 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::V14, Process::V15] {
|
||||
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() {
|
||||
@@ -685,3 +751,151 @@ 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 {
|
||||
feathered_stroke_on(&DevelopSettings { process: process.version(), ..Default::default() }, flow, feather)
|
||||
}
|
||||
|
||||
/// [`feathered_stroke`] on settings that were saved and reopened.
|
||||
fn feathered_stroke_on(d: &DevelopSettings, flow: f64, feather: f64) -> Plane {
|
||||
let (w, h) = (400, 100);
|
||||
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 V16: at Flow 100 a stroke's edge falls off over the feather exactly as one dab's does;
|
||||
/// V1 to V15 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::V16, 100.0, feather);
|
||||
let old = feathered_stroke(Process::V15, 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, "V15 is never the softer");
|
||||
}
|
||||
// halfway out at Feather 100 one dab paints 0.5; V15'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, "V15 keeps its hard edge: {}", old.get(200, 60));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Process V16 below Flow 100: the centre builds up by Flow per radius travelled whatever the
|
||||
/// feather, as a hard brush's does under V15 (`1 − (1 − flow)²` for a straight stroke, 44 % at Flow 25,
|
||||
/// as Lightroom Classic measures, #4045), and the feather shapes only the edge. Under V15 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::V16, flow, 100.0);
|
||||
let hard = feathered_stroke(Process::V16, 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::V15, 25.0, 100.0).get(200, 50);
|
||||
assert!(old < 0.3, "V15's soft brush is weaker at its centre: {old}");
|
||||
}
|
||||
|
||||
/// A hard brush (Feather 0) paints the same on V15 and V16.
|
||||
#[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::V16, flow, 0.0).data, feathered_stroke(Process::V15, flow, 0.0).data, "Flow {flow}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Process V16: 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 V15's accumulation on V16: 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::V16).data, paint(Process::V15).data);
|
||||
}
|
||||
|
||||
/// Process V16'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");
|
||||
}
|
||||
|
||||
/// A saved photo keeps its brush look: strokes saved on V8 (or 9), V10 (11, 12), V13 or V14 reopen
|
||||
/// on that process and render Flow per dab with every dab's falloff accumulated, as before V15; V15
|
||||
/// keeps the accumulated edge; only V16 feathers the stroke as one dab.
|
||||
#[test]
|
||||
fn a_saved_process_keeps_its_brush_look() {
|
||||
let saved = |n: u32| DevelopSettings::from_json(&serde_json::json!({ "process": n })).unwrap();
|
||||
for (flow, feather) in [(100.0, 100.0), (25.0, 100.0), (50.0, 60.0)] {
|
||||
let before = feathered_stroke_on(&saved(14), flow, feather);
|
||||
for n in [8, 9, 10, 11, 12, 13] {
|
||||
assert_eq!(feathered_stroke_on(&saved(n), flow, feather).data, before.data, "saved V{n}: Flow {flow}, Feather {feather}");
|
||||
}
|
||||
let per_radius = feathered_stroke_on(&saved(15), flow, feather);
|
||||
let by_stroke = feathered_stroke_on(&saved(16), flow, feather);
|
||||
if flow < 100.0 {
|
||||
assert_ne!(per_radius.data, before.data, "V15 builds up Flow per radius travelled (Flow {flow})");
|
||||
}
|
||||
assert_ne!(by_stroke.data, per_radius.data, "V16 feathers the stroke (Flow {flow}, Feather {feather})");
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@ 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::V10 | Process::V13 | Process::V14 => assert!(matches!(model, Some(GrainModel::Crystal(_))), "{p:?}"),
|
||||
Process::V7 | Process::V8 | Process::V10 | Process::V13 | Process::V14 | Process::V15 | Process::V16 => {
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -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};
|
||||
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;
|
||||
@@ -28,6 +30,12 @@ pub struct LiveParams {
|
||||
/// Flow and density, 0..1.
|
||||
pub flow: f32,
|
||||
pub density: f32,
|
||||
/// Flow is coverage per brush radius travelled (process V15, `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 V16, `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,
|
||||
@@ -39,6 +47,9 @@ pub struct LiveStroke {
|
||||
w: usize,
|
||||
h: usize,
|
||||
alpha: Vec<f32>,
|
||||
/// Under `by_stroke`, the Flow build-up and the edge `alpha` is made of (`masks::feather_dab`).
|
||||
build: Vec<f32>,
|
||||
edge: Vec<f32>,
|
||||
/// Samples stamped so far, and the last one (buffer pixels).
|
||||
placed: usize,
|
||||
/// Total dabs emitted across every stamp, including the first sample.
|
||||
@@ -46,6 +57,8 @@ pub struct LiveStroke {
|
||||
last: Option<Point>,
|
||||
/// 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<Point>,
|
||||
/// Buffer pixels painted since the last upload: (x0, y0, x1, y1), exclusive ends.
|
||||
dirty: Option<(usize, usize, usize, usize)>,
|
||||
texture: Option<TextureHandle>,
|
||||
@@ -56,7 +69,21 @@ 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],
|
||||
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,
|
||||
last_pressure: 1.0,
|
||||
last_dab: None,
|
||||
dirty: None,
|
||||
texture: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Stroke coverage (0..1) at buffer pixel `(x, y)`; 0 outside.
|
||||
@@ -80,7 +107,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, 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();
|
||||
@@ -105,6 +132,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;
|
||||
@@ -113,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 {
|
||||
@@ -220,12 +267,34 @@ mod tests {
|
||||
hard: 5.0,
|
||||
flow: 1.0,
|
||||
density: 1.0,
|
||||
per_radius: true,
|
||||
by_stroke: false,
|
||||
color: [230, 30, 40],
|
||||
opacity: 0.5,
|
||||
}
|
||||
}
|
||||
|
||||
/// Issue #517: two samples far apart (a fast stroke) paint a continuous band between them,
|
||||
/// Process V15: 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 V15 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<Pos2> = (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 V15 a slow drag builds up more");
|
||||
}
|
||||
|
||||
/// not two separate dabs.
|
||||
#[test]
|
||||
fn a_fast_segment_is_painted_continuously() {
|
||||
@@ -241,6 +310,31 @@ mod tests {
|
||||
assert_eq!(s.coverage(200, 111), 0.0);
|
||||
}
|
||||
|
||||
/// Process V16 (`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]
|
||||
|
||||
@@ -778,7 +778,7 @@ fn tool_interaction(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Res
|
||||
RightPanel::Remove => remove_overlay(app, ui, resp, map, d),
|
||||
RightPanel::RedEye => eye_overlay(app, ui, resp, map, d),
|
||||
RightPanel::Edit if app.ui.tool == "lensBlurShape" => lens_blur_shape_overlay(app, ui, resp, map, d),
|
||||
RightPanel::Edit if app.ui.tool.starts_with("lensBlur") => lens_blur_brush_overlay(app, ui, resp, map),
|
||||
RightPanel::Edit if app.ui.tool.starts_with("lensBlur") => lens_blur_brush_overlay(app, ui, resp, map, d),
|
||||
_ => {
|
||||
// side by side / stacked: Before shows the same frame, so a click in its view (white
|
||||
// balance, colour samples, targeted adjustment) means the same point of the photo.
|
||||
|
||||
@@ -84,7 +84,7 @@ pub(super) fn lens_blur_shape_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui
|
||||
/// Lens Blur Brush Refinement on the photo: the brush circle (size and feather), the stroke being
|
||||
/// painted (green: Focus, red: Blur), committed as `lensBlur.brushStroke` when the drag ends.
|
||||
/// ⌥ (Alt) erases what the brush painted.
|
||||
pub(super) fn lens_blur_brush_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Response, map: &CanvasMap) {
|
||||
pub(super) fn lens_blur_brush_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Response, map: &CanvasMap, d: &DevelopSettings) {
|
||||
let long = (map.rect.width().max(map.rect.height())) as f64;
|
||||
let clip = app.canvas_rect.unwrap_or(map.rect);
|
||||
let p = &ui.painter_at(clip);
|
||||
@@ -122,6 +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,
|
||||
// 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) && !app.ui.brush_auto_mask,
|
||||
color: if focus { [70, 200, 120] } else { [230, 70, 70] },
|
||||
opacity: 0.45,
|
||||
};
|
||||
|
||||
@@ -748,6 +748,9 @@ 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),
|
||||
// (an Auto Mask stroke keeps V15'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),
|
||||
};
|
||||
|
||||
@@ -2174,6 +2174,34 @@ fn a_fast_brush_stroke_shows_without_gaps_before_the_button_is_released() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Process V15 (and V16, 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");
|
||||
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<f32> = 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]> {
|
||||
|
||||
@@ -303,7 +303,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.settings`, `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; on Windows and Linux the image encoder, the two necks and the text detector's DETR encoder and mask decoder on the GPU through wgpu (`lightcraft-gpu` `sam3`) and the rest of the heads on the CPU; a description ~0.5–0.7 s with an RTX 5070, falling back to the CPU without a usable GPU or when the GPU is switched off; Settings ▸ Performance ▸ AI masks ▸ Run on: CPU puts all of it on the CPU on every platform (`segment.settings`); Settings ▸ Performance ▸ AI masks and `segment.model.status` → `backend` show where it runs and the last photo's time): 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; the remote worker retries listener accept errors after 100 ms (#2574), isolating client failures; it 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, ~0.6 s with an RTX 5070 under Linux, ~32 s on a 12-core 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; 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 V16, `masks::stroke_coverage`; V1 to V15 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 V15 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) |
|
||||
@@ -809,6 +809,8 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-27 | minor | LR-IMP-ADD-DIALOG / LR-IMP-MOVE: an optional backup folder (Backup to, `library.import` `backup`) gets a verified copy of each copied or moved file under the same folders and names as the destination; a move keeps the original of a photo whose backup failed; counts unchanged |
|
||||
| 2026-12-02 | minor | LR-MASK-BRUSH: a stroke's edge is feathered as one dab's is (process V16); status unchanged |
|
||||
| 2026-11-24 | minor | LR-MASK-BRUSH: process V15 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-19 | minor | LR-EDIT-OPTICS-DEFRINGE: AI Defringe (beyond Lightroom), a user-installed defringe network with a cached per-photo correction; no model ships; status unchanged |
|
||||
| 2026-10-31 | patch | LR-FILT-RATING: = or ≤ no stars in the filter bar shows the unrated photos instead of every photo (#3417); status unchanged |
|
||||
| 2026-10-29 | minor | MENU-EDIT-SELECTBY: Edit → Select by lists each rating on its own (★ only … ★★★★★ only, `library.selectBy` with `ratingOp: eq`) after the "and higher" rows, beside Unrated (#3311); status unchanged (✅) |
|
||||
|
||||
@@ -19,9 +19,11 @@ stronger Light sliders, issue #196) without changing a single photo someone has
|
||||
| **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** *(none)* | No process has this number: a saved 9 renders as V8, and Update to Current Process moves it to the latest. |
|
||||
| **V10** | V8 plus: checked Bradford white-balance fallback (`craft_color_transform::cct::wb_matrix`, returning `Mat3::IDENTITY` when a source illuminant's Bradford blue cone response `s[2] <= 0.0`, `craft-libs#587`). V1 to V8 keep the legacy Bradford result for saved edits (`local::wb_matrix_for`). |
|
||||
| **V11**, **V12** *(none)* | No process has 11; 12 is left to the open pull request that claims it (#4047). A photo saved with either renders as V10, and Update to Current Process moves it to the latest. |
|
||||
| **V11**, **V12** *(none)* | No process has 11 or 12. A photo saved with either renders as V10, and Update to Current Process moves it to the latest. |
|
||||
| **V13** | V10 plus: global Shadows eases off at large amounts (`finish::tone_slider`): the strength the local tone operator takes is `a / (1 + 1.33·abs(a))` for `a` = slider / 100, so the easing grows with the amount (slope 1 at 0; +10 acts at 0.88 of V6's) and ±100 acts at 0.43 of V6's. Fitted to 56 Lightroom exports of real portrait edits of Canon raws (Shadows +40 to +100), against which V6 rendered the darkest tones about 6 L* too light. Global Highlights stays linear: on the same edits V6 renders the brightest tones about 5 L* too dark, but single-slider exports show Lightroom's response to Highlights alone close to linear and dependent on the frame's content (#3923), which a fixed easing would not follow. Masks keep their linear amounts; Shadows amounts between 0 and +40 had no exports to check. CPU and GPU take the strength from `FinishParams`. Renders with Shadows at 0 are the same as V10's unless Texture is negative or the Global wheel is set. Also from V13: a negative global Texture smooths at 0.67 of V6's strength (`finish::texture_slider`; at −27, V6 left the 1–8 px detail of four full-size Lightroom exports of Canon EOS R6 edits at 0.87–0.94 of theirs, and 0.67 brings it to 0.94–1.02); and the global colour-grading wheel tints at 0.45 of the other wheels at the same saturation (`colorops::global_wheel`; V6 left photos graded Global 10 and 16 about +2 b* warmer than the exports). Positive Texture, the shadows, midtones and highlights wheels and masks are unchanged. |
|
||||
| **V14** (the latest) | V13 plus: Heal spots, and Remove spots with their automatic source, are pinned to the photo on the spot's edge (`spots::pinned`, [heal-pinned.md](heal-pinned.md)). The patch is the source times `e^P`, `P` the membrane fill (`lightcraft_inpaint::membrane_fill`) of the log ratio of photo to source, known only on the ring of pixels touching the spot and blurred there over the outside only (1.5 px), so the patch meets its surroundings at the edge, takes nothing from features that don't touch it, and carries the source's texture at its contrast relative to the new light. The source's fine detail (log luminance minus a 1.5 px blur) is scaled to the detail around the spot, by the ratio of medians around the spot (1.05 to 2 radii) and inside the source (0.9 radii), within 0.5 to 2×. Every spot, Clone included, reads its source at whole pixels (read between pixels, bilinear sampling halved the grain). V1 to V13 keep the source plus a Gaussian-weighted average of the difference around the spot (σ 0.6 radii) in linear light. A Heal or Remove spot whose working box holds more than `MAX_SPOT_SPAN² / 2` pixels (about 33.5 million; 8.4 million on the web) is too big for the pinned heal's working memory and gets the V13 averaged correction instead, still reading its source at whole pixels. Fill is unchanged. CPU and GPU branch on `spots::HealMethod`; the GPU renderer reads the image back for the spot stage on V14 photos with spots and keeps the rest of the render on the device. Renders without Heal, Remove or Clone spots are the same as V13's. |
|
||||
| **V14** | V13 plus: Heal spots, and Remove spots with their automatic source, are pinned to the photo on the spot's edge (`spots::pinned`, [heal-pinned.md](heal-pinned.md)). The patch is the source times `e^P`, `P` the membrane fill (`lightcraft_inpaint::membrane_fill`) of the log ratio of photo to source, known only on the ring of pixels touching the spot and blurred there over the outside only (1.5 px), so the patch meets its surroundings at the edge, takes nothing from features that don't touch it, and carries the source's texture at its contrast relative to the new light. The source's fine detail (log luminance minus a 1.5 px blur) is scaled to the detail around the spot, by the ratio of medians around the spot (1.05 to 2 radii) and inside the source (0.9 radii), within 0.5 to 2×. Every spot, Clone included, reads its source at whole pixels (read between pixels, bilinear sampling halved the grain). V1 to V13 keep the source plus a Gaussian-weighted average of the difference around the spot (σ 0.6 radii) in linear light. A Heal or Remove spot whose working box holds more than `MAX_SPOT_SPAN² / 2` pixels (about 33.5 million; 8.4 million on the web) is too big for the pinned heal's working memory and gets the V13 averaged correction instead, still reading its source at whole pixels. Fill is unchanged. CPU and GPU branch on `spots::HealMethod`; the GPU renderer reads the image back for the spot stage on V14 photos with spots and keeps the rest of the render on the device. Renders without Heal, Remove or Clone spots are the same as V13's. |
|
||||
| **V15** | V14 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 V14 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`, the masking and Lens Blur brushes) all branch on `masks::flow_per_radius`. Renders without brush strokes, or with Flow 100 only, are the same as V14's. |
|
||||
| **V16** (the latest) | V15 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 V15 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; V16 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 V15 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`, the masking and Lens Blur brushes) branch on `masks::stroke_feather`. Auto Mask strokes keep V15's accumulation (their edge follows the photo's edges, not the feather). Renders without brush strokes, or with Feather 0 or Auto Mask brushes only, are the same as V15's; a saved V1 to V15 photo keeps its strokes until Update to Current Process. |
|
||||
|
||||
## The rule
|
||||
|
||||
@@ -131,6 +133,8 @@ extra field and retain their existing cached renders. No cache-version bump is n
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-12-02 | minor | V16: a brush stroke's edge is feathered as one dab's is; V1 to V15 keep the accumulated soft edges |
|
||||
| 2026-11-24 | minor | V15: brush Flow per brush radius travelled, as in Lightroom Classic; V1 to V14 keep the flow per dab. 12 is no longer claimed |
|
||||
| 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 |
|
||||
| 2026-11-23 | minor | V13 (11 and 12 left to open claims): global Shadows eases off at large amounts, negative Texture and the global grading wheel act less, fitted to Lightroom exports; Highlights stays linear |
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# What's new in LightCraft
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Brush Feather works on strokes (process 16)
|
||||
- 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 and Flow 100, halfway out from a stroke's centre line was 90 % covered, and is
|
||||
now 50 %, as one dab is. Below Flow 100 a soft brush's centre builds up as a hard one's does, and Feather shapes only
|
||||
the edge. 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 15)
|
||||
- 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.
|
||||
|
||||
## 2026-10-31
|
||||
|
||||
### Filter for unrated photos
|
||||
|
||||
Reference in new issue
Block a user