From 6d29e03fc1dbd8578b3271dd29139fac9c9f4434 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Tue, 10 Nov 2026 19:31:40 +0100 Subject: [PATCH 01/20] LR-BEHAV-RENDER-FIDELITY: process V8, Whites and the tone curves measured against Lightroom (#523) Whites and the parametric curve follow Camera Raw's measured response on synthetic grey steps (tools/lr_tone_charts.py, crates/pipeline/src/curve_stage_tables.rs): Whites reaches into the upper midtones and the four regions are broad and additive. The master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast/Blacks and the colour stage. Refine Saturation keeps the curves' luminance. CPU and GPU share the tables; V1 to V7 are unchanged (docs/curve-stage.md, docs/process-versions.md). --- crates/develop/src/settings.rs | 9 +- crates/gpu/src/params.rs | 35 ++- crates/gpu/src/wgsl/finish.wgsl | 70 +++++ crates/gpu/tests/it/equivalence.rs | 44 +++ crates/pipeline/src/curve_stage.rs | 314 ++++++++++++++++++++++ crates/pipeline/src/curve_stage_tables.rs | 57 ++++ crates/pipeline/src/finish.rs | 19 +- crates/pipeline/src/lib.rs | 4 + crates/pipeline/src/light_v3.rs | 2 +- crates/pipeline/src/local.rs | 2 +- crates/pipeline/src/tests.rs | 24 +- crates/pipeline/src/tests_grain.rs | 2 +- docs/curve-stage.md | 70 +++++ docs/gaps.md | 2 +- docs/parity-checklist.md | 11 +- docs/process-versions.md | 4 +- docs/whats-new.md | 8 + tools/lr_tone_charts.py | 200 ++++++++++++++ tools/requirements-lr-tone-charts.txt | 4 + 19 files changed, 845 insertions(+), 36 deletions(-) create mode 100644 crates/pipeline/src/curve_stage.rs create mode 100644 crates/pipeline/src/curve_stage_tables.rs create mode 100644 docs/curve-stage.md create mode 100644 tools/lr_tone_charts.py create mode 100644 tools/requirements-lr-tone-charts.txt diff --git a/crates/develop/src/settings.rs b/crates/develop/src/settings.rs index 85bb3b90f2a..16a84270e2a 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 Whites and the parametric curve measured against Lightroom, and the tone curves applied as + /// Lightroom does: Whites, the parametric and point curve hue-preserving in linear ProPhoto RGB, then the + /// red, green and blue curves per channel, before the colour stage (`lightcraft_pipeline::curve_stage`). + 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/params.rs b/crates/gpu/src/params.rs index 9140fe81d5c..de6a0c5479d 100644 --- a/crates/gpu/src/params.rs +++ b/crates/gpu/src/params.rs @@ -23,6 +23,9 @@ const FIELDS: &[(&str, usize)] = &[ ("SRGB_OFF", 1), ("CURVE_OFF", 1), ("CURVES", 1), + ("STAGE", 1), + ("STAGE_OFF", 1), + ("STAGE_REFINE", 1), ("GAIN", 1), ("EV", 1), ("AIR", 1), @@ -197,21 +200,22 @@ pub fn finish_block(fp: &FinishParams, masks: &[[f32; MASK_TERMS]], present: &Pr let srgb_off = aux.len(); aux.extend_from_slice(&srgb_lut()[..]); let curve_off = aux.len(); - if let Some(c) = &fp.curves { - for l in c { - if l.v.len() != CURVE_N as usize { - // a wrong-length curve would shift every later aux offset (CURVE_OFF, MASK_OFF and - // the mask terms that follow) and make the kernel read the wrong data. `fail()` - // records the failure on this thread so the render falls back to the CPU; the - // partial `(p, aux)` returned here is never bound to a pipeline. - fail(FailKind::Fatal, format!("curve table has {} entries, expected {}", l.v.len(), CURVE_N)); - // `p` is only assembled below the curve loop, so an empty block is as good as any: - // the caller (render.rs) gates on `failed()` right after this returns and bails to - // the CPU fallback before indexing `p` or uploading `aux`. - return (Vec::new(), aux); - } - aux.extend_from_slice(&l.v); + let stage_off = curve_off + fp.curves.as_ref().map_or(0, |c| c.len() * CURVE_N as usize); + // process V8's stage (red, green, blue, then the base table) or the earlier processes' curves + let tables = fp.curves.iter().flatten().chain(fp.curve_stage.iter().flat_map(|c| c.chan.iter().chain([&c.base]))); + for l in tables { + if l.v.len() != CURVE_N as usize { + // a wrong-length curve would shift every later aux offset (CURVE_OFF, MASK_OFF and + // the mask terms that follow) and make the kernel read the wrong data. `fail()` + // records the failure on this thread so the render falls back to the CPU; the + // partial `(p, aux)` returned here is never bound to a pipeline. + fail(FailKind::Fatal, format!("curve table has {} entries, expected {}", l.v.len(), CURVE_N)); + // `p` is only assembled below the curve loop, so an empty block is as good as any: + // the caller (render.rs) gates on `failed()` right after this returns and bails to + // the CPU fallback before indexing `p` or uploading `aux`. + return (Vec::new(), aux); } + aux.extend_from_slice(&l.v); } let mask_off = aux.len(); for m in masks { @@ -258,6 +262,9 @@ pub fn finish_block(fp: &FinishParams, masks: &[[f32; MASK_TERMS]], present: &Pr p.u("SRGB_OFF", srgb_off as u32); p.u("CURVE_OFF", curve_off as u32); p.b("CURVES", fp.curves.is_some()); + p.b("STAGE", fp.curve_stage.is_some()); + p.u("STAGE_OFF", stage_off as u32); + p.f("STAGE_REFINE", fp.curve_stage.as_ref().map_or(1.0, |c| c.refine)); p.f("REFINE_SAT", fp.refine_sat); p.f("GAIN", fp.gain); p.f("EV", fp.ev); diff --git a/crates/gpu/src/wgsl/finish.wgsl b/crates/gpu/src/wgsl/finish.wgsl index 8a2f72f89ff..b57814fa221 100644 --- a/crates/gpu/src/wgsl/finish.wgsl +++ b/crates/gpu/src/wgsl/finish.wgsl @@ -122,6 +122,71 @@ fn light_ops(d: vec3) -> vec3 { return mul3(PRO_TO_2020, p); } +// A table of process V8's curve stage (`Lut1::eval`) at offset `o` in `aux`. +fn stage_lut(o: u32, x: f32) -> f32 { + let f = clamp(x, 0.0, 1.0) * f32(CURVE_N - 1u); + let i = min(u32(f), CURVE_N - 2u); + let t = f - f32(i); + return aux[o + i] + (aux[o + i + 1u] - aux[o + i]) * t; +} + +// `CurveStage::apply`: the base table on the largest and smallest channel of sRGB-encoded linear ProPhoto, the +// middle one keeping its place between them in linear light, then the red, green and blue curves per channel. +fn curve_stage(d: vec3) -> vec3 { + let p = mul3(PRO_FROM_2020, d); + var pc = clamp(p, vec3(0.0), vec3(1.0)); + var e = vec3(srgb_exact(pc.x), srgb_exact(pc.y), srgb_exact(pc.z)); + var hi = 0u; + var lo = 0u; + for (var k = 1u; k < 3u; k++) { + if (e[k] > e[hi]) { + hi = k; + } + if (e[k] < e[lo]) { + lo = k; + } + } + let off = pu(F_STAGE_OFF); + let base = off + 3u * CURVE_N; + let la = srgb_linear(stage_lut(base, e[hi])); + let lb = srgb_linear(stage_lut(base, e[lo])); + let pa = pc[hi]; + let pb = pc[lo]; + var curved = vec3(0.0); + for (var k = 0u; k < 3u; k++) { + var t = 1.0; + if (pa > pb) { + t = (pc[k] - pb) / (pa - pb); + } + curved[k] = stage_lut(off + k * CURVE_N, srgb_exact(clamp(lb + (la - lb) * t, 0.0, 1.0))); + } + var q = vec3(0.0); + for (var k = 0u; k < 3u; k++) { + q[k] = srgb_linear(clamp(curved[k], 0.0, 1.0)); + } + let rs = pf(F_STAGE_REFINE); + if (rs < 1.0) { + // the saturation back towards the input's, at the curves' luminance + let rr = refine_saturation(e, curved, rs); + var r = vec3(0.0); + for (var k = 0u; k < 3u; k++) { + r[k] = srgb_linear(clamp(rr[k], 0.0, 1.0)); + } + let yq = dot(q, PRO_Y); + let yr = dot(r, PRO_Y); + q = r; + if (yr > 1e-6) { + q = r * (yq / yr); + } + } + for (var k = 0u; k < 3u; k++) { + if (p[k] > 1.0) { + q[k] += p[k] - 1.0; + } + } + return mul3(PRO_TO_2020, q); +} + fn band_weights(h: f32) -> array { var w: array; for (var i = 0u; i < 8u; i++) { @@ -664,6 +729,11 @@ fn main(@builtin(global_invocation_id) gid: vec3) { d = light_ops(d); } + // --- process V8: Whites and the tone curves + if (pu(F_STAGE) != 0u) { + d = curve_stage(d); + } + // --- colour d = color_ops(d, lt[11], lt[12]); if (tint_on) { diff --git a/crates/gpu/tests/it/equivalence.rs b/crates/gpu/tests/it/equivalence.rs index 427afe424da..f9708b4f436 100644 --- a/crates/gpu/tests/it/equivalence.rs +++ b/crates/gpu/tests/it/equivalence.rs @@ -806,6 +806,50 @@ fn light_v3_operators_match() { } } +/// Process V8's curve stage: Whites, the parametric curve, the point curves and Refine Saturation, on a camera curve +/// and without one, in SDR and HDR. +#[test] +fn curve_stage_matches() { + if !gpu() { + return; + } + use lightcraft_geom::Point; + let src = scene(0, 960, 640); + let curve = lightcraft_pipeline::tone::CameraTone::new(std::array::from_fn(|i| { + let x = 0.004 * 1.18f32.powi(i as i32); + [x, 1.0 - (-2.0 * x).exp()] + })) + .unwrap(); + let raw = SourceInfo { raw: true, camera_tone: Some(curve), ..Default::default() }; + let req = RenderRequest::fit(720, 720); + let v8 = || DevelopSettings { process: Process::V8.version(), ..Default::default() }; + for v in [-100.0, -30.0, 40.0, 100.0] { + let mut s = v8(); + s.light.whites = v; + check(&format!("V8 Whites {v}"), &src, &raw, &s, &req); + } + let mut s = v8(); + s.curve.highlights = -40.0; + s.curve.lights = 25.0; + s.curve.darks = -15.0; + s.curve.shadows = 30.0; + check("V8 parametric", &src, &raw, &s, &req); + s.curve.master = vec![Point { x: 0.0, y: 0.05 }, Point { x: 0.5, y: 0.55 }, Point { x: 1.0, y: 0.95 }]; + s.curve.red = vec![Point { x: 0.0, y: 0.0 }, Point { x: 0.4, y: 0.5 }, Point { x: 1.0, y: 1.0 }]; + s.curve.blue = vec![Point { x: 0.0, y: 0.1 }, Point { x: 1.0, y: 0.9 }]; + s.light.whites = -25.0; + check("V8 curves", &src, &raw, &s, &req); + s.curve.refine_saturation = 30.0; + check("V8 Refine Saturation", &src, &raw, &s, &req); + check("V8 curves, no camera curve", &src, &SourceInfo::default(), &s, &req); + s.curve.split_mid = 40.0; + check("V8 other splits", &src, &raw, &s, &req); + s.curve.split_mid = 50.0; + s.hdr.enabled = true; + s.hdr.max_ev = 2.0; + check("V8 HDR preview", &src, &raw, &s, &req); +} + /// Issue #632: the Highlights / Shadows base of each process (V1: the edge-aware filter of log /// luminance; V2: of its fine median, a radius that grows with the render) matches the CPU's, and /// a warm cache never hands one process the other's base. diff --git a/crates/pipeline/src/curve_stage.rs b/crates/pipeline/src/curve_stage.rs new file mode 100644 index 00000000000..bb516c5a432 --- /dev/null +++ b/crates/pipeline/src/curve_stage.rs @@ -0,0 +1,314 @@ +//! Process V8's tone-curve stage ([`lightcraft_develop::Process::V8`], `docs/curve-stage.md`): Whites, the +//! parametric curve and the point curves, applied the way Lightroom applies them. +//! +//! Measured on Camera Raw renders of synthetic charts (`tools/lr_tone_charts.py`): +//! - Whites, the parametric curve, the master point curve, Contrast and Blacks act hue-preserving on linear ProPhoto +//! RGB: the curve maps the largest and the smallest channel (on sRGB-encoded values), and the middle channel keeps +//! its relative position between them in linear light. Predicting coloured patches from the curve measured on +//! grey steps this way leaves 0.03 to 0.16 (OkLab × 100), against 0.3 to 3.4 for V7. +//! - The red, green and blue curves act per channel on sRGB-encoded linear ProPhoto RGB, after the master curve. +//! - Whites and the four parametric regions are tables of Camera Raw's measured output (`curve_stage_tables`): +//! Whites reaches into the midtones (Whites −50 lowers encoded 0.6 by about 10/255), and each region is broad and +//! overlapping. The regions add: the sum of single regions reproduces three at once within 1/255. +//! +//! The stage runs after the tone map and Process V4's calibrated Contrast and Blacks, before the colour stage. It +//! replaces V7's curves on encoded output values; the tone map leaves Whites to it. + +use lightcraft_color::spline::{Lut1, MonotoneCurve}; +use lightcraft_color::transfer::{linear_to_srgb, srgb_to_linear}; +use lightcraft_develop::{DevelopSettings, Process, ToneCurve}; +use lightcraft_geom::Point; + +use crate::curve_stage_tables as t; +use crate::light_v3::PRO_Y; + +/// Entries per table (as the shipping curve tables). +pub const N: usize = 1024; + +/// Lightroom's default parametric splits: the measured region tables hold for them only. +const DEFAULT_SPLITS: [f64; 3] = [25.0, 50.0, 75.0]; + +/// The stage's tables: `base` (Whites, then the parametric curve, then the master point curve) acts hue-preserving, +/// `chan` (red, green, blue point curves) per channel. All on sRGB-encoded linear ProPhoto values. +#[derive(Clone, Debug)] +pub struct CurveStage { + pub chan: [Lut1; 3], + pub base: Lut1, + /// Refine Saturation, 0..1, on what the curves did (1 when only Whites is set). + pub refine: f32, +} + +/// A measured delta table (257 entries over 0..1) at `x`. +fn table_at(v: &[f32; 257], x: f32) -> f32 { + let p = x.clamp(0.0, 1.0) * 256.0; + let i = (p as usize).min(255); + let f = p - i as f32; + match (v.get(i), v.get(i + 1)) { + (Some(a), Some(b)) => a + (b - a) * f, + _ => 0.0, + } +} + +/// The delta at `x` of a setting measured at `amounts` (sorted, without 0), linearly between the measured amounts +/// and towards 0 below the smallest; clamped to the measured range. +fn measured_delta(amounts: &[f32; K], tables: &[[f32; 257]; K], amount: f32, x: f32) -> f32 { + if amount == 0.0 || K == 0 { + return 0.0; + } + // the measured amounts with 0 between the negative and positive ones + let mut keys: Vec<(f32, Option<&[f32; 257]>)> = amounts.iter().zip(tables.iter()).map(|(a, v)| (*a, Some(v))).collect(); + keys.push((0.0, None)); + keys.sort_by(|a, b| a.0.total_cmp(&b.0)); + let (lo, hi) = (keys.first().map_or(0.0, |k| k.0), keys.last().map_or(0.0, |k| k.0)); + let a = amount.clamp(lo, hi); + let at = |k: &(f32, Option<&[f32; 257]>)| k.1.map_or(0.0, |v| table_at(v, x)); + for w in keys.windows(2) { + if let [k0, k1] = w + && a >= k0.0 + && a <= k1.0 + { + let f = if k1.0 > k0.0 { (a - k0.0) / (k1.0 - k0.0) } else { 0.0 }; + return at(k0) * (1.0 - f) + at(k1) * f; + } + } + 0.0 +} + +/// The parametric curve: the measured regions at the default splits, else the analytic model of earlier processes. +fn parametric(c: &ToneCurve) -> Lut1 { + let splits = [c.split_shadows, c.split_mid, c.split_highlights]; + if splits.iter().zip(DEFAULT_SPLITS).any(|(s, d)| (s - d).abs() > 1e-6) { + return crate::curve::ParametricCurve::new(c).to_lut(); + } + let amounts = [c.shadows, c.darks, c.lights, c.highlights].map(|v| v as f32); + let mut lut = Lut1::from_fn(N, |x| { + let d: f32 = amounts.iter().zip(t::REGIONS.iter()).map(|(a, r)| measured_delta(&t::REGION_AMOUNTS, r, *a, x)).sum(); + (x + d).clamp(0.0, 1.0) + }); + monotone(&mut lut); + lut +} + +fn whites(amount: f64) -> Option { + if amount == 0.0 { + return None; + } + let mut lut = Lut1::from_fn(N, |x| (x + measured_delta(&t::WHITES_AMOUNTS, &t::WHITES, amount as f32, x)).clamp(0.0, 1.0)); + monotone(&mut lut); + Some(lut) +} + +/// Keeps a table non-decreasing (tone order never reverses). +fn monotone(lut: &mut Lut1) { + let mut m = f32::NEG_INFINITY; + for v in &mut lut.v { + m = m.max(*v); + *v = m; + } +} + +impl CurveStage { + /// The stage for `s`: `None` before V8, or when Whites, the parametric curve and every point curve are neutral. + pub fn new(s: &DevelopSettings) -> Option { + if s.process.process() < Process::V8 { + return None; + } + let c = &s.curve; + let parametric_on = c.highlights != 0.0 || c.lights != 0.0 || c.darks != 0.0 || c.shadows != 0.0; + let master = !ToneCurve::point_curve_is_identity(&c.master); + let chans = [&c.red, &c.green, &c.blue].map(|p| !ToneCurve::point_curve_is_identity(p)); + let w = whites(s.light.whites); + if w.is_none() && !parametric_on && !master && !chans.iter().any(|b| *b) { + return None; + } + let to_pts = |p: &[Point]| p.iter().map(|q| (q.x, q.y)).collect::>(); + let mut base = if parametric_on { parametric(c) } else { Lut1::identity(N) }; + if let Some(w) = &w { + base = base.compose(w); + } + if master { + base = MonotoneCurve::new(&to_pts(&c.master)).to_lut(N).compose(&base); + } + let per = [&c.red, &c.green, &c.blue]; + let chan = std::array::from_fn(|i| match per.get(i) { + Some(p) if chans.get(i).copied().unwrap_or(false) => MonotoneCurve::new(&to_pts(p)).to_lut(N), + _ => Lut1::identity(N), + }); + let curves_on = parametric_on || master || chans.iter().any(|b| *b); + let refine = if curves_on { (c.refine_saturation / 100.0).clamp(0.0, 1.0) as f32 } else { 1.0 }; + Some(CurveStage { chan, base, refine }) + } + + /// Linear Rec.2020 in and out (display referred, after the tone map). Values above white keep slope 1. + pub fn apply(&self, d: [f32; 3]) -> [f32; 3] { + let (to, from) = matrices(); + let p = mul3(to, d); + let pc = p.map(|v| v.clamp(0.0, 1.0)); + let e = pc.map(linear_to_srgb); + let (mut hi, mut lo) = (0usize, 0usize); + for k in 1..3 { + if e[k] > e[hi] { + hi = k; + } + if e[k] < e[lo] { + lo = k; + } + } + // the base curve on the largest and smallest channel; the middle one keeps its place in linear light + let (la, lb) = (srgb_to_linear(self.base.eval(e[hi])), srgb_to_linear(self.base.eval(e[lo]))); + let (pa, pb) = (pc[hi], pc[lo]); + let curved: [f32; 3] = std::array::from_fn(|k| { + let t = if pa > pb { (pc[k] - pb) / (pa - pb) } else { 1.0 }; + self.chan[k].eval(linear_to_srgb((lb + (la - lb) * t).clamp(0.0, 1.0))) + }); + let lin = |v: [f32; 3]| v.map(|x| srgb_to_linear(x.clamp(0.0, 1.0))); + let mut q = lin(curved); + if self.refine < 1.0 { + // the saturation back towards the input's, at the curves' luminance + let r = lin(crate::finish::refine_saturation(e, curved, self.refine)); + let y = |v: [f32; 3]| PRO_Y[0] * v[0] + PRO_Y[1] * v[1] + PRO_Y[2] * v[2]; + let (yq, yr) = (y(q), y(r)); + q = if yr > 1e-6 { r.map(|v| v * yq / yr) } else { r }; + } + for (k, v) in q.iter_mut().enumerate() { + if let Some(over) = p.get(k).filter(|x| **x > 1.0) { + *v += over - 1.0; + } + } + mul3(from, q) + } +} + +fn matrices() -> &'static ([[f32; 3]; 3], [[f32; 3]; 3]) { + static M: std::sync::OnceLock<([[f32; 3]; 3], [[f32; 3]; 3])> = std::sync::OnceLock::new(); + M.get_or_init(crate::light_v3::prophoto_matrices) +} + +fn mul3(m: &[[f32; 3]; 3], d: [f32; 3]) -> [f32; 3] { + std::array::from_fn(|r| m[r][0] * d[0] + m[r][1] * d[1] + m[r][2] * d[2]) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn v8() -> DevelopSettings { + DevelopSettings { process: Process::V8.version(), ..Default::default() } + } + + fn with_whites(v: f64) -> DevelopSettings { + let mut s = v8(); + s.light.whites = v; + s + } + + /// Display-linear grey whose sRGB encoding is `e`, through the stage, back to encoded. + fn grey(stage: &CurveStage, e: f32) -> f32 { + linear_to_srgb(stage.apply([srgb_to_linear(e); 3])[1]) + } + + #[test] + fn earlier_processes_and_neutral_settings_have_no_stage() { + assert!(CurveStage::new(&v8()).is_none(), "neutral settings are the identity"); + for p in Process::ALL.iter().filter(|p| **p < Process::V8) { + let s = DevelopSettings { process: p.version(), ..with_whites(-50.0) }; + assert!(CurveStage::new(&s).is_none(), "{p:?}"); + } + } + + #[test] + fn whites_reaches_into_the_midtones_as_measured() { + let stage = CurveStage::new(&with_whites(-50.0)).expect("Whites set"); + let drop = (0.6 - grey(&stage, 0.6)) * 255.0; + assert!((7.0..13.0).contains(&drop), "encoded 0.6 fell by {drop}/255"); + let dark = (0.05 - grey(&stage, 0.05)).abs() * 255.0; + assert!(dark < 2.0, "the shadows hardly move: {dark}/255"); + let up = CurveStage::new(&with_whites(50.0)).expect("Whites set"); + assert!(grey(&up, 0.6) > 0.6); + } + + #[test] + fn regions_add_and_act_in_their_own_range() { + let curve = |f: fn(&mut ToneCurve)| { + let mut s = v8(); + f(&mut s.curve); + CurveStage::new(&s).expect("a region set") + }; + let shadows = curve(|c| c.shadows = 50.0); + let highlights = curve(|c| c.highlights = 50.0); + let both = curve(|c| { + c.shadows = 50.0; + c.highlights = 50.0; + }); + assert!(grey(&shadows, 0.15) - 0.15 > 3.0 * (grey(&shadows, 0.85) - 0.85).abs(), "Shadows lifts the dark end"); + assert!(grey(&highlights, 0.85) - 0.85 > 3.0 * (grey(&highlights, 0.15) - 0.15).abs(), "Highlights lifts the bright end"); + for e in [0.15f32, 0.4, 0.6, 0.85] { + let sum = e + (grey(&shadows, e) - e) + (grey(&highlights, e) - e); + assert!((grey(&both, e) - sum).abs() < 1.5 / 255.0, "{e}"); + } + } + + #[test] + fn other_splits_fall_back_to_the_analytic_curve() { + let mut s = v8(); + s.curve.highlights = 50.0; + s.curve.split_mid = 40.0; + let stage = CurveStage::new(&s).expect("a region set"); + assert_eq!(stage.base.v, crate::curve::ParametricCurve::new(&s.curve).to_lut().v); + } + + #[test] + fn tone_order_never_reverses_and_every_table_fits_the_gpu() { + for w in [-100.0, -50.0, 37.0, 100.0] { + let mut s = with_whites(w); + s.curve.shadows = -100.0; + s.curve.lights = 100.0; + let stage = CurveStage::new(&s).expect("set"); + assert!(stage.base.v.windows(2).all(|p| p[0] <= p[1]), "{w}"); + assert!(stage.chan.iter().chain([&stage.base]).all(|l| l.v.len() == N), "{w}"); + } + } + + #[test] + fn the_middle_channel_keeps_its_place_in_linear_prophoto() { + let stage = CurveStage::new(&with_whites(-100.0)).expect("Whites set"); + let (to, from) = matrices(); + let input = [0.55f32, 0.27, 0.08]; + let out = mul3(to, stage.apply(mul3(from, input))); + let at = |p: [f32; 3]| (p[1] - p[2]) / (p[0] - p[2]); + assert!((at(out) - at(input)).abs() < 1e-3, "{out:?}"); + } + + #[test] + fn colour_curves_act_per_channel_after_the_master() { + let mut s = v8(); + s.curve.red = vec![Point { x: 0.0, y: 0.0 }, Point { x: 0.5, y: 0.7 }, Point { x: 1.0, y: 1.0 }]; + let stage = CurveStage::new(&s).expect("a red curve"); + let (to, from) = matrices(); + let out = mul3(to, stage.apply(mul3(from, [srgb_to_linear(0.5); 3]))); + assert!((linear_to_srgb(out[0]) - 0.7).abs() < 2e-3, "{out:?}"); + assert!((linear_to_srgb(out[1]) - 0.5).abs() < 2e-3, "{out:?}"); + } + + #[test] + fn hdr_values_keep_slope_one_above_white() { + let stage = CurveStage::new(&with_whites(-50.0)).expect("Whites set"); + let (a, b) = (stage.apply([2.0; 3]), stage.apply([3.0; 3])); + assert!((b[0] - a[0] - 1.0).abs() < 1e-3, "{a:?} {b:?}"); + } + + #[test] + fn refine_saturation_at_zero_undoes_what_the_curves_added() { + let mut s = v8(); + s.curve.master = vec![Point { x: 0.0, y: 0.0 }, Point { x: 0.25, y: 0.15 }, Point { x: 0.75, y: 0.85 }, Point { x: 1.0, y: 1.0 }]; + let sat = |stage: &CurveStage| { + let (to, from) = matrices(); + let p = mul3(to, stage.apply(mul3(from, [0.5, 0.25, 0.12]))).map(linear_to_srgb); + (p[0] - p[2]) / (0.2126 * p[0] + 0.7152 * p[1] + 0.0722 * p[2]) + }; + let full = sat(&CurveStage::new(&s).expect("a curve")); + s.curve.refine_saturation = 0.0; + let none = sat(&CurveStage::new(&s).expect("a curve")); + assert!(none < full, "{none} {full}"); + } +} diff --git a/crates/pipeline/src/curve_stage_tables.rs b/crates/pipeline/src/curve_stage_tables.rs new file mode 100644 index 00000000000..768fcb7ef51 --- /dev/null +++ b/crates/pipeline/src/curve_stage_tables.rs @@ -0,0 +1,57 @@ +// @generated by tools/lr_tone_charts.py from Camera Raw renders of its synthetic grey steps (docs/curve-stage.md). +// Output minus input of each setting on sRGB-encoded linear ProPhoto values, 257 evenly spaced inputs from 0 to 1. + +pub const WHITES_AMOUNTS: [f32; 6] = [-100.0, -50.0, -25.0, 25.0, 50.0, 100.0]; +pub static WHITES: [[f32; 257]; 6] = [ + [0.000000, 0.000000, 0.000000, -0.000115, -0.000262, -0.000282, -0.000280, -0.000241, -0.000213, -0.000216, -0.000229, -0.000303, -0.000375, -0.000435, -0.000492, -0.000540, -0.000588, -0.000634, -0.000679, -0.000739, -0.000800, -0.000869, -0.000949, -0.001028, -0.001128, -0.001240, -0.001352, -0.001477, -0.001619, -0.001762, -0.001904, -0.002002, -0.002093, -0.002185, -0.002276, -0.002425, -0.002578, -0.002731, -0.002884, -0.003029, -0.003167, -0.003305, -0.003443, -0.003582, -0.003749, -0.003925, -0.004101, -0.004276, -0.004452, -0.004625, -0.004797, -0.004968, -0.005139, -0.005311, -0.005482, -0.005703, -0.005924, -0.006145, -0.006365, -0.006586, -0.006807, -0.007026, -0.007246, -0.007466, -0.007686, -0.007906, -0.008126, -0.008373, -0.008635, -0.008897, -0.009159, -0.009421, -0.009683, -0.009945, -0.010238, -0.010534, -0.010830, -0.011127, -0.011423, -0.011719, -0.012016, -0.012349, -0.012699, -0.013049, -0.013399, -0.013749, -0.014099, -0.014449, -0.014799, -0.015189, -0.015580, -0.015970, -0.016360, -0.016750, -0.017141, -0.017531, -0.017921, -0.018365, -0.018821, -0.019277, -0.019733, -0.020189, -0.020645, -0.021101, -0.021557, -0.022017, -0.022533, -0.023050, -0.023566, -0.024083, -0.024599, -0.025116, -0.025632, -0.026149, -0.026665, -0.027240, -0.027837, -0.028434, -0.029031, -0.029627, -0.030224, -0.030821, -0.031418, -0.032015, -0.032612, -0.033245, -0.033891, -0.034538, -0.035184, -0.035830, -0.036477, -0.037123, -0.037769, -0.038416, -0.039062, -0.039694, -0.040247, -0.040800, -0.041354, -0.041907, -0.042461, -0.043014, -0.043567, -0.044121, -0.044674, -0.045228, -0.045801, -0.046389, -0.046978, -0.047567, -0.048156, -0.048744, -0.049333, -0.049922, -0.050510, -0.051099, -0.051692, -0.052335, -0.052977, -0.053620, -0.054263, -0.054905, -0.055548, -0.056190, -0.056833, -0.057476, -0.058118, -0.058807, -0.059508, -0.060209, -0.060911, -0.061612, -0.062313, -0.063014, -0.063716, -0.064417, -0.065118, -0.065860, -0.066614, -0.067368, -0.068122, -0.068877, -0.069631, -0.070385, -0.071139, -0.071894, -0.072650, -0.073448, -0.074245, -0.075042, -0.075839, -0.076636, -0.077434, -0.078231, -0.079028, -0.079825, -0.080644, -0.081470, -0.082296, -0.083121, -0.083947, -0.084772, -0.085598, -0.086424, -0.087249, -0.088070, -0.088891, -0.089713, -0.090534, -0.091355, -0.092176, -0.092997, -0.093818, -0.094591, -0.095338, -0.096086, -0.096833, -0.097581, -0.098329, -0.099076, -0.099824, -0.100370, -0.100889, -0.101407, -0.101925, -0.102443, -0.102962, -0.103480, -0.103672, -0.103685, -0.103698, -0.103711, -0.103724, -0.103737, -0.103750, -0.102762, -0.101769, -0.100777, -0.099784, -0.098791, -0.097798, -0.095053, -0.092290, -0.089527, -0.086764, -0.084001, -0.079339, -0.073815, -0.068290, -0.062766, -0.056620, -0.047795, -0.038970, -0.030145, -0.020499, -0.010248, 0.000000], + [0.000000, 0.000000, 0.000000, -0.000115, -0.000262, -0.000282, -0.000280, -0.000241, -0.000213, -0.000216, -0.000229, -0.000303, -0.000362, -0.000342, -0.000361, -0.000481, -0.000584, -0.000629, -0.000675, -0.000737, -0.000799, -0.000867, -0.000942, -0.001016, -0.001114, -0.001228, -0.001342, -0.001450, -0.001552, -0.001653, -0.001755, -0.001854, -0.001952, -0.002051, -0.002149, -0.002281, -0.002416, -0.002551, -0.002686, -0.002827, -0.002972, -0.003118, -0.003263, -0.003408, -0.003547, -0.003685, -0.003822, -0.003960, -0.004098, -0.004249, -0.004411, -0.004572, -0.004733, -0.004894, -0.005056, -0.005261, -0.005466, -0.005671, -0.005876, -0.006080, -0.006285, -0.006462, -0.006638, -0.006814, -0.006991, -0.007167, -0.007343, -0.007550, -0.007772, -0.007994, -0.008217, -0.008439, -0.008661, -0.008884, -0.009132, -0.009384, -0.009636, -0.009888, -0.010140, -0.010392, -0.010643, -0.010911, -0.011186, -0.011462, -0.011737, -0.012012, -0.012288, -0.012563, -0.012838, -0.013154, -0.013470, -0.013786, -0.014102, -0.014418, -0.014734, -0.015050, -0.015366, -0.015714, -0.016071, -0.016427, -0.016783, -0.017140, -0.017496, -0.017852, -0.018209, -0.018567, -0.018960, -0.019353, -0.019746, -0.020140, -0.020533, -0.020926, -0.021319, -0.021712, -0.022105, -0.022531, -0.022969, -0.023407, -0.023846, -0.024284, -0.024722, -0.025160, -0.025599, -0.026037, -0.026475, -0.026923, -0.027375, -0.027827, -0.028279, -0.028731, -0.029183, -0.029634, -0.030086, -0.030538, -0.030990, -0.031423, -0.031754, -0.032085, -0.032417, -0.032748, -0.033079, -0.033411, -0.033742, -0.034073, -0.034405, -0.034736, -0.035069, -0.035404, -0.035739, -0.036073, -0.036408, -0.036743, -0.037077, -0.037412, -0.037747, -0.038082, -0.038416, -0.038748, -0.039080, -0.039412, -0.039744, -0.040076, -0.040408, -0.040740, -0.041072, -0.041404, -0.041736, -0.042057, -0.042374, -0.042692, -0.043009, -0.043326, -0.043644, -0.043961, -0.044279, -0.044596, -0.044913, -0.045210, -0.045500, -0.045790, -0.046080, -0.046370, -0.046661, -0.046951, -0.047241, -0.047531, -0.047818, -0.048053, -0.048289, -0.048524, -0.048760, -0.048995, -0.049231, -0.049466, -0.049702, -0.049937, -0.050104, -0.050252, -0.050400, -0.050548, -0.050695, -0.050843, -0.050991, -0.051139, -0.051287, -0.051339, -0.051388, -0.051437, -0.051486, -0.051535, -0.051584, -0.051633, -0.051683, -0.051635, -0.051537, -0.051439, -0.051341, -0.051243, -0.051146, -0.051048, -0.050950, -0.050664, -0.050351, -0.050038, -0.049725, -0.049412, -0.049099, -0.048786, -0.048276, -0.047660, -0.047043, -0.046427, -0.045810, -0.045194, -0.044577, -0.043540, -0.042501, -0.041462, -0.040423, -0.039384, -0.038345, -0.036747, -0.035143, -0.033539, -0.031934, -0.030330, -0.028242, -0.025934, -0.023626, -0.021318, -0.018876, -0.015857, -0.012837, -0.009818, -0.006628, -0.003314, 0.000000], + [0.000000, 0.000000, 0.000000, -0.000096, -0.000224, -0.000267, -0.000245, -0.000104, -0.000027, -0.000130, -0.000228, -0.000300, -0.000357, -0.000337, -0.000338, -0.000392, -0.000441, -0.000477, -0.000512, -0.000549, -0.000585, -0.000641, -0.000721, -0.000802, -0.000869, -0.000929, -0.000988, -0.001060, -0.001151, -0.001242, -0.001332, -0.001401, -0.001466, -0.001531, -0.001596, -0.001706, -0.001818, -0.001931, -0.002044, -0.002140, -0.002224, -0.002308, -0.002392, -0.002476, -0.002571, -0.002669, -0.002768, -0.002866, -0.002964, -0.003073, -0.003190, -0.003306, -0.003423, -0.003540, -0.003656, -0.003790, -0.003925, -0.004059, -0.004193, -0.004327, -0.004461, -0.004584, -0.004706, -0.004829, -0.004952, -0.005074, -0.005197, -0.005321, -0.005447, -0.005573, -0.005698, -0.005824, -0.005950, -0.006075, -0.006233, -0.006394, -0.006556, -0.006717, -0.006879, -0.007040, -0.007202, -0.007371, -0.007545, -0.007718, -0.007891, -0.008064, -0.008238, -0.008411, -0.008584, -0.008777, -0.008969, -0.009161, -0.009354, -0.009546, -0.009739, -0.009931, -0.010123, -0.010331, -0.010542, -0.010753, -0.010964, -0.011175, -0.011386, -0.011597, -0.011808, -0.012019, -0.012243, -0.012468, -0.012692, -0.012916, -0.013140, -0.013364, -0.013588, -0.013813, -0.014037, -0.014283, -0.014536, -0.014790, -0.015044, -0.015298, -0.015552, -0.015806, -0.016060, -0.016314, -0.016568, -0.016806, -0.017038, -0.017269, -0.017501, -0.017733, -0.017965, -0.018197, -0.018429, -0.018660, -0.018892, -0.019112, -0.019271, -0.019429, -0.019587, -0.019745, -0.019904, -0.020062, -0.020220, -0.020379, -0.020537, -0.020695, -0.020846, -0.020990, -0.021135, -0.021280, -0.021425, -0.021569, -0.021714, -0.021859, -0.022004, -0.022148, -0.022292, -0.022427, -0.022561, -0.022695, -0.022830, -0.022964, -0.023098, -0.023233, -0.023367, -0.023502, -0.023636, -0.023754, -0.023867, -0.023981, -0.024094, -0.024207, -0.024321, -0.024434, -0.024548, -0.024661, -0.024774, -0.024866, -0.024951, -0.025036, -0.025121, -0.025206, -0.025292, -0.025377, -0.025462, -0.025547, -0.025629, -0.025670, -0.025711, -0.025752, -0.025793, -0.025834, -0.025875, -0.025916, -0.025957, -0.025998, -0.025998, -0.025986, -0.025975, -0.025963, -0.025951, -0.025939, -0.025928, -0.025916, -0.025904, -0.025834, -0.025762, -0.025689, -0.025617, -0.025545, -0.025473, -0.025401, -0.025328, -0.025208, -0.025064, -0.024920, -0.024775, -0.024631, -0.024487, -0.024342, -0.024198, -0.023963, -0.023714, -0.023466, -0.023217, -0.022968, -0.022720, -0.022471, -0.022140, -0.021764, -0.021387, -0.021011, -0.020634, -0.020258, -0.019881, -0.019330, -0.018779, -0.018227, -0.017676, -0.017124, -0.016573, -0.015824, -0.015074, -0.014323, -0.013572, -0.012822, -0.011889, -0.010874, -0.009859, -0.008844, -0.007785, -0.006538, -0.005290, -0.004043, -0.002728, -0.001364, 0.000000], + [0.000000, 0.000000, 0.000004, 0.000007, 0.000012, 0.000032, 0.000045, 0.000043, 0.000043, 0.000043, 0.000042, 0.000036, 0.000043, 0.000120, 0.000175, 0.000171, 0.000179, 0.000226, 0.000273, 0.000311, 0.000349, 0.000381, 0.000405, 0.000429, 0.000479, 0.000545, 0.000612, 0.000660, 0.000680, 0.000700, 0.000719, 0.000776, 0.000838, 0.000900, 0.000962, 0.001031, 0.001099, 0.001168, 0.001237, 0.001297, 0.001353, 0.001408, 0.001463, 0.001518, 0.001577, 0.001636, 0.001696, 0.001755, 0.001815, 0.001891, 0.001980, 0.002068, 0.002156, 0.002244, 0.002332, 0.002395, 0.002458, 0.002521, 0.002584, 0.002648, 0.002711, 0.002808, 0.002906, 0.003004, 0.003102, 0.003200, 0.003297, 0.003400, 0.003505, 0.003611, 0.003716, 0.003821, 0.003926, 0.004032, 0.004151, 0.004273, 0.004395, 0.004516, 0.004638, 0.004760, 0.004881, 0.005011, 0.005145, 0.005278, 0.005412, 0.005545, 0.005679, 0.005812, 0.005946, 0.006092, 0.006237, 0.006383, 0.006529, 0.006674, 0.006820, 0.006966, 0.007112, 0.007278, 0.007449, 0.007620, 0.007791, 0.007962, 0.008133, 0.008304, 0.008475, 0.008647, 0.008834, 0.009021, 0.009208, 0.009396, 0.009583, 0.009770, 0.009958, 0.010145, 0.010332, 0.010538, 0.010750, 0.010963, 0.011175, 0.011388, 0.011600, 0.011812, 0.012025, 0.012237, 0.012450, 0.012632, 0.012804, 0.012975, 0.013147, 0.013318, 0.013490, 0.013661, 0.013833, 0.014004, 0.014175, 0.014343, 0.014493, 0.014642, 0.014791, 0.014941, 0.015090, 0.015240, 0.015389, 0.015538, 0.015688, 0.015837, 0.015989, 0.016144, 0.016299, 0.016454, 0.016609, 0.016764, 0.016919, 0.017074, 0.017229, 0.017384, 0.017539, 0.017690, 0.017841, 0.017992, 0.018144, 0.018295, 0.018446, 0.018597, 0.018749, 0.018900, 0.019051, 0.019198, 0.019344, 0.019490, 0.019635, 0.019781, 0.019927, 0.020073, 0.020219, 0.020364, 0.020510, 0.020649, 0.020785, 0.020921, 0.021057, 0.021194, 0.021330, 0.021466, 0.021602, 0.021739, 0.021874, 0.021991, 0.022108, 0.022225, 0.022342, 0.022459, 0.022576, 0.022693, 0.022810, 0.022927, 0.023029, 0.023128, 0.023227, 0.023326, 0.023425, 0.023523, 0.023622, 0.023721, 0.023820, 0.023898, 0.023976, 0.024053, 0.024131, 0.024209, 0.024287, 0.024365, 0.024442, 0.024500, 0.024547, 0.024595, 0.024642, 0.024689, 0.024737, 0.024784, 0.024832, 0.024839, 0.024842, 0.024844, 0.024846, 0.024849, 0.024851, 0.024853, 0.024802, 0.024721, 0.024641, 0.024560, 0.024480, 0.024399, 0.024319, 0.024114, 0.023909, 0.023704, 0.023499, 0.023293, 0.023088, 0.022686, 0.022283, 0.021879, 0.021475, 0.021072, 0.020448, 0.019725, 0.019001, 0.018278, 0.017293, 0.015181, 0.013069, 0.010956, 0.007812, 0.003905, 0.000000], + [0.000000, 0.000074, 0.000125, 0.000231, 0.000267, 0.000269, 0.000316, 0.000448, 0.000536, 0.000503, 0.000469, 0.000429, 0.000417, 0.000552, 0.000665, 0.000728, 0.000803, 0.000921, 0.001038, 0.001193, 0.001351, 0.001497, 0.001630, 0.001762, 0.001902, 0.002047, 0.002192, 0.002339, 0.002490, 0.002641, 0.002792, 0.003019, 0.003256, 0.003493, 0.003731, 0.003912, 0.004089, 0.004267, 0.004444, 0.004658, 0.004898, 0.005139, 0.005379, 0.005619, 0.005873, 0.006130, 0.006388, 0.006645, 0.006902, 0.007164, 0.007429, 0.007694, 0.007959, 0.008224, 0.008489, 0.008774, 0.009058, 0.009343, 0.009628, 0.009912, 0.010197, 0.010532, 0.010867, 0.011202, 0.011538, 0.011873, 0.012208, 0.012575, 0.012959, 0.013343, 0.013727, 0.014111, 0.014495, 0.014879, 0.015296, 0.015716, 0.016137, 0.016557, 0.016978, 0.017398, 0.017819, 0.018281, 0.018764, 0.019247, 0.019729, 0.020212, 0.020694, 0.021177, 0.021660, 0.022208, 0.022756, 0.023304, 0.023852, 0.024401, 0.024949, 0.025497, 0.026045, 0.026634, 0.027233, 0.027832, 0.028430, 0.029029, 0.029628, 0.030227, 0.030825, 0.031429, 0.032111, 0.032793, 0.033474, 0.034156, 0.034838, 0.035520, 0.036201, 0.036883, 0.037565, 0.038266, 0.038975, 0.039684, 0.040393, 0.041102, 0.041811, 0.042520, 0.043228, 0.043937, 0.044646, 0.045200, 0.045698, 0.046195, 0.046693, 0.047190, 0.047688, 0.048186, 0.048683, 0.049181, 0.049679, 0.050172, 0.050642, 0.051112, 0.051581, 0.052051, 0.052521, 0.052991, 0.053460, 0.053930, 0.054400, 0.054870, 0.055335, 0.055795, 0.056256, 0.056717, 0.057178, 0.057639, 0.058099, 0.058560, 0.059021, 0.059482, 0.059940, 0.060371, 0.060802, 0.061232, 0.061663, 0.062094, 0.062525, 0.062955, 0.063386, 0.063817, 0.064247, 0.064643, 0.065028, 0.065414, 0.065800, 0.066185, 0.066571, 0.066957, 0.067342, 0.067728, 0.068114, 0.068443, 0.068753, 0.069064, 0.069374, 0.069685, 0.069995, 0.070306, 0.070616, 0.070927, 0.071233, 0.071471, 0.071709, 0.071946, 0.072184, 0.072422, 0.072660, 0.072897, 0.073135, 0.073373, 0.073549, 0.073708, 0.073868, 0.074027, 0.074186, 0.074346, 0.074505, 0.074664, 0.074823, 0.074873, 0.074920, 0.074966, 0.075013, 0.075059, 0.075106, 0.075152, 0.075199, 0.075137, 0.075020, 0.074903, 0.074786, 0.074670, 0.074553, 0.074436, 0.074319, 0.073978, 0.073606, 0.073233, 0.072861, 0.072488, 0.072115, 0.071743, 0.071119, 0.070356, 0.069593, 0.068831, 0.068068, 0.067306, 0.066543, 0.065205, 0.063864, 0.062523, 0.061182, 0.059841, 0.058501, 0.055362, 0.052205, 0.049048, 0.045891, 0.042734, 0.039062, 0.035155, 0.031249, 0.027343, 0.023437, 0.019530, 0.015624, 0.011718, 0.007812, 0.003905, 0.000000], + [0.000000, 0.000500, 0.001050, 0.001608, 0.002124, 0.002641, 0.003061, 0.003303, 0.003534, 0.003731, 0.003895, 0.003860, 0.003920, 0.004480, 0.005071, 0.005740, 0.006429, 0.007182, 0.007935, 0.008852, 0.009777, 0.010736, 0.011738, 0.012740, 0.013790, 0.014871, 0.015953, 0.017110, 0.018378, 0.019646, 0.020914, 0.022253, 0.023603, 0.024952, 0.026301, 0.027757, 0.029220, 0.030684, 0.032148, 0.033662, 0.035214, 0.036765, 0.038316, 0.039868, 0.041479, 0.043107, 0.044734, 0.046362, 0.047990, 0.049693, 0.051446, 0.053199, 0.054951, 0.056704, 0.058458, 0.060353, 0.062248, 0.064143, 0.066038, 0.067933, 0.069828, 0.071984, 0.074141, 0.076298, 0.078455, 0.080612, 0.082769, 0.085098, 0.087516, 0.089934, 0.092353, 0.094771, 0.097190, 0.099608, 0.102268, 0.104958, 0.107648, 0.110338, 0.113028, 0.115718, 0.118408, 0.121306, 0.124302, 0.127299, 0.130295, 0.133292, 0.136288, 0.139284, 0.142281, 0.145455, 0.148629, 0.151804, 0.154979, 0.158153, 0.161328, 0.164503, 0.167677, 0.170547, 0.173344, 0.176141, 0.178938, 0.181735, 0.184532, 0.187329, 0.190126, 0.192895, 0.195221, 0.197546, 0.199871, 0.202196, 0.204522, 0.206847, 0.209172, 0.211497, 0.213823, 0.215741, 0.217504, 0.219267, 0.221030, 0.222793, 0.224556, 0.226319, 0.228082, 0.229845, 0.231608, 0.232962, 0.234169, 0.235376, 0.236582, 0.237789, 0.238996, 0.240202, 0.241409, 0.242616, 0.243822, 0.244972, 0.245824, 0.246675, 0.247527, 0.248378, 0.249229, 0.250081, 0.250932, 0.251784, 0.252635, 0.253487, 0.254150, 0.254663, 0.255176, 0.255689, 0.256201, 0.256714, 0.257227, 0.257740, 0.258253, 0.258766, 0.259249, 0.259381, 0.259513, 0.259645, 0.259777, 0.259909, 0.260041, 0.260173, 0.260305, 0.260437, 0.260570, 0.260342, 0.260015, 0.259689, 0.259363, 0.259036, 0.258710, 0.258383, 0.258057, 0.257731, 0.257404, 0.256644, 0.255745, 0.254845, 0.253946, 0.253046, 0.252147, 0.251248, 0.250348, 0.249449, 0.248501, 0.246825, 0.245149, 0.243472, 0.241796, 0.240119, 0.238443, 0.236767, 0.235090, 0.233414, 0.230383, 0.226974, 0.223565, 0.220155, 0.216746, 0.213337, 0.209928, 0.206518, 0.203109, 0.199218, 0.195312, 0.191405, 0.187499, 0.183593, 0.179687, 0.175780, 0.171874, 0.167968, 0.164062, 0.160155, 0.156249, 0.152343, 0.148437, 0.144530, 0.140624, 0.136718, 0.132812, 0.128905, 0.124999, 0.121093, 0.117187, 0.113280, 0.109374, 0.105468, 0.101562, 0.097655, 0.093749, 0.089843, 0.085937, 0.082030, 0.078124, 0.074218, 0.070312, 0.066405, 0.062499, 0.058593, 0.054687, 0.050780, 0.046874, 0.042968, 0.039062, 0.035155, 0.031249, 0.027343, 0.023437, 0.019530, 0.015624, 0.011718, 0.007812, 0.003905, 0.000000], +]; + +/// Shadows, Darks, Lights, Highlights at the default splits (25, 50, 75). +pub const REGION_AMOUNTS: [f32; 8] = [-100.0, -75.0, -50.0, -25.0, 25.0, 50.0, 75.0, 100.0]; +pub static REGIONS: [[[f32; 257]; 8]; 4] = [ + [ + [0.000000, -0.003906, -0.007812, -0.011719, -0.015625, -0.019531, -0.023438, -0.027344, -0.031250, -0.035156, -0.039062, -0.042969, -0.046875, -0.050781, -0.054687, -0.058593, -0.062499, -0.066404, -0.070310, -0.074214, -0.078119, -0.082020, -0.085917, -0.089814, -0.093689, -0.097549, -0.101408, -0.105222, -0.108969, -0.112716, -0.116463, -0.119858, -0.123204, -0.126550, -0.129896, -0.132087, -0.134192, -0.136297, -0.138402, -0.139029, -0.138591, -0.138153, -0.137715, -0.137277, -0.136208, -0.134968, -0.133728, -0.132488, -0.131248, -0.130007, -0.128764, -0.127522, -0.126280, -0.125038, -0.123793, -0.122191, -0.120589, -0.118988, -0.117386, -0.115784, -0.114182, -0.112299, -0.110414, -0.108530, -0.106645, -0.104760, -0.102875, -0.100853, -0.098758, -0.096664, -0.094569, -0.092474, -0.090380, -0.088285, -0.086074, -0.083848, -0.081623, -0.079397, -0.077171, -0.074945, -0.072719, -0.070470, -0.068210, -0.065950, -0.063690, -0.061429, -0.059169, -0.056909, -0.054648, -0.052496, -0.050343, -0.048191, -0.046039, -0.043887, -0.041734, -0.039582, -0.037430, -0.035503, -0.033629, -0.031756, -0.029882, -0.028009, -0.026135, -0.024262, -0.022388, -0.020543, -0.019148, -0.017753, -0.016358, -0.014963, -0.013569, -0.012174, -0.010779, -0.009384, -0.007989, -0.007096, -0.006394, -0.005692, -0.004989, -0.004287, -0.003585, -0.002883, -0.002181, -0.001479, -0.000777, -0.000550, -0.000494, -0.000438, -0.000382, -0.000326, -0.000270, -0.000214, -0.000159, -0.000103, -0.000047, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], + [0.000000, -0.003906, -0.007810, -0.011714, -0.015617, -0.019520, -0.023420, -0.027317, -0.031213, -0.035106, -0.038996, -0.042869, -0.046738, -0.050579, -0.054409, -0.058210, -0.061993, -0.065718, -0.069443, -0.072985, -0.076518, -0.079914, -0.083141, -0.086369, -0.089272, -0.091958, -0.094644, -0.096916, -0.098582, -0.100248, -0.101914, -0.102339, -0.102591, -0.102842, -0.103094, -0.102809, -0.102485, -0.102160, -0.101836, -0.101648, -0.101559, -0.101469, -0.101380, -0.101290, -0.100926, -0.100488, -0.100049, -0.099610, -0.099171, -0.098507, -0.097696, -0.096884, -0.096073, -0.095261, -0.094447, -0.093356, -0.092265, -0.091174, -0.090084, -0.088993, -0.087902, -0.086539, -0.085174, -0.083810, -0.082445, -0.081080, -0.079715, -0.078211, -0.076633, -0.075055, -0.073477, -0.071899, -0.070321, -0.068743, -0.067045, -0.065333, -0.063620, -0.061908, -0.060195, -0.058482, -0.056770, -0.055028, -0.053272, -0.051517, -0.049761, -0.048005, -0.046250, -0.044494, -0.042738, -0.041056, -0.039375, -0.037694, -0.036012, -0.034331, -0.032650, -0.030969, -0.029287, -0.027782, -0.026319, -0.024855, -0.023392, -0.021929, -0.020466, -0.019003, -0.017539, -0.016098, -0.015009, -0.013919, -0.012830, -0.011740, -0.010651, -0.009561, -0.008472, -0.007382, -0.006293, -0.005591, -0.005039, -0.004486, -0.003933, -0.003380, -0.002827, -0.002274, -0.001722, -0.001169, -0.000616, -0.000437, -0.000392, -0.000348, -0.000304, -0.000259, -0.000215, -0.000170, -0.000126, -0.000082, -0.000037, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], + [0.000000, -0.003889, -0.007766, -0.011628, -0.015484, -0.019325, -0.023153, -0.026956, -0.030743, -0.034487, -0.038207, -0.041789, -0.045327, -0.048632, -0.051842, -0.054816, -0.057642, -0.059991, -0.062341, -0.063894, -0.065409, -0.066430, -0.066845, -0.067260, -0.067075, -0.066490, -0.065904, -0.065464, -0.065235, -0.065006, -0.064777, -0.064648, -0.064532, -0.064417, -0.064302, -0.063994, -0.063672, -0.063350, -0.063027, -0.062616, -0.062141, -0.061666, -0.061190, -0.060715, -0.060164, -0.059592, -0.059020, -0.058449, -0.057877, -0.057219, -0.056506, -0.055792, -0.055079, -0.054365, -0.053651, -0.052854, -0.052057, -0.051260, -0.050464, -0.049667, -0.048870, -0.047994, -0.047118, -0.046242, -0.045365, -0.044489, -0.043613, -0.042704, -0.041779, -0.040854, -0.039928, -0.039003, -0.038078, -0.037152, -0.036206, -0.035257, -0.034309, -0.033360, -0.032411, -0.031463, -0.030514, -0.029568, -0.028622, -0.027676, -0.026731, -0.025785, -0.024839, -0.023894, -0.022948, -0.022057, -0.021166, -0.020276, -0.019385, -0.018494, -0.017603, -0.016712, -0.015821, -0.015026, -0.014254, -0.013482, -0.012710, -0.011938, -0.011166, -0.010394, -0.009622, -0.008861, -0.008269, -0.007678, -0.007087, -0.006495, -0.005904, -0.005312, -0.004721, -0.004129, -0.003538, -0.003150, -0.002841, -0.002531, -0.002221, -0.001912, -0.001602, -0.001292, -0.000983, -0.000673, -0.000363, -0.000262, -0.000235, -0.000209, -0.000182, -0.000155, -0.000129, -0.000102, -0.000076, -0.000049, -0.000022, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], + [0.000000, -0.003216, -0.006332, -0.009343, -0.012326, -0.015215, -0.018012, -0.020640, -0.023188, -0.025512, -0.027735, -0.029351, -0.030826, -0.031553, -0.032123, -0.032295, -0.032353, -0.032045, -0.031737, -0.032000, -0.032289, -0.032629, -0.033031, -0.033434, -0.033802, -0.034148, -0.034493, -0.034792, -0.035021, -0.035251, -0.035480, -0.035605, -0.035715, -0.035825, -0.035935, -0.035913, -0.035882, -0.035851, -0.035820, -0.035735, -0.035609, -0.035484, -0.035359, -0.035234, -0.035025, -0.034794, -0.034563, -0.034332, -0.034101, -0.033801, -0.033455, -0.033109, -0.032763, -0.032417, -0.032070, -0.031651, -0.031232, -0.030812, -0.030393, -0.029974, -0.029555, -0.029057, -0.028559, -0.028061, -0.027563, -0.027065, -0.026567, -0.026037, -0.025490, -0.024943, -0.024396, -0.023849, -0.023303, -0.022756, -0.022183, -0.021607, -0.021032, -0.020456, -0.019880, -0.019304, -0.018729, -0.018149, -0.017566, -0.016984, -0.016402, -0.015820, -0.015238, -0.014655, -0.014073, -0.013525, -0.012977, -0.012429, -0.011880, -0.011332, -0.010784, -0.010236, -0.009688, -0.009199, -0.008724, -0.008250, -0.007775, -0.007301, -0.006826, -0.006352, -0.005877, -0.005409, -0.005050, -0.004690, -0.004331, -0.003971, -0.003612, -0.003253, -0.002893, -0.002534, -0.002174, -0.001938, -0.001748, -0.001559, -0.001369, -0.001180, -0.000990, -0.000801, -0.000611, -0.000422, -0.000232, -0.000169, -0.000152, -0.000135, -0.000118, -0.000101, -0.000083, -0.000066, -0.000049, -0.000032, -0.000014, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], + [0.000000, 0.003646, 0.006659, 0.009375, 0.011731, 0.013420, 0.014676, 0.015142, 0.015370, 0.014932, 0.014561, 0.014594, 0.014704, 0.015220, 0.015721, 0.016189, 0.016651, 0.017095, 0.017538, 0.017972, 0.018404, 0.018805, 0.019166, 0.019527, 0.019867, 0.020193, 0.020519, 0.020826, 0.021106, 0.021387, 0.021667, 0.021886, 0.022098, 0.022309, 0.022520, 0.022666, 0.022807, 0.022948, 0.023088, 0.023182, 0.023242, 0.023302, 0.023362, 0.023422, 0.023400, 0.023355, 0.023310, 0.023265, 0.023221, 0.023123, 0.022990, 0.022858, 0.022725, 0.022592, 0.022459, 0.022224, 0.021989, 0.021754, 0.021519, 0.021284, 0.021049, 0.020741, 0.020433, 0.020124, 0.019816, 0.019508, 0.019199, 0.018846, 0.018470, 0.018094, 0.017718, 0.017341, 0.016965, 0.016589, 0.016177, 0.015761, 0.015345, 0.014929, 0.014513, 0.014097, 0.013681, 0.013261, 0.012839, 0.012416, 0.011994, 0.011572, 0.011150, 0.010728, 0.010306, 0.009902, 0.009498, 0.009094, 0.008689, 0.008285, 0.007881, 0.007477, 0.007073, 0.006710, 0.006356, 0.006003, 0.005650, 0.005297, 0.004943, 0.004590, 0.004237, 0.003889, 0.003626, 0.003364, 0.003102, 0.002840, 0.002577, 0.002315, 0.002053, 0.001791, 0.001528, 0.001357, 0.001221, 0.001085, 0.000948, 0.000812, 0.000676, 0.000540, 0.000404, 0.000267, 0.000131, 0.000088, 0.000079, 0.000070, 0.000061, 0.000052, 0.000043, 0.000034, 0.000026, 0.000017, 0.000008, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], + [0.000000, 0.009101, 0.016045, 0.021283, 0.025025, 0.026425, 0.027479, 0.027901, 0.028224, 0.028275, 0.028387, 0.028865, 0.029436, 0.030492, 0.031508, 0.032421, 0.033364, 0.034399, 0.035435, 0.036317, 0.037192, 0.038050, 0.038889, 0.039728, 0.040518, 0.041276, 0.042034, 0.042754, 0.043416, 0.044078, 0.044741, 0.045302, 0.045849, 0.046396, 0.046943, 0.047349, 0.047744, 0.048140, 0.048536, 0.048827, 0.049044, 0.049260, 0.049476, 0.049693, 0.049744, 0.049751, 0.049758, 0.049765, 0.049772, 0.049646, 0.049434, 0.049222, 0.049010, 0.048798, 0.048584, 0.048137, 0.047690, 0.047243, 0.046796, 0.046348, 0.045901, 0.045257, 0.044610, 0.043964, 0.043318, 0.042672, 0.042026, 0.041275, 0.040470, 0.039665, 0.038860, 0.038055, 0.037250, 0.036444, 0.035538, 0.034620, 0.033702, 0.032783, 0.031865, 0.030947, 0.030028, 0.029095, 0.028155, 0.027215, 0.026275, 0.025335, 0.024395, 0.023455, 0.022515, 0.021619, 0.020723, 0.019827, 0.018931, 0.018034, 0.017138, 0.016242, 0.015346, 0.014552, 0.013783, 0.013014, 0.012245, 0.011476, 0.010707, 0.009938, 0.009168, 0.008411, 0.007845, 0.007278, 0.006712, 0.006145, 0.005579, 0.005012, 0.004445, 0.003879, 0.003312, 0.002945, 0.002654, 0.002363, 0.002071, 0.001780, 0.001489, 0.001198, 0.000906, 0.000615, 0.000324, 0.000229, 0.000206, 0.000183, 0.000159, 0.000136, 0.000113, 0.000090, 0.000066, 0.000043, 0.000020, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], + [0.000000, 0.016424, 0.026872, 0.032718, 0.036179, 0.037852, 0.039251, 0.040147, 0.040939, 0.041440, 0.042015, 0.043039, 0.044157, 0.045770, 0.047360, 0.048891, 0.050438, 0.052038, 0.053639, 0.055094, 0.056543, 0.057972, 0.059376, 0.060780, 0.062128, 0.063438, 0.064749, 0.066005, 0.067181, 0.068356, 0.069532, 0.070566, 0.071581, 0.072595, 0.073610, 0.074423, 0.075221, 0.076019, 0.076817, 0.077447, 0.077957, 0.078467, 0.078977, 0.079487, 0.079717, 0.079872, 0.080026, 0.080181, 0.080336, 0.080261, 0.080036, 0.079811, 0.079586, 0.079361, 0.079132, 0.078488, 0.077845, 0.077201, 0.076558, 0.075914, 0.075270, 0.074259, 0.073245, 0.072231, 0.071217, 0.070203, 0.069189, 0.067969, 0.066640, 0.065312, 0.063983, 0.062655, 0.061327, 0.059998, 0.058504, 0.056989, 0.055474, 0.053959, 0.052444, 0.050929, 0.049414, 0.047861, 0.046290, 0.044719, 0.043148, 0.041577, 0.040006, 0.038435, 0.036864, 0.035383, 0.033902, 0.032421, 0.030940, 0.029460, 0.027979, 0.026498, 0.025017, 0.023711, 0.022447, 0.021184, 0.019920, 0.018656, 0.017392, 0.016128, 0.014864, 0.013620, 0.012702, 0.011785, 0.010867, 0.009949, 0.009031, 0.008113, 0.007195, 0.006278, 0.005360, 0.004765, 0.004294, 0.003823, 0.003353, 0.002882, 0.002411, 0.001940, 0.001469, 0.000998, 0.000527, 0.000374, 0.000336, 0.000298, 0.000260, 0.000222, 0.000184, 0.000146, 0.000108, 0.000070, 0.000032, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], + [0.000000, 0.025013, 0.036949, 0.042838, 0.046705, 0.048947, 0.050910, 0.052362, 0.053694, 0.054690, 0.055763, 0.057303, 0.058964, 0.061264, 0.063530, 0.065707, 0.067897, 0.070128, 0.072358, 0.074526, 0.076691, 0.078814, 0.080885, 0.082956, 0.084966, 0.086934, 0.088903, 0.090823, 0.092674, 0.094525, 0.096376, 0.098048, 0.099696, 0.101343, 0.102991, 0.104385, 0.105761, 0.107137, 0.108512, 0.109656, 0.110634, 0.111611, 0.112588, 0.113565, 0.114129, 0.114580, 0.115032, 0.115483, 0.115935, 0.116025, 0.115879, 0.115733, 0.115587, 0.115441, 0.115289, 0.114462, 0.113635, 0.112808, 0.111982, 0.111155, 0.110328, 0.108885, 0.107438, 0.105990, 0.104543, 0.103096, 0.101648, 0.099869, 0.097916, 0.095962, 0.094009, 0.092055, 0.090102, 0.088148, 0.085917, 0.083652, 0.081387, 0.079122, 0.076857, 0.074592, 0.072327, 0.070013, 0.067676, 0.065339, 0.063001, 0.060664, 0.058327, 0.055990, 0.053653, 0.051465, 0.049278, 0.047092, 0.044905, 0.042718, 0.040531, 0.038344, 0.036158, 0.034252, 0.032414, 0.030575, 0.028737, 0.026898, 0.025060, 0.023222, 0.021383, 0.019575, 0.018249, 0.016923, 0.015598, 0.014272, 0.012946, 0.011621, 0.010295, 0.008969, 0.007644, 0.006791, 0.006119, 0.005447, 0.004775, 0.004103, 0.003431, 0.002759, 0.002087, 0.001415, 0.000743, 0.000525, 0.000472, 0.000418, 0.000365, 0.000312, 0.000258, 0.000205, 0.000152, 0.000098, 0.000045, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], + ], + [ + [0.000000, -0.003906, -0.007812, -0.011719, -0.015625, -0.019531, -0.023438, -0.027344, -0.031250, -0.035156, -0.039062, -0.042969, -0.046875, -0.050781, -0.054688, -0.058594, -0.062500, -0.066406, -0.070312, -0.074219, -0.078125, -0.082031, -0.085938, -0.089844, -0.093750, -0.097656, -0.101562, -0.105469, -0.109375, -0.113281, -0.117187, -0.121093, -0.124999, -0.128906, -0.132812, -0.136717, -0.140621, -0.144526, -0.148431, -0.152333, -0.156234, -0.160135, -0.164036, -0.167937, -0.171819, -0.175697, -0.179574, -0.183452, -0.187329, -0.191141, -0.194911, -0.198680, -0.202449, -0.206219, -0.209984, -0.213377, -0.216770, -0.220162, -0.223555, -0.226947, -0.230340, -0.232560, -0.234772, -0.236984, -0.239196, -0.241409, -0.243621, -0.244545, -0.244792, -0.245038, -0.245285, -0.245532, -0.245779, -0.246025, -0.246172, -0.246307, -0.246442, -0.246576, -0.246711, -0.246845, -0.246980, -0.246882, -0.246673, -0.246464, -0.246254, -0.246045, -0.245836, -0.245627, -0.245418, -0.244803, -0.244185, -0.243568, -0.242951, -0.242334, -0.241716, -0.241099, -0.240482, -0.239553, -0.238550, -0.237547, -0.236544, -0.235540, -0.234537, -0.233534, -0.232531, -0.231509, -0.230200, -0.228890, -0.227580, -0.226271, -0.224961, -0.223651, -0.222342, -0.221032, -0.219723, -0.218225, -0.216656, -0.215087, -0.213517, -0.211948, -0.210379, -0.208810, -0.207241, -0.205671, -0.204102, -0.202374, -0.200589, -0.198804, -0.197019, -0.195235, -0.193450, -0.191665, -0.189880, -0.188095, -0.186310, -0.184500, -0.182559, -0.180619, -0.178678, -0.176738, -0.174798, -0.172857, -0.170917, -0.168976, -0.167036, -0.165095, -0.163099, -0.161058, -0.159017, -0.156976, -0.154936, -0.152895, -0.150854, -0.148813, -0.146772, -0.144731, -0.142686, -0.140594, -0.138502, -0.136410, -0.134318, -0.132226, -0.130134, -0.128042, -0.125950, -0.123858, -0.121766, -0.119682, -0.117600, -0.115518, -0.113436, -0.111355, -0.109273, -0.107191, -0.105109, -0.103027, -0.100945, -0.098905, -0.096878, -0.094851, -0.092824, -0.090797, -0.088770, -0.086743, -0.084717, -0.082690, -0.080669, -0.078748, -0.076826, -0.074905, -0.072983, -0.071062, -0.069140, -0.067219, -0.065297, -0.063375, -0.061571, -0.059799, -0.058027, -0.056255, -0.054484, -0.052712, -0.050940, -0.049168, -0.047396, -0.045808, -0.044226, -0.042644, -0.041063, -0.039481, -0.037899, -0.036317, -0.034735, -0.033291, -0.031918, -0.030545, -0.029173, -0.027800, -0.026427, -0.025054, -0.023681, -0.022501, -0.021348, -0.020196, -0.019043, -0.017890, -0.016738, -0.015585, -0.014581, -0.013657, -0.012734, -0.011811, -0.010888, -0.009964, -0.009041, -0.008335, -0.007630, -0.006925, -0.006220, -0.005514, -0.004809, -0.004309, -0.003811, -0.003313, -0.002815, -0.002317, -0.001941, -0.001619, -0.001297, -0.000976, -0.000683, -0.000518, -0.000353, -0.000188, -0.000092, -0.000046, 0.000000], + [0.000000, -0.003906, -0.007812, -0.011717, -0.015622, -0.019528, -0.023434, -0.027338, -0.031242, -0.035145, -0.039048, -0.042950, -0.046852, -0.050752, -0.054650, -0.058542, -0.062434, -0.066322, -0.070211, -0.074086, -0.077960, -0.081820, -0.085661, -0.089502, -0.093311, -0.097100, -0.100888, -0.104624, -0.108282, -0.111941, -0.115599, -0.119092, -0.122562, -0.126032, -0.129502, -0.132580, -0.135629, -0.138678, -0.141728, -0.144400, -0.146802, -0.149204, -0.151605, -0.154007, -0.155625, -0.157031, -0.158436, -0.159842, -0.161247, -0.162285, -0.163082, -0.163880, -0.164677, -0.165474, -0.166274, -0.167365, -0.168456, -0.169547, -0.170638, -0.171729, -0.172819, -0.173662, -0.174504, -0.175345, -0.176186, -0.177028, -0.177869, -0.178537, -0.179113, -0.179690, -0.180267, -0.180843, -0.181420, -0.181997, -0.182333, -0.182640, -0.182947, -0.183253, -0.183560, -0.183867, -0.184174, -0.184268, -0.184262, -0.184256, -0.184250, -0.184244, -0.184238, -0.184232, -0.184226, -0.183930, -0.183633, -0.183336, -0.183039, -0.182742, -0.182445, -0.182148, -0.181851, -0.181319, -0.180731, -0.180143, -0.179554, -0.178966, -0.178378, -0.177789, -0.177201, -0.176597, -0.175739, -0.174881, -0.174023, -0.173166, -0.172308, -0.171450, -0.170592, -0.169734, -0.168876, -0.167842, -0.166740, -0.165638, -0.164537, -0.163435, -0.162333, -0.161232, -0.160130, -0.159028, -0.157927, -0.156676, -0.155371, -0.154066, -0.152762, -0.151457, -0.150152, -0.148847, -0.147543, -0.146238, -0.144933, -0.143603, -0.142137, -0.140671, -0.139205, -0.137739, -0.136274, -0.134808, -0.133342, -0.131876, -0.130410, -0.128944, -0.127420, -0.125848, -0.124276, -0.122704, -0.121133, -0.119561, -0.117989, -0.116417, -0.114845, -0.113274, -0.111698, -0.110072, -0.108446, -0.106820, -0.105194, -0.103568, -0.101942, -0.100316, -0.098690, -0.097064, -0.095438, -0.093809, -0.092180, -0.090550, -0.088921, -0.087291, -0.085662, -0.084032, -0.082403, -0.080773, -0.079144, -0.077546, -0.075959, -0.074372, -0.072785, -0.071198, -0.069611, -0.068024, -0.066437, -0.064850, -0.063268, -0.061761, -0.060254, -0.058748, -0.057241, -0.055735, -0.054228, -0.052722, -0.051215, -0.049709, -0.048298, -0.046915, -0.045531, -0.044148, -0.042764, -0.041380, -0.039997, -0.038613, -0.037230, -0.035986, -0.034747, -0.033507, -0.032268, -0.031029, -0.029789, -0.028550, -0.027310, -0.026179, -0.025103, -0.024027, -0.022951, -0.021875, -0.020798, -0.019722, -0.018646, -0.017719, -0.016812, -0.015906, -0.014999, -0.014093, -0.013186, -0.012280, -0.011490, -0.010765, -0.010040, -0.009316, -0.008591, -0.007866, -0.007141, -0.006584, -0.006028, -0.005472, -0.004916, -0.004360, -0.003804, -0.003410, -0.003017, -0.002625, -0.002233, -0.001840, -0.001542, -0.001286, -0.001030, -0.000774, -0.000541, -0.000410, -0.000279, -0.000148, -0.000072, -0.000036, 0.000000], + [0.000000, -0.003896, -0.007794, -0.011686, -0.015574, -0.019462, -0.023345, -0.027217, -0.031086, -0.034947, -0.038802, -0.042626, -0.046444, -0.050238, -0.054009, -0.057720, -0.061406, -0.065011, -0.068615, -0.072035, -0.075446, -0.078709, -0.081790, -0.084872, -0.087704, -0.090369, -0.093035, -0.095368, -0.097214, -0.099060, -0.100906, -0.101989, -0.102964, -0.103939, -0.104914, -0.105335, -0.105714, -0.106094, -0.106474, -0.107069, -0.107820, -0.108570, -0.109321, -0.110071, -0.110713, -0.111326, -0.111938, -0.112550, -0.113163, -0.113641, -0.114032, -0.114423, -0.114814, -0.115205, -0.115595, -0.115822, -0.116050, -0.116277, -0.116505, -0.116732, -0.116960, -0.116991, -0.117021, -0.117052, -0.117082, -0.117112, -0.117142, -0.117070, -0.116945, -0.116820, -0.116695, -0.116570, -0.116444, -0.116319, -0.116069, -0.115804, -0.115539, -0.115274, -0.115009, -0.114743, -0.114478, -0.114121, -0.113720, -0.113318, -0.112917, -0.112516, -0.112114, -0.111713, -0.111312, -0.110791, -0.110269, -0.109748, -0.109226, -0.108704, -0.108183, -0.107661, -0.107140, -0.106545, -0.105933, -0.105321, -0.104709, -0.104096, -0.103484, -0.102872, -0.102260, -0.101643, -0.100944, -0.100245, -0.099546, -0.098846, -0.098147, -0.097448, -0.096749, -0.096050, -0.095351, -0.094604, -0.093838, -0.093073, -0.092308, -0.091542, -0.090777, -0.090012, -0.089246, -0.088481, -0.087716, -0.086909, -0.086088, -0.085266, -0.084445, -0.083623, -0.082802, -0.081980, -0.081159, -0.080337, -0.079516, -0.078688, -0.077828, -0.076968, -0.076109, -0.075249, -0.074389, -0.073529, -0.072669, -0.071810, -0.070950, -0.070090, -0.069215, -0.068328, -0.067441, -0.066554, -0.065667, -0.064781, -0.063894, -0.063007, -0.062120, -0.061233, -0.060346, -0.059456, -0.058566, -0.057676, -0.056786, -0.055896, -0.055006, -0.054116, -0.053226, -0.052336, -0.051447, -0.050570, -0.049697, -0.048824, -0.047950, -0.047077, -0.046204, -0.045331, -0.044458, -0.043585, -0.042712, -0.041861, -0.041019, -0.040176, -0.039333, -0.038490, -0.037647, -0.036804, -0.035962, -0.035119, -0.034279, -0.033476, -0.032674, -0.031871, -0.031069, -0.030266, -0.029463, -0.028661, -0.027858, -0.027056, -0.026307, -0.025573, -0.024839, -0.024105, -0.023371, -0.022638, -0.021904, -0.021170, -0.020436, -0.019767, -0.019101, -0.018435, -0.017768, -0.017102, -0.016435, -0.015769, -0.015102, -0.014491, -0.013909, -0.013326, -0.012744, -0.012161, -0.011579, -0.010996, -0.010414, -0.009906, -0.009408, -0.008910, -0.008412, -0.007914, -0.007417, -0.006919, -0.006483, -0.006081, -0.005679, -0.005277, -0.004875, -0.004473, -0.004071, -0.003755, -0.003438, -0.003122, -0.002806, -0.002490, -0.002174, -0.001953, -0.001733, -0.001512, -0.001292, -0.001072, -0.000900, -0.000750, -0.000601, -0.000451, -0.000316, -0.000241, -0.000165, -0.000090, -0.000045, -0.000023, 0.000000], + [0.000000, -0.003245, -0.006451, -0.009562, -0.012604, -0.015620, -0.018545, -0.021305, -0.024020, -0.026613, -0.029128, -0.031179, -0.033102, -0.034352, -0.035460, -0.036218, -0.036875, -0.037210, -0.037546, -0.037927, -0.038310, -0.038883, -0.039689, -0.040494, -0.041371, -0.042295, -0.043219, -0.044099, -0.044914, -0.045729, -0.046543, -0.047334, -0.048121, -0.048909, -0.049696, -0.050409, -0.051117, -0.051824, -0.052532, -0.053184, -0.053796, -0.054408, -0.055020, -0.055632, -0.056188, -0.056729, -0.057271, -0.057812, -0.058353, -0.058826, -0.059254, -0.059683, -0.060111, -0.060540, -0.060967, -0.061309, -0.061650, -0.061992, -0.062333, -0.062675, -0.063016, -0.063236, -0.063455, -0.063673, -0.063892, -0.064110, -0.064329, -0.064479, -0.064594, -0.064708, -0.064823, -0.064937, -0.065051, -0.065166, -0.065188, -0.065199, -0.065210, -0.065221, -0.065232, -0.065243, -0.065254, -0.065196, -0.065105, -0.065014, -0.064923, -0.064833, -0.064742, -0.064651, -0.064560, -0.064371, -0.064181, -0.063992, -0.063802, -0.063612, -0.063423, -0.063233, -0.063043, -0.062789, -0.062520, -0.062250, -0.061981, -0.061712, -0.061442, -0.061173, -0.060903, -0.060629, -0.060277, -0.059925, -0.059573, -0.059221, -0.058870, -0.058518, -0.058166, -0.057814, -0.057462, -0.057064, -0.056648, -0.056232, -0.055816, -0.055400, -0.054984, -0.054568, -0.054152, -0.053736, -0.053320, -0.052863, -0.052392, -0.051922, -0.051451, -0.050980, -0.050509, -0.050038, -0.049568, -0.049097, -0.048626, -0.048148, -0.047635, -0.047122, -0.046608, -0.046095, -0.045582, -0.045068, -0.044555, -0.044042, -0.043529, -0.043015, -0.042489, -0.041953, -0.041418, -0.040882, -0.040346, -0.039810, -0.039274, -0.038738, -0.038202, -0.037666, -0.037130, -0.036584, -0.036039, -0.035494, -0.034948, -0.034403, -0.033858, -0.033312, -0.032767, -0.032222, -0.031676, -0.031135, -0.030594, -0.030053, -0.029512, -0.028972, -0.028431, -0.027890, -0.027349, -0.026809, -0.026268, -0.025741, -0.025218, -0.024695, -0.024173, -0.023650, -0.023127, -0.022604, -0.022082, -0.021559, -0.021038, -0.020543, -0.020047, -0.019552, -0.019057, -0.018562, -0.018066, -0.017571, -0.017076, -0.016580, -0.016117, -0.015661, -0.015206, -0.014751, -0.014296, -0.013841, -0.013386, -0.012931, -0.012476, -0.012068, -0.011661, -0.011255, -0.010848, -0.010441, -0.010035, -0.009628, -0.009222, -0.008848, -0.008491, -0.008134, -0.007776, -0.007419, -0.007062, -0.006705, -0.006348, -0.006035, -0.005729, -0.005423, -0.005116, -0.004810, -0.004503, -0.004197, -0.003931, -0.003687, -0.003444, -0.003200, -0.002957, -0.002713, -0.002469, -0.002280, -0.002092, -0.001903, -0.001714, -0.001526, -0.001337, -0.001202, -0.001067, -0.000933, -0.000798, -0.000664, -0.000555, -0.000457, -0.000359, -0.000262, -0.000174, -0.000132, -0.000090, -0.000047, -0.000023, -0.000011, 0.000000], + [0.000000, 0.003733, 0.006885, 0.009623, 0.011999, 0.013697, 0.014974, 0.015479, 0.015753, 0.015382, 0.015074, 0.015142, 0.015300, 0.015928, 0.016523, 0.017035, 0.017575, 0.018207, 0.018839, 0.019385, 0.019926, 0.020457, 0.020973, 0.021490, 0.022018, 0.022555, 0.023091, 0.023617, 0.024128, 0.024639, 0.025149, 0.025657, 0.026163, 0.026670, 0.027177, 0.027654, 0.028129, 0.028604, 0.029079, 0.029548, 0.030014, 0.030480, 0.030946, 0.031412, 0.031837, 0.032250, 0.032663, 0.033077, 0.033490, 0.033884, 0.034267, 0.034649, 0.035031, 0.035414, 0.035795, 0.036135, 0.036474, 0.036813, 0.037152, 0.037491, 0.037830, 0.038118, 0.038406, 0.038694, 0.038982, 0.039270, 0.039557, 0.039805, 0.040033, 0.040260, 0.040487, 0.040714, 0.040941, 0.041168, 0.041329, 0.041483, 0.041637, 0.041790, 0.041944, 0.042097, 0.042251, 0.042362, 0.042453, 0.042544, 0.042635, 0.042727, 0.042818, 0.042909, 0.043000, 0.043004, 0.043007, 0.043010, 0.043013, 0.043017, 0.043020, 0.043023, 0.043027, 0.042961, 0.042879, 0.042797, 0.042716, 0.042634, 0.042552, 0.042470, 0.042388, 0.042302, 0.042144, 0.041986, 0.041828, 0.041670, 0.041512, 0.041354, 0.041196, 0.041039, 0.040881, 0.040665, 0.040428, 0.040191, 0.039954, 0.039717, 0.039480, 0.039243, 0.039005, 0.038768, 0.038531, 0.038245, 0.037941, 0.037637, 0.037333, 0.037030, 0.036726, 0.036422, 0.036118, 0.035814, 0.035510, 0.035198, 0.034841, 0.034484, 0.034127, 0.033770, 0.033413, 0.033055, 0.032698, 0.032341, 0.031984, 0.031627, 0.031251, 0.030860, 0.030469, 0.030078, 0.029686, 0.029295, 0.028904, 0.028513, 0.028122, 0.027731, 0.027339, 0.026936, 0.026534, 0.026132, 0.025729, 0.025327, 0.024925, 0.024522, 0.024120, 0.023717, 0.023315, 0.022911, 0.022506, 0.022101, 0.021696, 0.021291, 0.020886, 0.020481, 0.020076, 0.019671, 0.019266, 0.018872, 0.018481, 0.018090, 0.017700, 0.017309, 0.016919, 0.016528, 0.016137, 0.015747, 0.015358, 0.014991, 0.014624, 0.014257, 0.013890, 0.013523, 0.013156, 0.012789, 0.012423, 0.012056, 0.011713, 0.011377, 0.011041, 0.010705, 0.010370, 0.010034, 0.009698, 0.009362, 0.009026, 0.008726, 0.008427, 0.008128, 0.007830, 0.007531, 0.007232, 0.006933, 0.006634, 0.006361, 0.006101, 0.005841, 0.005580, 0.005320, 0.005060, 0.004800, 0.004540, 0.004318, 0.004101, 0.003884, 0.003668, 0.003451, 0.003235, 0.003018, 0.002826, 0.002648, 0.002469, 0.002290, 0.002112, 0.001933, 0.001755, 0.001621, 0.001487, 0.001353, 0.001219, 0.001085, 0.000951, 0.000849, 0.000749, 0.000648, 0.000547, 0.000446, 0.000373, 0.000313, 0.000253, 0.000193, 0.000138, 0.000106, 0.000075, 0.000043, 0.000023, 0.000011, 0.000000], + [0.000000, 0.009208, 0.016334, 0.021551, 0.025264, 0.026740, 0.027861, 0.028333, 0.028707, 0.028808, 0.028974, 0.029541, 0.030206, 0.031393, 0.032549, 0.033632, 0.034735, 0.035905, 0.037075, 0.038197, 0.039317, 0.040428, 0.041528, 0.042628, 0.043718, 0.044802, 0.045887, 0.046964, 0.048033, 0.049102, 0.050170, 0.051216, 0.052258, 0.053300, 0.054342, 0.055360, 0.056375, 0.057391, 0.058407, 0.059397, 0.060370, 0.061342, 0.062315, 0.063287, 0.064219, 0.065139, 0.066059, 0.066979, 0.067900, 0.068793, 0.069668, 0.070544, 0.071419, 0.072295, 0.073169, 0.073942, 0.074715, 0.075488, 0.076261, 0.077035, 0.077808, 0.078506, 0.079203, 0.079900, 0.080598, 0.081295, 0.081993, 0.082610, 0.083185, 0.083760, 0.084335, 0.084910, 0.085485, 0.086060, 0.086515, 0.086956, 0.087396, 0.087836, 0.088276, 0.088717, 0.089157, 0.089497, 0.089789, 0.090081, 0.090373, 0.090665, 0.090957, 0.091249, 0.091541, 0.091651, 0.091761, 0.091871, 0.091980, 0.092090, 0.092200, 0.092310, 0.092419, 0.092373, 0.092290, 0.092206, 0.092122, 0.092039, 0.091955, 0.091872, 0.091788, 0.091693, 0.091414, 0.091134, 0.090854, 0.090575, 0.090295, 0.090016, 0.089736, 0.089456, 0.089177, 0.088761, 0.088293, 0.087825, 0.087356, 0.086888, 0.086420, 0.085952, 0.085484, 0.085016, 0.084547, 0.083951, 0.083309, 0.082666, 0.082024, 0.081382, 0.080739, 0.080097, 0.079454, 0.078812, 0.078170, 0.077506, 0.076729, 0.075953, 0.075177, 0.074400, 0.073624, 0.072847, 0.072071, 0.071295, 0.070518, 0.069742, 0.068918, 0.068057, 0.067196, 0.066335, 0.065474, 0.064612, 0.063751, 0.062890, 0.062029, 0.061168, 0.060304, 0.059402, 0.058501, 0.057600, 0.056699, 0.055798, 0.054897, 0.053995, 0.053094, 0.052193, 0.051292, 0.050390, 0.049487, 0.048584, 0.047681, 0.046779, 0.045876, 0.044973, 0.044070, 0.043167, 0.042265, 0.041387, 0.040518, 0.039649, 0.038780, 0.037910, 0.037041, 0.036172, 0.035303, 0.034433, 0.033568, 0.032758, 0.031948, 0.031139, 0.030329, 0.029519, 0.028710, 0.027900, 0.027090, 0.026280, 0.025526, 0.024786, 0.024047, 0.023308, 0.022568, 0.021829, 0.021090, 0.020350, 0.019611, 0.018953, 0.018297, 0.017641, 0.016985, 0.016330, 0.015674, 0.015018, 0.014362, 0.013769, 0.013206, 0.012644, 0.012082, 0.011520, 0.010958, 0.010396, 0.009833, 0.009349, 0.008876, 0.008402, 0.007929, 0.007455, 0.006982, 0.006509, 0.006094, 0.005712, 0.005330, 0.004948, 0.004566, 0.004184, 0.003802, 0.003509, 0.003217, 0.002925, 0.002633, 0.002341, 0.002049, 0.001834, 0.001621, 0.001407, 0.001193, 0.000980, 0.000822, 0.000691, 0.000559, 0.000427, 0.000307, 0.000234, 0.000162, 0.000090, 0.000046, 0.000023, 0.000000], + [0.000000, 0.016424, 0.027008, 0.032906, 0.036341, 0.038091, 0.039557, 0.040504, 0.041346, 0.041896, 0.042523, 0.043617, 0.044814, 0.046556, 0.048276, 0.049941, 0.051629, 0.053393, 0.055157, 0.056839, 0.058518, 0.060201, 0.061890, 0.063580, 0.065239, 0.066879, 0.068519, 0.070164, 0.071818, 0.073472, 0.075127, 0.076752, 0.078373, 0.079994, 0.081615, 0.083234, 0.084852, 0.086471, 0.088089, 0.089686, 0.091267, 0.092848, 0.094429, 0.096010, 0.097533, 0.099041, 0.100548, 0.102055, 0.103562, 0.105039, 0.106496, 0.107952, 0.109409, 0.110866, 0.112321, 0.113668, 0.115015, 0.116362, 0.117709, 0.119057, 0.120404, 0.121643, 0.122882, 0.124121, 0.125360, 0.126599, 0.127838, 0.128971, 0.130047, 0.131123, 0.132199, 0.133276, 0.134352, 0.135428, 0.136325, 0.137200, 0.138075, 0.138950, 0.139825, 0.140700, 0.141575, 0.142288, 0.142924, 0.143560, 0.144197, 0.144833, 0.145469, 0.146105, 0.146741, 0.147086, 0.147430, 0.147774, 0.148117, 0.148461, 0.148804, 0.149148, 0.149492, 0.149568, 0.149580, 0.149592, 0.149604, 0.149616, 0.149628, 0.149640, 0.149652, 0.149643, 0.149297, 0.148951, 0.148605, 0.148259, 0.147913, 0.147567, 0.147221, 0.146875, 0.146529, 0.145923, 0.145218, 0.144513, 0.143807, 0.143102, 0.142397, 0.141692, 0.140986, 0.140281, 0.139576, 0.138635, 0.137610, 0.136584, 0.135559, 0.134534, 0.133508, 0.132483, 0.131457, 0.130432, 0.129407, 0.128340, 0.127060, 0.125779, 0.124498, 0.123217, 0.121937, 0.120656, 0.119375, 0.118094, 0.116814, 0.115533, 0.114162, 0.112719, 0.111277, 0.109834, 0.108391, 0.106948, 0.105506, 0.104063, 0.102620, 0.101177, 0.099729, 0.098216, 0.096703, 0.095190, 0.093677, 0.092163, 0.090650, 0.089137, 0.087624, 0.086111, 0.084597, 0.083086, 0.081575, 0.080065, 0.078554, 0.077043, 0.075532, 0.074022, 0.072511, 0.071000, 0.069490, 0.068024, 0.066574, 0.065123, 0.063672, 0.062222, 0.060771, 0.059321, 0.057870, 0.056419, 0.054975, 0.053631, 0.052286, 0.050941, 0.049597, 0.048252, 0.046907, 0.045563, 0.044218, 0.042874, 0.041628, 0.040410, 0.039193, 0.037975, 0.036757, 0.035540, 0.034322, 0.033104, 0.031886, 0.030809, 0.029736, 0.028662, 0.027589, 0.026516, 0.025443, 0.024369, 0.023296, 0.022324, 0.021403, 0.020482, 0.019561, 0.018641, 0.017720, 0.016799, 0.015878, 0.015091, 0.014324, 0.013556, 0.012788, 0.012020, 0.011252, 0.010485, 0.009816, 0.009200, 0.008585, 0.007970, 0.007355, 0.006740, 0.006125, 0.005652, 0.005180, 0.004708, 0.004236, 0.003764, 0.003292, 0.002949, 0.002607, 0.002265, 0.001924, 0.001582, 0.001330, 0.001118, 0.000907, 0.000695, 0.000500, 0.000380, 0.000260, 0.000140, 0.000069, 0.000034, 0.000000], + [0.000000, 0.025013, 0.036949, 0.042838, 0.046717, 0.049017, 0.051023, 0.052492, 0.053831, 0.054810, 0.055876, 0.057465, 0.059174, 0.061515, 0.063827, 0.066068, 0.068332, 0.070669, 0.073007, 0.075282, 0.077555, 0.079832, 0.082114, 0.084397, 0.086660, 0.088911, 0.091163, 0.093429, 0.095718, 0.098006, 0.100295, 0.102560, 0.104823, 0.107085, 0.109347, 0.111619, 0.113892, 0.116165, 0.118438, 0.120705, 0.122967, 0.125229, 0.127492, 0.129754, 0.131964, 0.134161, 0.136358, 0.138554, 0.140751, 0.142934, 0.145107, 0.147280, 0.149453, 0.151626, 0.153799, 0.155865, 0.157932, 0.159999, 0.162066, 0.164132, 0.166199, 0.168152, 0.170103, 0.172055, 0.174007, 0.175958, 0.177910, 0.179744, 0.181516, 0.183287, 0.185059, 0.186831, 0.188603, 0.190374, 0.191918, 0.193433, 0.194948, 0.196463, 0.197978, 0.199494, 0.201009, 0.202300, 0.203485, 0.204670, 0.205854, 0.207039, 0.208224, 0.209409, 0.210593, 0.211345, 0.212094, 0.212843, 0.213593, 0.214342, 0.215091, 0.215841, 0.216590, 0.216921, 0.217152, 0.217382, 0.217613, 0.217844, 0.218075, 0.218306, 0.218537, 0.218734, 0.218389, 0.218045, 0.217700, 0.217355, 0.217011, 0.216666, 0.216321, 0.215977, 0.215632, 0.214856, 0.213914, 0.212973, 0.212031, 0.211090, 0.210148, 0.209207, 0.208266, 0.207324, 0.206383, 0.205037, 0.203546, 0.202055, 0.200563, 0.199072, 0.197581, 0.196090, 0.194598, 0.193107, 0.191616, 0.190057, 0.188143, 0.186229, 0.184315, 0.182401, 0.180487, 0.178573, 0.176659, 0.174745, 0.172831, 0.170917, 0.168855, 0.166676, 0.164496, 0.162316, 0.160136, 0.157956, 0.155777, 0.153597, 0.151417, 0.149237, 0.147049, 0.144765, 0.142480, 0.140195, 0.137910, 0.135626, 0.133341, 0.131056, 0.128772, 0.126487, 0.124202, 0.121930, 0.119662, 0.117393, 0.115125, 0.112856, 0.110588, 0.108319, 0.106051, 0.103783, 0.101514, 0.099329, 0.097170, 0.095011, 0.092852, 0.090693, 0.088534, 0.086375, 0.084216, 0.082057, 0.079908, 0.077921, 0.075933, 0.073945, 0.071958, 0.069970, 0.067983, 0.065995, 0.064008, 0.062020, 0.060192, 0.058408, 0.056624, 0.054840, 0.053056, 0.051272, 0.049488, 0.047705, 0.045921, 0.044355, 0.042796, 0.041237, 0.039678, 0.038119, 0.036559, 0.035000, 0.033441, 0.032034, 0.030704, 0.029375, 0.028045, 0.026715, 0.025386, 0.024056, 0.022726, 0.021598, 0.020498, 0.019398, 0.018299, 0.017199, 0.016099, 0.014999, 0.014039, 0.013155, 0.012271, 0.011388, 0.010504, 0.009620, 0.008736, 0.008061, 0.007386, 0.006711, 0.006037, 0.005362, 0.004687, 0.004199, 0.003713, 0.003226, 0.002740, 0.002253, 0.001892, 0.001589, 0.001285, 0.000981, 0.000702, 0.000532, 0.000362, 0.000191, 0.000092, 0.000046, 0.000000], + ], + [ + [0.000000, -0.000071, -0.000200, -0.000235, -0.000293, -0.000455, -0.000599, -0.000710, -0.000810, -0.000879, -0.000962, -0.001118, -0.001254, -0.001285, -0.001372, -0.001597, -0.001824, -0.002054, -0.002285, -0.002534, -0.002783, -0.003057, -0.003360, -0.003664, -0.004024, -0.004422, -0.004821, -0.005246, -0.005710, -0.006174, -0.006637, -0.007191, -0.007758, -0.008324, -0.008890, -0.009557, -0.010232, -0.010907, -0.011581, -0.012338, -0.013153, -0.013968, -0.014783, -0.015598, -0.016560, -0.017562, -0.018564, -0.019566, -0.020568, -0.021673, -0.022846, -0.024019, -0.025192, -0.026365, -0.027540, -0.028933, -0.030326, -0.031720, -0.033113, -0.034507, -0.035900, -0.037518, -0.039138, -0.040758, -0.042378, -0.043997, -0.045617, -0.047383, -0.049224, -0.051066, -0.052908, -0.054750, -0.056592, -0.058434, -0.060469, -0.062528, -0.064588, -0.066647, -0.068706, -0.070765, -0.072825, -0.074998, -0.077226, -0.079454, -0.081682, -0.083910, -0.086138, -0.088366, -0.090593, -0.092945, -0.095297, -0.097649, -0.100002, -0.102354, -0.104706, -0.107058, -0.109410, -0.111792, -0.114181, -0.116570, -0.118959, -0.121348, -0.123737, -0.126127, -0.128516, -0.130900, -0.133205, -0.135510, -0.137815, -0.140121, -0.142426, -0.144731, -0.147036, -0.149341, -0.151646, -0.153810, -0.155920, -0.158030, -0.160140, -0.162250, -0.164360, -0.166470, -0.168580, -0.170690, -0.172800, -0.174685, -0.176489, -0.178293, -0.180097, -0.181901, -0.183705, -0.185509, -0.187312, -0.189116, -0.190920, -0.192661, -0.194070, -0.195480, -0.196889, -0.198298, -0.199708, -0.201117, -0.202526, -0.203936, -0.205345, -0.206754, -0.207929, -0.208916, -0.209902, -0.210889, -0.211875, -0.212862, -0.213849, -0.214835, -0.215822, -0.216809, -0.217761, -0.218302, -0.218843, -0.219385, -0.219926, -0.220468, -0.221009, -0.221550, -0.222092, -0.222633, -0.223175, -0.223373, -0.223477, -0.223581, -0.223685, -0.223790, -0.223894, -0.223998, -0.224102, -0.224206, -0.224311, -0.224079, -0.223739, -0.223399, -0.223059, -0.222719, -0.222379, -0.222039, -0.221699, -0.221359, -0.220991, -0.220197, -0.219404, -0.218610, -0.217817, -0.217023, -0.216229, -0.215436, -0.214642, -0.213849, -0.212686, -0.211419, -0.210153, -0.208886, -0.207620, -0.206353, -0.205087, -0.203820, -0.202554, -0.200796, -0.199022, -0.197249, -0.195476, -0.193703, -0.191929, -0.190156, -0.188383, -0.186241, -0.183909, -0.181578, -0.179246, -0.176915, -0.174583, -0.172252, -0.169920, -0.167052, -0.164108, -0.161163, -0.158218, -0.155273, -0.152329, -0.149384, -0.146004, -0.142384, -0.138765, -0.135145, -0.131526, -0.127906, -0.124287, -0.119928, -0.115565, -0.111202, -0.106840, -0.102477, -0.098114, -0.092973, -0.087825, -0.082676, -0.077527, -0.072378, -0.066647, -0.060652, -0.054657, -0.048662, -0.042520, -0.035744, -0.028969, -0.022193, -0.015000, -0.007499, 0.000000], + [0.000000, -0.000071, -0.000200, -0.000235, -0.000293, -0.000455, -0.000556, -0.000546, -0.000562, -0.000649, -0.000735, -0.000816, -0.000892, -0.000944, -0.001027, -0.001188, -0.001343, -0.001475, -0.001608, -0.001785, -0.001965, -0.002163, -0.002381, -0.002600, -0.002850, -0.003120, -0.003391, -0.003676, -0.003983, -0.004291, -0.004598, -0.004989, -0.005392, -0.005795, -0.006198, -0.006651, -0.007109, -0.007566, -0.008024, -0.008549, -0.009124, -0.009698, -0.010272, -0.010847, -0.011506, -0.012189, -0.012871, -0.013554, -0.014237, -0.014997, -0.015807, -0.016617, -0.017428, -0.018238, -0.019050, -0.020006, -0.020963, -0.021920, -0.022877, -0.023833, -0.024790, -0.025892, -0.026996, -0.028099, -0.029202, -0.030305, -0.031408, -0.032613, -0.033871, -0.035128, -0.036386, -0.037644, -0.038902, -0.040160, -0.041546, -0.042949, -0.044352, -0.045755, -0.047157, -0.048560, -0.049963, -0.051442, -0.052958, -0.054474, -0.055990, -0.057506, -0.059022, -0.060538, -0.062054, -0.063673, -0.065292, -0.066911, -0.068530, -0.070149, -0.071768, -0.073387, -0.075006, -0.076653, -0.078308, -0.079962, -0.081616, -0.083271, -0.084925, -0.086579, -0.088234, -0.089887, -0.091517, -0.093148, -0.094778, -0.096408, -0.098039, -0.099669, -0.101300, -0.102930, -0.104560, -0.106122, -0.107657, -0.109192, -0.110727, -0.112262, -0.113797, -0.115332, -0.116867, -0.118402, -0.119937, -0.121342, -0.122700, -0.124058, -0.125417, -0.126775, -0.128133, -0.129492, -0.130850, -0.132208, -0.133566, -0.134886, -0.136005, -0.137123, -0.138242, -0.139361, -0.140479, -0.141598, -0.142716, -0.143835, -0.144953, -0.146072, -0.147033, -0.147870, -0.148706, -0.149542, -0.150379, -0.151215, -0.152051, -0.152888, -0.153724, -0.154560, -0.155373, -0.155900, -0.156427, -0.156954, -0.157482, -0.158009, -0.158536, -0.159063, -0.159591, -0.160118, -0.160645, -0.160913, -0.161109, -0.161306, -0.161502, -0.161698, -0.161895, -0.162091, -0.162288, -0.162484, -0.162681, -0.162615, -0.162465, -0.162315, -0.162166, -0.162016, -0.161866, -0.161716, -0.161566, -0.161416, -0.161244, -0.160734, -0.160225, -0.159715, -0.159205, -0.158696, -0.158186, -0.157676, -0.157167, -0.156657, -0.155846, -0.154951, -0.154056, -0.153161, -0.152266, -0.151371, -0.150476, -0.149581, -0.148686, -0.147397, -0.146095, -0.144794, -0.143493, -0.142192, -0.140890, -0.139589, -0.138288, -0.136696, -0.134955, -0.133214, -0.131473, -0.129731, -0.127990, -0.126249, -0.124508, -0.122358, -0.120149, -0.117940, -0.115731, -0.113523, -0.111314, -0.109105, -0.106572, -0.103860, -0.101149, -0.098438, -0.095726, -0.093015, -0.090303, -0.087065, -0.083824, -0.080584, -0.077343, -0.074102, -0.070861, -0.067083, -0.063300, -0.059516, -0.055733, -0.051949, -0.047772, -0.043416, -0.039060, -0.034704, -0.030257, -0.025414, -0.020571, -0.015729, -0.010617, -0.005308, 0.000000], + [0.000000, -0.000071, -0.000200, -0.000235, -0.000262, -0.000282, -0.000288, -0.000268, -0.000281, -0.000384, -0.000475, -0.000498, -0.000529, -0.000602, -0.000680, -0.000772, -0.000851, -0.000891, -0.000930, -0.001038, -0.001149, -0.001270, -0.001403, -0.001537, -0.001702, -0.001887, -0.002072, -0.002263, -0.002465, -0.002666, -0.002867, -0.003103, -0.003344, -0.003585, -0.003826, -0.004107, -0.004390, -0.004674, -0.004958, -0.005280, -0.005629, -0.005978, -0.006327, -0.006676, -0.007079, -0.007498, -0.007916, -0.008334, -0.008752, -0.009219, -0.009717, -0.010215, -0.010714, -0.011212, -0.011711, -0.012287, -0.012864, -0.013440, -0.014016, -0.014592, -0.015168, -0.015840, -0.016513, -0.017185, -0.017858, -0.018530, -0.019203, -0.019937, -0.020703, -0.021470, -0.022237, -0.023003, -0.023770, -0.024537, -0.025378, -0.026230, -0.027081, -0.027932, -0.028783, -0.029634, -0.030485, -0.031388, -0.032315, -0.033241, -0.034168, -0.035095, -0.036022, -0.036948, -0.037875, -0.038874, -0.039873, -0.040873, -0.041872, -0.042871, -0.043870, -0.044870, -0.045869, -0.046896, -0.047930, -0.048965, -0.049999, -0.051033, -0.052067, -0.053101, -0.054135, -0.055169, -0.056203, -0.057238, -0.058272, -0.059306, -0.060340, -0.061374, -0.062408, -0.063443, -0.064477, -0.065483, -0.066478, -0.067473, -0.068468, -0.069464, -0.070459, -0.071454, -0.072449, -0.073444, -0.074440, -0.075371, -0.076280, -0.077188, -0.078097, -0.079006, -0.079914, -0.080823, -0.081732, -0.082641, -0.083549, -0.084436, -0.085211, -0.085985, -0.086759, -0.087534, -0.088308, -0.089082, -0.089856, -0.090631, -0.091405, -0.092179, -0.092858, -0.093459, -0.094061, -0.094662, -0.095264, -0.095866, -0.096467, -0.097069, -0.097670, -0.098272, -0.098859, -0.099267, -0.099676, -0.100084, -0.100493, -0.100901, -0.101310, -0.101718, -0.102127, -0.102535, -0.102944, -0.103183, -0.103377, -0.103570, -0.103763, -0.103957, -0.104150, -0.104343, -0.104537, -0.104730, -0.104923, -0.104933, -0.104884, -0.104835, -0.104787, -0.104738, -0.104689, -0.104640, -0.104591, -0.104542, -0.104477, -0.104176, -0.103874, -0.103573, -0.103271, -0.102969, -0.102668, -0.102366, -0.102064, -0.101763, -0.101250, -0.100679, -0.100108, -0.099536, -0.098965, -0.098394, -0.097822, -0.097251, -0.096680, -0.095835, -0.094983, -0.094130, -0.093278, -0.092425, -0.091573, -0.090720, -0.089867, -0.088813, -0.087656, -0.086499, -0.085342, -0.084185, -0.083028, -0.081871, -0.080714, -0.079281, -0.077808, -0.076336, -0.074863, -0.073390, -0.071917, -0.070445, -0.068766, -0.066974, -0.065182, -0.063389, -0.061597, -0.059805, -0.058013, -0.055884, -0.053753, -0.051623, -0.049492, -0.047361, -0.045231, -0.042779, -0.040323, -0.037868, -0.035412, -0.032957, -0.030269, -0.027474, -0.024680, -0.021886, -0.019040, -0.015973, -0.012905, -0.009838, -0.006628, -0.003314, 0.000000], + [0.000000, -0.000071, -0.000067, 0.000000, -0.000034, -0.000192, -0.000245, -0.000104, -0.000027, -0.000130, -0.000226, -0.000285, -0.000334, -0.000330, -0.000338, -0.000378, -0.000407, -0.000401, -0.000395, -0.000475, -0.000559, -0.000627, -0.000675, -0.000723, -0.000795, -0.000883, -0.000971, -0.001062, -0.001157, -0.001251, -0.001346, -0.001450, -0.001555, -0.001660, -0.001765, -0.001892, -0.002021, -0.002150, -0.002278, -0.002425, -0.002584, -0.002743, -0.002902, -0.003061, -0.003250, -0.003447, -0.003645, -0.003842, -0.004039, -0.004252, -0.004475, -0.004697, -0.004920, -0.005142, -0.005366, -0.005633, -0.005901, -0.006169, -0.006437, -0.006705, -0.006973, -0.007278, -0.007583, -0.007889, -0.008194, -0.008499, -0.008805, -0.009136, -0.009481, -0.009825, -0.010170, -0.010515, -0.010860, -0.011205, -0.011595, -0.011990, -0.012386, -0.012782, -0.013177, -0.013573, -0.013969, -0.014383, -0.014807, -0.015231, -0.015654, -0.016078, -0.016502, -0.016926, -0.017349, -0.017813, -0.018278, -0.018742, -0.019206, -0.019671, -0.020135, -0.020599, -0.021063, -0.021543, -0.022027, -0.022510, -0.022994, -0.023478, -0.023961, -0.024445, -0.024928, -0.025412, -0.025906, -0.026399, -0.026892, -0.027385, -0.027879, -0.028372, -0.028865, -0.029358, -0.029852, -0.030339, -0.030823, -0.031307, -0.031792, -0.032276, -0.032760, -0.033245, -0.033729, -0.034214, -0.034698, -0.035159, -0.035611, -0.036063, -0.036516, -0.036968, -0.037420, -0.037873, -0.038325, -0.038777, -0.039230, -0.039673, -0.040067, -0.040461, -0.040856, -0.041250, -0.041644, -0.042039, -0.042433, -0.042827, -0.043222, -0.043616, -0.043968, -0.044287, -0.044605, -0.044923, -0.045241, -0.045560, -0.045878, -0.046196, -0.046515, -0.046833, -0.047144, -0.047369, -0.047595, -0.047821, -0.048046, -0.048272, -0.048497, -0.048723, -0.048948, -0.049174, -0.049399, -0.049541, -0.049658, -0.049776, -0.049894, -0.050012, -0.050130, -0.050248, -0.050366, -0.050484, -0.050602, -0.050629, -0.050627, -0.050624, -0.050622, -0.050620, -0.050618, -0.050616, -0.050614, -0.050611, -0.050601, -0.050463, -0.050325, -0.050187, -0.050049, -0.049911, -0.049774, -0.049636, -0.049498, -0.049360, -0.049114, -0.048838, -0.048561, -0.048285, -0.048009, -0.047733, -0.047457, -0.047180, -0.046904, -0.046486, -0.046064, -0.045642, -0.045220, -0.044797, -0.044375, -0.043953, -0.043530, -0.043006, -0.042430, -0.041854, -0.041278, -0.040702, -0.040125, -0.039549, -0.038973, -0.038261, -0.037530, -0.036799, -0.036068, -0.035337, -0.034606, -0.033876, -0.033046, -0.032162, -0.031278, -0.030394, -0.029510, -0.028626, -0.027742, -0.026702, -0.025662, -0.024622, -0.023582, -0.022542, -0.021501, -0.020316, -0.019129, -0.017942, -0.016754, -0.015567, -0.014280, -0.012947, -0.011614, -0.010281, -0.008927, -0.007484, -0.006041, -0.004599, -0.003095, -0.001547, 0.000000], + [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000043, 0.000166, 0.000256, 0.000255, 0.000252, 0.000231, 0.000235, 0.000373, 0.000470, 0.000463, 0.000477, 0.000559, 0.000641, 0.000711, 0.000781, 0.000858, 0.000943, 0.001029, 0.001133, 0.001250, 0.001368, 0.001484, 0.001599, 0.001714, 0.001830, 0.001979, 0.002132, 0.002286, 0.002440, 0.002629, 0.002822, 0.003014, 0.003206, 0.003414, 0.003633, 0.003851, 0.004070, 0.004289, 0.004536, 0.004792, 0.005048, 0.005304, 0.005559, 0.005847, 0.006155, 0.006463, 0.006772, 0.007080, 0.007389, 0.007748, 0.008108, 0.008467, 0.008827, 0.009187, 0.009546, 0.009966, 0.010387, 0.010808, 0.011228, 0.011649, 0.012069, 0.012530, 0.013013, 0.013496, 0.013978, 0.014461, 0.014943, 0.015426, 0.015957, 0.016494, 0.017031, 0.017569, 0.018106, 0.018643, 0.019180, 0.019766, 0.020375, 0.020984, 0.021593, 0.022202, 0.022811, 0.023420, 0.024029, 0.024692, 0.025355, 0.026018, 0.026682, 0.027345, 0.028008, 0.028671, 0.029335, 0.030037, 0.030749, 0.031461, 0.032172, 0.032884, 0.033596, 0.034307, 0.035019, 0.035733, 0.036480, 0.037228, 0.037976, 0.038723, 0.039471, 0.040218, 0.040966, 0.041713, 0.042461, 0.043221, 0.043986, 0.044752, 0.045517, 0.046282, 0.047047, 0.047813, 0.048578, 0.049343, 0.050108, 0.050863, 0.051614, 0.052364, 0.053115, 0.053866, 0.054616, 0.055367, 0.056118, 0.056869, 0.057619, 0.058361, 0.059055, 0.059749, 0.060443, 0.061138, 0.061832, 0.062526, 0.063220, 0.063915, 0.064609, 0.065303, 0.065945, 0.066545, 0.067145, 0.067745, 0.068345, 0.068945, 0.069545, 0.070145, 0.070745, 0.071345, 0.071934, 0.072388, 0.072842, 0.073295, 0.073749, 0.074203, 0.074657, 0.075111, 0.075564, 0.076018, 0.076472, 0.076782, 0.077053, 0.077324, 0.077595, 0.077866, 0.078137, 0.078408, 0.078679, 0.078950, 0.079220, 0.079325, 0.079376, 0.079426, 0.079477, 0.079528, 0.079579, 0.079630, 0.079680, 0.079731, 0.079767, 0.079572, 0.079377, 0.079181, 0.078986, 0.078791, 0.078596, 0.078401, 0.078206, 0.078010, 0.077612, 0.077157, 0.076702, 0.076247, 0.075792, 0.075336, 0.074881, 0.074426, 0.073971, 0.073262, 0.072545, 0.071828, 0.071111, 0.070394, 0.069677, 0.068960, 0.068242, 0.067354, 0.066377, 0.065401, 0.064424, 0.063448, 0.062471, 0.061495, 0.060518, 0.059328, 0.058107, 0.056887, 0.055666, 0.054446, 0.053225, 0.052004, 0.050635, 0.049183, 0.047732, 0.046281, 0.044829, 0.043378, 0.041927, 0.040273, 0.038619, 0.036964, 0.035310, 0.033655, 0.032001, 0.030165, 0.028327, 0.026490, 0.024652, 0.022814, 0.020876, 0.018893, 0.016909, 0.014926, 0.012917, 0.010800, 0.008684, 0.006567, 0.004401, 0.002200, 0.000000], + [0.000000, 0.000000, 0.000000, 0.000116, 0.000261, 0.000266, 0.000316, 0.000448, 0.000536, 0.000503, 0.000469, 0.000429, 0.000415, 0.000533, 0.000639, 0.000717, 0.000803, 0.000918, 0.001034, 0.001185, 0.001339, 0.001483, 0.001615, 0.001748, 0.001909, 0.002090, 0.002270, 0.002452, 0.002636, 0.002821, 0.003005, 0.003238, 0.003477, 0.003717, 0.003957, 0.004272, 0.004592, 0.004912, 0.005233, 0.005576, 0.005935, 0.006293, 0.006652, 0.007011, 0.007417, 0.007836, 0.008255, 0.008674, 0.009093, 0.009564, 0.010069, 0.010573, 0.011078, 0.011583, 0.012088, 0.012669, 0.013249, 0.013829, 0.014409, 0.014989, 0.015570, 0.016260, 0.016950, 0.017641, 0.018332, 0.019023, 0.019713, 0.020466, 0.021253, 0.022039, 0.022825, 0.023611, 0.024397, 0.025183, 0.026060, 0.026949, 0.027837, 0.028726, 0.029615, 0.030503, 0.031392, 0.032356, 0.033356, 0.034356, 0.035356, 0.036355, 0.037355, 0.038355, 0.039355, 0.040455, 0.041556, 0.042657, 0.043758, 0.044859, 0.045960, 0.047061, 0.048161, 0.049341, 0.050540, 0.051738, 0.052937, 0.054135, 0.055334, 0.056532, 0.057731, 0.058934, 0.060213, 0.061492, 0.062771, 0.064050, 0.065329, 0.066608, 0.067887, 0.069166, 0.070445, 0.071756, 0.073079, 0.074402, 0.075725, 0.077048, 0.078371, 0.079694, 0.081017, 0.082340, 0.083663, 0.084991, 0.086321, 0.087651, 0.088981, 0.090311, 0.091641, 0.092971, 0.094301, 0.095631, 0.096961, 0.098280, 0.099536, 0.100792, 0.102048, 0.103305, 0.104561, 0.105817, 0.107074, 0.108330, 0.109586, 0.110842, 0.112015, 0.113122, 0.114228, 0.115335, 0.116441, 0.117548, 0.118654, 0.119761, 0.120867, 0.121974, 0.123061, 0.123922, 0.124784, 0.125645, 0.126506, 0.127368, 0.128229, 0.129090, 0.129952, 0.130813, 0.131674, 0.132273, 0.132801, 0.133328, 0.133855, 0.134382, 0.134909, 0.135437, 0.135964, 0.136491, 0.137018, 0.137241, 0.137366, 0.137491, 0.137616, 0.137741, 0.137866, 0.137990, 0.138115, 0.138240, 0.138337, 0.138001, 0.137666, 0.137330, 0.136995, 0.136659, 0.136323, 0.135988, 0.135652, 0.135317, 0.134606, 0.133791, 0.132976, 0.132160, 0.131345, 0.130530, 0.129714, 0.128899, 0.128084, 0.126801, 0.125504, 0.124207, 0.122911, 0.121614, 0.120317, 0.119020, 0.117723, 0.116126, 0.114376, 0.112625, 0.110875, 0.109124, 0.107374, 0.105623, 0.103872, 0.101753, 0.099582, 0.097411, 0.095239, 0.093068, 0.090896, 0.088725, 0.086311, 0.083765, 0.081218, 0.078672, 0.076125, 0.073579, 0.071032, 0.068169, 0.065305, 0.062440, 0.059576, 0.056711, 0.053847, 0.050711, 0.047573, 0.044435, 0.041297, 0.038159, 0.034875, 0.031526, 0.028176, 0.024826, 0.021444, 0.017921, 0.014399, 0.010876, 0.007285, 0.003642, 0.000000], + [0.000000, 0.000000, 0.000000, 0.000116, 0.000261, 0.000266, 0.000359, 0.000615, 0.000826, 0.000914, 0.000981, 0.000924, 0.000898, 0.001030, 0.001153, 0.001249, 0.001375, 0.001596, 0.001816, 0.002025, 0.002233, 0.002461, 0.002715, 0.002968, 0.003250, 0.003550, 0.003850, 0.004177, 0.004542, 0.004907, 0.005272, 0.005691, 0.006117, 0.006544, 0.006970, 0.007500, 0.008037, 0.008574, 0.009111, 0.009716, 0.010370, 0.011024, 0.011678, 0.012331, 0.013073, 0.013839, 0.014604, 0.015370, 0.016135, 0.017003, 0.017939, 0.018875, 0.019810, 0.020746, 0.021683, 0.022781, 0.023878, 0.024976, 0.026074, 0.027171, 0.028269, 0.029576, 0.030884, 0.032192, 0.033500, 0.034808, 0.036116, 0.037556, 0.039064, 0.040573, 0.042082, 0.043591, 0.045099, 0.046608, 0.048311, 0.050037, 0.051764, 0.053490, 0.055217, 0.056943, 0.058670, 0.060552, 0.062507, 0.064463, 0.066419, 0.068374, 0.070330, 0.072286, 0.074241, 0.076403, 0.078566, 0.080729, 0.082892, 0.085055, 0.087218, 0.089381, 0.091544, 0.093844, 0.096176, 0.098509, 0.100841, 0.103174, 0.105506, 0.107838, 0.110171, 0.112509, 0.114945, 0.117381, 0.119816, 0.122252, 0.124687, 0.127123, 0.129558, 0.131994, 0.134429, 0.136848, 0.139261, 0.141673, 0.144086, 0.146499, 0.148911, 0.151324, 0.153736, 0.156149, 0.158561, 0.160827, 0.163040, 0.165253, 0.167466, 0.169680, 0.171893, 0.174106, 0.176319, 0.178532, 0.180745, 0.182893, 0.184697, 0.186501, 0.188305, 0.190109, 0.191913, 0.193717, 0.195521, 0.197325, 0.199129, 0.200933, 0.202403, 0.203606, 0.204810, 0.206013, 0.207216, 0.208420, 0.209623, 0.210826, 0.212030, 0.213233, 0.214380, 0.214852, 0.215324, 0.215797, 0.216269, 0.216741, 0.217214, 0.217686, 0.218158, 0.218631, 0.219103, 0.218971, 0.218672, 0.218374, 0.218075, 0.217777, 0.217479, 0.217180, 0.216882, 0.216584, 0.216285, 0.215432, 0.214400, 0.213368, 0.212336, 0.211304, 0.210272, 0.209240, 0.208208, 0.207177, 0.206105, 0.204435, 0.202765, 0.201095, 0.199424, 0.197754, 0.196084, 0.194414, 0.192744, 0.191073, 0.188989, 0.186789, 0.184589, 0.182389, 0.180188, 0.177988, 0.175788, 0.173588, 0.171388, 0.168782, 0.166163, 0.163545, 0.160927, 0.158308, 0.155690, 0.153071, 0.150453, 0.147620, 0.144677, 0.141734, 0.138791, 0.135848, 0.132905, 0.129962, 0.127019, 0.123855, 0.120660, 0.117464, 0.114269, 0.111073, 0.107878, 0.104682, 0.101365, 0.097982, 0.094599, 0.091216, 0.087832, 0.084449, 0.081066, 0.077534, 0.074001, 0.070468, 0.066935, 0.063402, 0.059869, 0.056220, 0.052570, 0.048920, 0.045269, 0.041619, 0.037910, 0.034174, 0.030439, 0.026703, 0.022954, 0.019145, 0.015337, 0.011529, 0.007697, 0.003848, 0.000000], + [0.000000, 0.000000, 0.000125, 0.000228, 0.000293, 0.000443, 0.000634, 0.000899, 0.001109, 0.001164, 0.001202, 0.001141, 0.001121, 0.001314, 0.001494, 0.001642, 0.001818, 0.002085, 0.002351, 0.002575, 0.002797, 0.003071, 0.003409, 0.003747, 0.004100, 0.004463, 0.004827, 0.005230, 0.005691, 0.006153, 0.006614, 0.007157, 0.007710, 0.008264, 0.008818, 0.009477, 0.010144, 0.010811, 0.011478, 0.012241, 0.013074, 0.013906, 0.014739, 0.015572, 0.016516, 0.017490, 0.018464, 0.019438, 0.020412, 0.021520, 0.022715, 0.023911, 0.025107, 0.026302, 0.027500, 0.028906, 0.030311, 0.031717, 0.033123, 0.034529, 0.035934, 0.037616, 0.039299, 0.040982, 0.042665, 0.044349, 0.046032, 0.047894, 0.049851, 0.051807, 0.053764, 0.055720, 0.057677, 0.059633, 0.061852, 0.064104, 0.066356, 0.068608, 0.070860, 0.073112, 0.075364, 0.077831, 0.080401, 0.082970, 0.085540, 0.088110, 0.090679, 0.093249, 0.095818, 0.098683, 0.101550, 0.104416, 0.107283, 0.110149, 0.113016, 0.115882, 0.118749, 0.121821, 0.124942, 0.128063, 0.131185, 0.134306, 0.137427, 0.140548, 0.143670, 0.146800, 0.150080, 0.153359, 0.156639, 0.159919, 0.163198, 0.166478, 0.169758, 0.173038, 0.176317, 0.179575, 0.182824, 0.186074, 0.189323, 0.192573, 0.195822, 0.199072, 0.202321, 0.205571, 0.208820, 0.211836, 0.214768, 0.217699, 0.220631, 0.223563, 0.226495, 0.229426, 0.232358, 0.235290, 0.238222, 0.241045, 0.243296, 0.245546, 0.247797, 0.250048, 0.252299, 0.254550, 0.256801, 0.259052, 0.261303, 0.263553, 0.265259, 0.266529, 0.267799, 0.269068, 0.270338, 0.271608, 0.272878, 0.274148, 0.275417, 0.276687, 0.277867, 0.277989, 0.278110, 0.278231, 0.278353, 0.278474, 0.278595, 0.278717, 0.278838, 0.278959, 0.279081, 0.278317, 0.277310, 0.276304, 0.275297, 0.274291, 0.273284, 0.272278, 0.271272, 0.270265, 0.269259, 0.267528, 0.265565, 0.263601, 0.261638, 0.259675, 0.257712, 0.255748, 0.253785, 0.251822, 0.249814, 0.247126, 0.244439, 0.241752, 0.239064, 0.236377, 0.233689, 0.231002, 0.228314, 0.225627, 0.222547, 0.219357, 0.216167, 0.212978, 0.209788, 0.206598, 0.203409, 0.200219, 0.197029, 0.193530, 0.190022, 0.186513, 0.183005, 0.179496, 0.175988, 0.172479, 0.168971, 0.165337, 0.161638, 0.157940, 0.154241, 0.150543, 0.146844, 0.143146, 0.139448, 0.135657, 0.131852, 0.128048, 0.124244, 0.120440, 0.116635, 0.112831, 0.108987, 0.105122, 0.101256, 0.097391, 0.093525, 0.089659, 0.085794, 0.081907, 0.078019, 0.074132, 0.070244, 0.066357, 0.062469, 0.058569, 0.054668, 0.050768, 0.046867, 0.042966, 0.039062, 0.035155, 0.031249, 0.027343, 0.023437, 0.019530, 0.015624, 0.011718, 0.007812, 0.003905, 0.000000], + ], + [ + [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000170, -0.000401, -0.000631, -0.000862, -0.001093, -0.001324, -0.001555, -0.001786, -0.002017, -0.002248, -0.002629, -0.003800, -0.004971, -0.006143, -0.007314, -0.008485, -0.009656, -0.010827, -0.011999, -0.013170, -0.014341, -0.015931, -0.017854, -0.019778, -0.021701, -0.023625, -0.025548, -0.027472, -0.029395, -0.031319, -0.033242, -0.035202, -0.037590, -0.039978, -0.042366, -0.044754, -0.047142, -0.049530, -0.051918, -0.054306, -0.056694, -0.059082, -0.061595, -0.064142, -0.066690, -0.069237, -0.071784, -0.074332, -0.076879, -0.079426, -0.081974, -0.084521, -0.086958, -0.089360, -0.091762, -0.094164, -0.096566, -0.098968, -0.101370, -0.103772, -0.106174, -0.108550, -0.110533, -0.112515, -0.114498, -0.116481, -0.118464, -0.120447, -0.122430, -0.124413, -0.126396, -0.127877, -0.129218, -0.130559, -0.131900, -0.133241, -0.134582, -0.135923, -0.137264, -0.138605, -0.139159, -0.139689, -0.140219, -0.140748, -0.141278, -0.141807, -0.142337, -0.142867, -0.142785, -0.142391, -0.141997, -0.141603, -0.141208, -0.140814, -0.140420, -0.140026, -0.138758, -0.137365, -0.135972, -0.134580, -0.133187, -0.131794, -0.130401, -0.128338, -0.125908, -0.123477, -0.121047, -0.118616, -0.116186, -0.113755, -0.110258, -0.106756, -0.103253, -0.099751, -0.096248, -0.092746, -0.088181, -0.083606, -0.079030, -0.074455, -0.069879, -0.064569, -0.058924, -0.053280, -0.047636, -0.041810, -0.035207, -0.028604, -0.022001, -0.014908, -0.007453, 0.000000], + [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000119, -0.000282, -0.000445, -0.000607, -0.000770, -0.000932, -0.001095, -0.001257, -0.001420, -0.001582, -0.001850, -0.002671, -0.003492, -0.004313, -0.005134, -0.005955, -0.006776, -0.007597, -0.008418, -0.009239, -0.010060, -0.011173, -0.012519, -0.013866, -0.015212, -0.016559, -0.017905, -0.019252, -0.020598, -0.021945, -0.023291, -0.024663, -0.026331, -0.027999, -0.029667, -0.031336, -0.033004, -0.034672, -0.036340, -0.038008, -0.039677, -0.041345, -0.043102, -0.044885, -0.046667, -0.048449, -0.050231, -0.052013, -0.053795, -0.055577, -0.057359, -0.059141, -0.060847, -0.062528, -0.064209, -0.065890, -0.067571, -0.069252, -0.070933, -0.072614, -0.074295, -0.075959, -0.077358, -0.078758, -0.080157, -0.081557, -0.082956, -0.084356, -0.085755, -0.087155, -0.088555, -0.089611, -0.090571, -0.091531, -0.092492, -0.093452, -0.094412, -0.095373, -0.096333, -0.097293, -0.097711, -0.098112, -0.098512, -0.098913, -0.099314, -0.099714, -0.100115, -0.100515, -0.100489, -0.100243, -0.099998, -0.099752, -0.099507, -0.099261, -0.099016, -0.098770, -0.097900, -0.096940, -0.095980, -0.095020, -0.094060, -0.093100, -0.092141, -0.090700, -0.088994, -0.087289, -0.085584, -0.083879, -0.082174, -0.080469, -0.077998, -0.075524, -0.073051, -0.070577, -0.068103, -0.065629, -0.062390, -0.059143, -0.055896, -0.052649, -0.049403, -0.045639, -0.041641, -0.037642, -0.033643, -0.029518, -0.024848, -0.020178, -0.015508, -0.010503, -0.005251, 0.000000], + [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000074, -0.000175, -0.000275, -0.000376, -0.000477, -0.000577, -0.000678, -0.000779, -0.000879, -0.000980, -0.001147, -0.001660, -0.002173, -0.002687, -0.003200, -0.003713, -0.004227, -0.004740, -0.005253, -0.005767, -0.006280, -0.006971, -0.007803, -0.008636, -0.009468, -0.010301, -0.011133, -0.011966, -0.012798, -0.013631, -0.014463, -0.015311, -0.016344, -0.017377, -0.018410, -0.019442, -0.020475, -0.021508, -0.022540, -0.023573, -0.024606, -0.025639, -0.026726, -0.027829, -0.028932, -0.030035, -0.031137, -0.032240, -0.033343, -0.034446, -0.035548, -0.036651, -0.037711, -0.038756, -0.039802, -0.040847, -0.041893, -0.042939, -0.043984, -0.045030, -0.046076, -0.047111, -0.047989, -0.048867, -0.049745, -0.050623, -0.051501, -0.052379, -0.053257, -0.054135, -0.055012, -0.055682, -0.056292, -0.056903, -0.057514, -0.058125, -0.058735, -0.059346, -0.059957, -0.060568, -0.060842, -0.061107, -0.061371, -0.061635, -0.061899, -0.062163, -0.062427, -0.062691, -0.062689, -0.062551, -0.062412, -0.062273, -0.062135, -0.061996, -0.061857, -0.061719, -0.061187, -0.060599, -0.060011, -0.059423, -0.058834, -0.058246, -0.057658, -0.056765, -0.055704, -0.054643, -0.053582, -0.052521, -0.051460, -0.050399, -0.048848, -0.047296, -0.045743, -0.044190, -0.042637, -0.041084, -0.039057, -0.037025, -0.034993, -0.032961, -0.030929, -0.028563, -0.026045, -0.023528, -0.021010, -0.018416, -0.015497, -0.012577, -0.009657, -0.006537, -0.003268, 0.000000], + [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000035, -0.000082, -0.000130, -0.000178, -0.000225, -0.000273, -0.000320, -0.000368, -0.000415, -0.000463, -0.000541, -0.000777, -0.001013, -0.001249, -0.001485, -0.001722, -0.001958, -0.002194, -0.002430, -0.002666, -0.002903, -0.003222, -0.003608, -0.003994, -0.004381, -0.004767, -0.005153, -0.005539, -0.005925, -0.006311, -0.006697, -0.007090, -0.007569, -0.008048, -0.008526, -0.009005, -0.009483, -0.009962, -0.010441, -0.010919, -0.011398, -0.011877, -0.012381, -0.012892, -0.013404, -0.013915, -0.014426, -0.014938, -0.015449, -0.015960, -0.016472, -0.016983, -0.017477, -0.017964, -0.018452, -0.018940, -0.019427, -0.019915, -0.020403, -0.020890, -0.021378, -0.021861, -0.022268, -0.022676, -0.023084, -0.023492, -0.023899, -0.024307, -0.024715, -0.025123, -0.025531, -0.025846, -0.026137, -0.026427, -0.026717, -0.027007, -0.027297, -0.027588, -0.027878, -0.028168, -0.028302, -0.028431, -0.028559, -0.028688, -0.028817, -0.028946, -0.029074, -0.029203, -0.029209, -0.029151, -0.029093, -0.029035, -0.028977, -0.028919, -0.028861, -0.028803, -0.028558, -0.028287, -0.028016, -0.027745, -0.027474, -0.027203, -0.026931, -0.026515, -0.026020, -0.025524, -0.025029, -0.024533, -0.024038, -0.023542, -0.022817, -0.022090, -0.021364, -0.020638, -0.019911, -0.019185, -0.018235, -0.017283, -0.016331, -0.015379, -0.014426, -0.013321, -0.012146, -0.010971, -0.009796, -0.008586, -0.007226, -0.005865, -0.004505, -0.003049, -0.001525, 0.000000], + [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000050, 0.000117, 0.000184, 0.000252, 0.000319, 0.000387, 0.000454, 0.000522, 0.000589, 0.000656, 0.000766, 0.001096, 0.001427, 0.001757, 0.002087, 0.002417, 0.002748, 0.003078, 0.003408, 0.003739, 0.004069, 0.004518, 0.005061, 0.005605, 0.006148, 0.006691, 0.007235, 0.007778, 0.008322, 0.008865, 0.009408, 0.009962, 0.010631, 0.011301, 0.011971, 0.012641, 0.013310, 0.013980, 0.014650, 0.015320, 0.015989, 0.016659, 0.017370, 0.018091, 0.018813, 0.019535, 0.020256, 0.020978, 0.021700, 0.022421, 0.023143, 0.023865, 0.024567, 0.025263, 0.025959, 0.026656, 0.027352, 0.028048, 0.028744, 0.029440, 0.030137, 0.030827, 0.031423, 0.032019, 0.032615, 0.033211, 0.033807, 0.034403, 0.034999, 0.035595, 0.036191, 0.036657, 0.037087, 0.037517, 0.037946, 0.038376, 0.038806, 0.039235, 0.039665, 0.040095, 0.040305, 0.040509, 0.040713, 0.040916, 0.041120, 0.041323, 0.041527, 0.041731, 0.041753, 0.041683, 0.041613, 0.041543, 0.041473, 0.041402, 0.041332, 0.041262, 0.040922, 0.040544, 0.040166, 0.039787, 0.039409, 0.039031, 0.038653, 0.038058, 0.037345, 0.036632, 0.035920, 0.035207, 0.034494, 0.033781, 0.032735, 0.031687, 0.030640, 0.029592, 0.028545, 0.027497, 0.026120, 0.024740, 0.023359, 0.021979, 0.020598, 0.019008, 0.017322, 0.015636, 0.013950, 0.012215, 0.010269, 0.008323, 0.006376, 0.004310, 0.002155, 0.000000], + [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000080, 0.000189, 0.000299, 0.000408, 0.000517, 0.000626, 0.000735, 0.000844, 0.000953, 0.001063, 0.001242, 0.001787, 0.002333, 0.002879, 0.003425, 0.003971, 0.004517, 0.005063, 0.005609, 0.006154, 0.006700, 0.007438, 0.008329, 0.009220, 0.010111, 0.011002, 0.011893, 0.012784, 0.013675, 0.014566, 0.015457, 0.016365, 0.017469, 0.018573, 0.019676, 0.020780, 0.021884, 0.022988, 0.024092, 0.025195, 0.026299, 0.027403, 0.028573, 0.029761, 0.030948, 0.032136, 0.033324, 0.034512, 0.035700, 0.036888, 0.038076, 0.039263, 0.040424, 0.041575, 0.042727, 0.043878, 0.045030, 0.046181, 0.047333, 0.048484, 0.049636, 0.050778, 0.051774, 0.052771, 0.053767, 0.054764, 0.055761, 0.056757, 0.057754, 0.058750, 0.059747, 0.060528, 0.061250, 0.061971, 0.062693, 0.063414, 0.064136, 0.064857, 0.065579, 0.066300, 0.066662, 0.067012, 0.067362, 0.067712, 0.068062, 0.068412, 0.068762, 0.069112, 0.069160, 0.069053, 0.068946, 0.068839, 0.068732, 0.068625, 0.068518, 0.068411, 0.067854, 0.067232, 0.066611, 0.065990, 0.065368, 0.064747, 0.064125, 0.063141, 0.061957, 0.060774, 0.059590, 0.058406, 0.057223, 0.056039, 0.054292, 0.052542, 0.050792, 0.049041, 0.047291, 0.045541, 0.043250, 0.040953, 0.038657, 0.036360, 0.034063, 0.031426, 0.028634, 0.025842, 0.023050, 0.020178, 0.016957, 0.013737, 0.010517, 0.007105, 0.003552, 0.000000], + [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000141, 0.000333, 0.000525, 0.000718, 0.000910, 0.001102, 0.001294, 0.001486, 0.001678, 0.001870, 0.002192, 0.003198, 0.004204, 0.005210, 0.006216, 0.007222, 0.008228, 0.009234, 0.010240, 0.011246, 0.012252, 0.013647, 0.015354, 0.017061, 0.018768, 0.020474, 0.022181, 0.023888, 0.025595, 0.027302, 0.029009, 0.030749, 0.032879, 0.035009, 0.037140, 0.039270, 0.041400, 0.043531, 0.045661, 0.047791, 0.049922, 0.052052, 0.054258, 0.056485, 0.058711, 0.060938, 0.063165, 0.065392, 0.067619, 0.069845, 0.072072, 0.074299, 0.076337, 0.078313, 0.080290, 0.082267, 0.084244, 0.086221, 0.088198, 0.090174, 0.092151, 0.094094, 0.095519, 0.096944, 0.098369, 0.099794, 0.101219, 0.102644, 0.104069, 0.105494, 0.106919, 0.107739, 0.108391, 0.109042, 0.109694, 0.110345, 0.110997, 0.111648, 0.112299, 0.112951, 0.112758, 0.112539, 0.112320, 0.112101, 0.111883, 0.111664, 0.111445, 0.111226, 0.110443, 0.109371, 0.108299, 0.107227, 0.106156, 0.105084, 0.104012, 0.102940, 0.101213, 0.099393, 0.097572, 0.095752, 0.093931, 0.092111, 0.090290, 0.088075, 0.085643, 0.083211, 0.080779, 0.078347, 0.075915, 0.073483, 0.070586, 0.067687, 0.064788, 0.061889, 0.058989, 0.056090, 0.052849, 0.049604, 0.046360, 0.043115, 0.039870, 0.036455, 0.032962, 0.029468, 0.025975, 0.022446, 0.018760, 0.015074, 0.011388, 0.007628, 0.003814, 0.000000], + [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000178, 0.000421, 0.000664, 0.000906, 0.001149, 0.001392, 0.001634, 0.001877, 0.002120, 0.002362, 0.002773, 0.004064, 0.005355, 0.006646, 0.007937, 0.009228, 0.010519, 0.011810, 0.013101, 0.014392, 0.015683, 0.017484, 0.019691, 0.021898, 0.024106, 0.026313, 0.028521, 0.030728, 0.032935, 0.035143, 0.037350, 0.039601, 0.042371, 0.045140, 0.047909, 0.050679, 0.053448, 0.056218, 0.058987, 0.061756, 0.064526, 0.067295, 0.070147, 0.073022, 0.075896, 0.078771, 0.081645, 0.084520, 0.087394, 0.090269, 0.093143, 0.096018, 0.098611, 0.101113, 0.103616, 0.106118, 0.108621, 0.111123, 0.113625, 0.116128, 0.118630, 0.121083, 0.122773, 0.124462, 0.126152, 0.127842, 0.129532, 0.131221, 0.132911, 0.134601, 0.136291, 0.137119, 0.137708, 0.138296, 0.138884, 0.139472, 0.140060, 0.140649, 0.141237, 0.141825, 0.141254, 0.140648, 0.140041, 0.139434, 0.138827, 0.138220, 0.137613, 0.137007, 0.135669, 0.133956, 0.132244, 0.130531, 0.128819, 0.127106, 0.125393, 0.123681, 0.121195, 0.118600, 0.116004, 0.113408, 0.110812, 0.108217, 0.105621, 0.102623, 0.099405, 0.096186, 0.092968, 0.089749, 0.086531, 0.083312, 0.079721, 0.076129, 0.072536, 0.068944, 0.065351, 0.061758, 0.057965, 0.054171, 0.050376, 0.046581, 0.042786, 0.038937, 0.035063, 0.031190, 0.027316, 0.023437, 0.019530, 0.015624, 0.011718, 0.007812, 0.003905, 0.000000], + ], +]; diff --git a/crates/pipeline/src/finish.rs b/crates/pipeline/src/finish.rs index 3bce268a68c..041936bdaa4 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), } } } @@ -248,6 +248,8 @@ pub struct FinishParams { pub shadow_tint: f32, /// Tone curves (parametric ∘ point, per channel) on encoded values, 1024 entries each. pub curves: Option<[Lut1; 3]>, + /// Process V8's Whites and tone curves (they replace `curves`, which stays `None` from V8 on). + pub curve_stage: Option, /// Refine Saturation as 0..1 (1 = the curves' own saturation). pub refine_sat: f32, pub vig: Option, @@ -335,7 +337,8 @@ impl FinishParams { light: crate::light_v3::LightOps::new(s, info), lut: crate::lut::get(&s.profile.id).map(|l| (l, (s.profile.amount / 100.0).clamp(0.0, 2.0) as f32)), ops: ColorOps::new(s), - curves: curve_luts(&s.curve), + curves: if s.process.process() < Process::V8 { curve_luts(&s.curve) } else { None }, + curve_stage: crate::curve_stage::CurveStage::new(s), refine_sat: (s.curve.refine_saturation / 100.0).clamp(0.0, 1.0) as f32, vig: if effects { vignette(s) } else { None }, to_out: space.from_working(), @@ -412,6 +415,13 @@ pub fn base_tone(s: &DevelopSettings, info: &SourceInfo, peak: f32) -> ToneMap { 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), }, + // V7, with Whites moved out of the tone map: the curve stage applies Whites as measured against + // Lightroom (`crate::curve_stage`) + Process::V8 => match info.camera_tone.as_ref().filter(|_| info.raw) { + Some(curve) => ToneMap::camera_rolloff_hdr(curve, 0.0, 0.0, 0.0, peak), + None if info.raw => ToneMap::rolloff_hdr(l.contrast, 0.0, l.blacks, peak), + None => ToneMap::display_hdr(l.contrast, 0.0, l.blacks, peak), + }, } } @@ -558,6 +568,9 @@ pub(crate) fn finish_with( // --- process V4: calibrated Contrast, Blacks (ProPhoto with the sRGB transfer) d = apply_light(d, light.as_ref(), preview_light.as_ref(), exact, srgb); + // --- process V8: Whites and the tone curves, as Lightroom applies them + d = fp.curve_stage.as_ref().map_or(d, |stage| stage.apply(d)); + // --- colour d = fp.ops.apply(d, l_sat, l_hue); if let Some((dir, amt)) = local.tint { diff --git a/crates/pipeline/src/lib.rs b/crates/pipeline/src/lib.rs index 34bd402336f..1dc2ae10fff 100644 --- a/crates/pipeline/src/lib.rs +++ b/crates/pipeline/src/lib.rs @@ -12,6 +12,7 @@ //! 3. tone map — contrast / whites / blacks filmic curve on luminance, highlight desaturation //! 4. colour — vibrance, saturation, colour mixer, colour grading, B&W (OkLCh) //! 5. display — gamut map to the output space (sRGB unless [`RenderRequest::space`] says otherwise), encode, tone curves (parametric + point), vignette, grain +//! (from process V8 the tone curves and Whites run between 3 and 4 instead: [`curve_stage`]) //! //! Spatial parameters are specified relative to the image's long edge, so a 400 px preview and a //! 60 MP export look alike. @@ -29,6 +30,9 @@ pub mod colorops; pub mod crystal; pub mod cull; pub mod curve; +pub mod curve_stage; +#[rustfmt::skip] +mod curve_stage_tables; pub mod dust; pub mod finish; pub mod geometry; diff --git a/crates/pipeline/src/light_v3.rs b/crates/pipeline/src/light_v3.rs index a7db45ec066..5f3e0f9bf24 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 5fb9ad84ceb..0401c315338 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/tests.rs b/crates/pipeline/src/tests.rs index f1229bd5690..0ebe887a372 100644 --- a/crates/pipeline/src/tests.rs +++ b/crates/pipeline/src/tests.rs @@ -1,4 +1,4 @@ -use lightcraft_develop::{DevelopSettings, controls}; +use lightcraft_develop::{DevelopSettings, Process, controls}; use lightcraft_raster::Rgb32f; use crate::{RenderRequest, SourceInfo, render}; @@ -453,13 +453,23 @@ fn refine_saturation_tames_a_contrast_curve() { lightcraft_geom::Point::new(0.7, 0.85), lightcraft_geom::Point::new(1.0, 1.0), ]; - let full = render(&src, &info, &s, &req).image.data[0]; + let curved = s.clone(); s.curve.refine_saturation = 0.0; - let refined = render(&src, &info, &s, &req).image.data[0]; - assert!(sat(full) > sat(refined), "{flat:?} {full:?} {refined:?}"); - // the curve's tone change stays - let y = |p: [u8; 4]| 0.2126 * p[0] as f32 + 0.7152 * p[1] as f32 + 0.0722 * p[2] as f32; - assert!((y(full) - y(refined)).abs() < 2.0); + let y = |p: [u8; 4], lin: bool| { + let c = |v: u8| if lin { lightcraft_color::transfer::srgb_to_linear(v as f32 / 255.0) } else { v as f32 }; + 0.2126 * c(p[0]) + 0.7152 * c(p[1]) + 0.0722 * c(p[2]) + }; + for process in [Process::V7, Process::V8] { + let on = |s: &DevelopSettings| render(&src, &info, &DevelopSettings { process: process.version(), ..s.clone() }, &req).image.data[0]; + let (full, refined) = (on(&curved), on(&s)); + assert!(sat(full) > sat(refined), "{process:?}: {flat:?} {full:?} {refined:?}"); + // the curve's tone change stays: up to V7 the encoded luma, from V8 the luminance + if process < Process::V8 { + assert!((y(full, false) - y(refined, false)).abs() < 2.0, "{process:?}: {full:?} {refined:?}"); + } else { + assert!((y(full, true) / y(refined, true) - 1.0).abs() < 0.03, "{process:?}: {full:?} {refined:?}"); + } + } } #[test] diff --git a/crates/pipeline/src/tests_grain.rs b/crates/pipeline/src/tests_grain.rs index 14172a516cd..9dc48924530 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/docs/curve-stage.md b/docs/curve-stage.md new file mode 100644 index 00000000000..16381aefaa9 --- /dev/null +++ b/docs/curve-stage.md @@ -0,0 +1,70 @@ +# Whites and the tone curves, measured (process V8) + +> **Changes:** [revision history](#revision-history) + +Process V8 renders Whites, the parametric curve and the point curves the way Lightroom does, from measurements of +Camera Raw's output. V1 to V7 are unchanged (`docs/process-versions.md`). The code is +`crates/pipeline/src/curve_stage.rs`, its measured tables `crates/pipeline/src/curve_stage_tables.rs`, and the GPU +kernel's `curve_stage` in `crates/gpu/src/wgsl/finish.wgsl`. + +## What was wrong + +Up to V7 Whites is part of the tone map, which acts on luminance, and the curves act on each channel of the +display-encoded output. Measured against Camera Raw, this goes wrong in three ways: + +- **Whites reaches too little.** Lightroom's Whites moves the upper midtones too: at Whites −50 an sRGB-encoded 0.6 + drops by about 10/255. V7's Whites barely touches them. +- **The parametric regions are too narrow.** Lightroom's Highlights, Lights, Darks and Shadows regions are broad and + overlap, and they add: the sum of the single regions reproduces three at once within 1/255. +- **Per-channel curves shift hues.** A contrast curve applied to R, G and B separately pushes orange towards red and + saturates. Lightroom's master curve keeps the hue. It maps the largest and the smallest channel through the curve, + and the middle channel keeps its relative position between them in linear light. + +## What V8 does + +After the tone map and V4's calibrated Contrast and Blacks, before the colour stage: + +1. Convert linear Rec.2020 to linear ProPhoto RGB (D50, Bradford) and encode with the sRGB curve, as the V4 + operators do (`light_v3::prophoto_matrices`). +2. Build the base table: Whites, then the parametric curve, then the master point curve. Whites and the four regions + are Camera Raw's measured output minus input (257 inputs each). Whites is measured at ±25, ±50 and ±100, the + regions at ±25, ±50, ±75 and ±100, and amounts in between are interpolated linearly, towards 0 below 25. The + tables hold for Lightroom's default splits (25, 50, 75). With other splits the parametric curve is the analytic + model of the earlier processes. The table is kept non-decreasing. +3. Apply the base table to the largest and smallest channel. The middle channel keeps its relative position between + them in linear light. +4. Apply the red, green and blue point curves to each channel. +5. Refine Saturation (below 100) moves saturation back towards the input's, as in V7, and then rescales to the + curves' linear luminance, so the tone change stays. +6. Values above SDR white (an HDR render) continue with slope 1. + +The tone map no longer applies Whites under V8 (`finish::base_tone`), and the V7 output-curve tables are not built +(`FinishParams::curves` is `None`). With Whites, the parametric curve and the point curves all neutral, the stage +does not run and the render is V7's. + +## How it was measured + +`tools/lr_tone_charts.py charts OUT_DIR` writes linear DNG charts: 48 grey steps from 0.002 to 1 and OkLCh colour +patches, with the settings in the DNG's XMP. It writes one neutral chart, Whites at each measured amount, and each +parametric region at each measured amount. The charts are original test data. Every chart was rendered through +Camera Raw to a 16-bit Adobe RGB (1998) TIFF. Only that output is measured, and nothing of Adobe's is copied or +shipped. `tools/lr_tone_charts.py tables RENDER_DIR OUT_RS` reads the grey steps of each render as sRGB-encoded +linear ProPhoto values and writes `curve_stage_tables.rs`. It needs numpy and tifffile +(`tools/requirements-lr-tone-charts.txt`). Running the tool again reproduces the committed charts and the committed +tables byte for byte. + +The grey-step tables leave out how colour is treated. To check that, the colour patches of the same renders were +predicted from the grey-step curves under the hue-preserving rule in step 3. The prediction is within 0.03 to 0.16 +(OkLab × 100) of Camera Raw's patches, against 0.3 to 3.4 for V7's per-channel curves. + +## Limits + +- The tables are measured with Lightroom's default splits. Moved splits use the earlier analytic model. +- Local (mask) Whites keeps the earlier processes' operator. +- The measurements use Camera Raw's process version 2012 controls (`crs:ProcessVersion` 11.0). + +## Revision history + +| Date | Change | Summary | +|---|---|---| +| 2026-11-10 | minor | Process V8: measured Whites and parametric curve, hue-preserving master curve | diff --git a/docs/gaps.md b/docs/gaps.md index 72ff6d72f88..4e58bb69807 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -17,7 +17,7 @@ Hours are Opus 5.5 agent wall-clock hours (see [target-app-parity.md](target-app |---:|---|---|---|---:|---| | 1 B | **Camera colour is estimated, not measured** (LR-PROF-CAMERACOLOR). Raws start from a per-file fit to the camera JPEG, 10 bundled profiles, 52 spectral matrices (plus same-sensor bodies, e.g. the X-T30 through the X-T3) or chart-measured matrices (the EOS D60); others use a neutral matrix (a black-and-white camera JPEG gives its tone curve only, #577; dark JPEG tones also guide the toe, #1307) | ΔE vs camera JPEG 2.9–10 after fitting (raw-parity.md); 1 chart-calibrated model (EOS D60: its Kelvin scale and fallback colour, the look stays the JPEG fit) vs 1,500 Adobe Standard profiles | every raw shooter sees colour that is close but not Lightroom's; some get neutral-matrix colour | 50–90 | [raw-parity](raw-parity.md#colour) | | 2 B | **CR3 variants no public file uses** (LR-IMP-FORMATS): `crx.rs` refuses vertical-tile C-RAW, partial-subband and other plane coding, multi-tile 0x200 and adaptive low-frequency gains, and those files fall back to the preview. All 110 CC0 CR3s on raw.pixls.us (31 folders) decode from sensor data, so none of these variants has a public sample; 26 CR3 bodies are verified (M50 / R100 / R8 exact, R5 Mark II pinned, 22 more pinned on one CC0 file each and checked against the camera JPEG, [cr3.md](cr3.md#further-bodies-one-cc0-file-each)). HEIF stills are `.HIF` files, not CR3; no CR3 sRAW / mRAW sample exists | measured: Canon's share whose camera fully works 73% → 94% (raw-parity.md); 18 of 22 popular Canon bodies write CR3, all 18 now verified | +0.3 points of photographers; the variants surface only as user files that open as a preview | 10–25 | [raw-parity](raw-parity.md#remaining-work-ranked-by-photographers-unlocked-per-hour) | -| 3 B | **Render fidelity partial** (LR-BEHAV-RENDER-FIDELITY): calibrated camera-look Contrast and Blacks; other operators need measurement; from process V5 raw tone curves roll off into white in stops, so Exposure keeps recorded highlights (#1632) | process V3 reduces held-out response error from 0.136 to 0.038 stops for Contrast and 0.424 to 0.077 for Blacks on one Sony camera; Whites remains V2 pending a follow-up | imported Lightroom edits still differ, especially on uncalibrated operators and cameras | 30–60 | [calibrated Light operators](light-v3.md), [process versions](process-versions.md) | +| 3 B | **Render fidelity partial** (LR-BEHAV-RENDER-FIDELITY): calibrated camera-look Contrast and Blacks; other operators need measurement; from process V5 raw tone curves roll off into white in stops, so Exposure keeps recorded highlights (#1632); from V8 Whites and the tone curves are measured against Camera Raw ([curve-stage.md](curve-stage.md)) | process V3 reduces held-out response error from 0.136 to 0.038 stops for Contrast and 0.424 to 0.077 for Blacks on one Sony camera; Whites remains V2 pending a follow-up | imported Lightroom edits still differ, especially on uncalibrated operators and cameras | 30–60 | [calibrated Light operators](light-v3.md), [process versions](process-versions.md) | | 4 | ~~Original-pixel detail at 100%~~ (LR-VIEW-ZOOM): closed 2026-10-12, see Closed recently | checklist row ✅ | — | 0 | [ui-parity](ui-parity.md) | | 5 B | **AI masks: Subject, Sky, People, Background, Landscape** are heuristics; Object / Describe run SAM 3 but its download has no mirror configured | `crates/segment`; ai-masks.md; MASK rows 67% | masking is how most Lightroom users edit today | 40–70 + model decision | [target-app-parity](target-app-parity.md#ai) | | 6 | **Compressed ORF** (support withdrawn) | #3775 decoder removed pending provenance review; uncompressed support remains | compressed files use embedded JPEG previews when available, not sensor data | pending review | [orf-compression](orf-compression.md) | diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 7d1ec1a01a9..436e7af1e5c 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -183,10 +183,10 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-EDIT-LIGHT-CONTRAST | Contrast | P0 | 🟡 | `ctl:light.contrast` | From process V4, global Contrast on the camera-look path is fitted per channel in ProPhoto with the sRGB transfer. Check response error 0.136 to 0.038 stops on six held-out Sony photos. Other sources and local adjustments retain V2; broader parity remains unverified (`docs/light-v3.md`). | | LR-EDIT-LIGHT-HIGHLIGHTS | Highlights | P0 | ✅ | `ctl:light.highlights`, `crates/raw/src/highlight.rs` | sensor-clipped highlights stay neutral when Highlights (or Exposure, Whites) darkens them: fully clipped content is rebuilt to the neutral of the colour model applied after it, partly clipped content takes its colour from reliable unclipped content nearby (not from dark objects, lens fringes or another surface beside it) and white where there is none, and pale partly clipped content (a white sky) turns white on its way to clipping (#523); binned previews and thumbnails decide clipping per sample before averaging (`develop_binned_masked`, `highlight::reconstruct_masked`), so a block with one clipped specular sample keeps its mean instead of jumping to the clip level, which reconstruction turned into green speckles at 500 px (#548) From process V2 the Highlights/Shadows base is the edge-aware filter of the 0.15 %-of-long-edge median of log luminance: twigs and fine texture take their surroundings' shift, so bright areas keep their local contrast as with Exposure (V1's base kept ~0.6 of it at −100, #632); region edges stay sharp. Alt/Option-drag shows highlight clipping | | LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | From process V2, the same base as Highlights: dark areas keep their local contrast when lifted (#632). Alt/Option-drag shows shadow clipping (white, clipped channels in colour) | -| LR-EDIT-LIGHT-WHITES | Whites | P0 | 🟡 | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | V4 preserves V2 Whites for both signs. Calibration is a planned follow-up; measured V2 check response error is 0.075 stops on the Sony test photos (`docs/light-v3.md`). Alt/Option-drag shows highlight clipping (black, clipped channels in colour) | +| LR-EDIT-LIGHT-WHITES | Whites | P0 | 🟡 | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | From process V8 Whites is measured against Camera Raw renders of synthetic grey steps and reaches into the midtones as Lightroom's does ([curve-stage.md](curve-stage.md)); not yet compared on photos per camera. V4 to V7 preserve V2 Whites for both signs; measured V2 check response error is 0.075 stops on the Sony test photos (`docs/light-v3.md`). Alt/Option-drag shows highlight clipping (black, clipped channels in colour) | | LR-EDIT-LIGHT-BLACKS | Blacks | P0 | 🟡 | `ctl:light.blacks`, `crates/pipeline/src/visualize.rs` | From process V4, global Blacks on the camera-look path uses a fitted per-channel/luminance mix. Check response error 0.424 to 0.077 stops on six held-out Sony photos; deepest tones still differ. Other sources and local adjustments retain V2 (`docs/light-v3.md`). Alt/Option-drag shows shadow clipping (white, clipped channels in colour) | -| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | the graph draws the renderer's own curve model; dragging the line moves the region under the pointer (one undo step) | -| LR-EDIT-LIGHT-CURVE-POINT | Point curve | P0 | ✅ | `cmd:develop.curve`, `cmd:curve.reset`, `cmd:curve.presets`, `cmd:curve.applyPreset`, `cmd:curve.savePreset`, `cmd:curve.deletePreset`, `cmd:curve.importPresets`, `cmd:curve.exportPresets`, `cmd:file.importCurvePresets`, `cmd:file.exportCurvePresets`, `crates/engine/src/cmd/curves.rs`, `crates/ui-egui/src/panels/edit.rs` | click to add a point; drag a point in both axes (between its neighbours, input / output readout, one undo step per drag; ⌥-drag moves it a tenth as far for fine adjustment, issue #1363); drag empty space to add and drag; double-click removes; reset: double-click a channel selector (that channel), the Reset button under the graph (every curve incl. parametric) or right-click the graph (channel / all); Point Curve preset dropdown: own Linear / Medium Contrast / Strong Contrast, user presets (save the current point curves, delete by right-click; saved with the library), import / export as `.lccurve` JSON | +| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | from process V8 the regions are Camera Raw's measured response at the default splits, broad and additive ([curve-stage.md](curve-stage.md)); the graph draws the renderer's own curve model; dragging the line moves the region under the pointer (one undo step) | +| LR-EDIT-LIGHT-CURVE-POINT | Point curve | P0 | ✅ | `cmd:develop.curve`, `cmd:curve.reset`, `cmd:curve.presets`, `cmd:curve.applyPreset`, `cmd:curve.savePreset`, `cmd:curve.deletePreset`, `cmd:curve.importPresets`, `cmd:curve.exportPresets`, `cmd:file.importCurvePresets`, `cmd:file.exportCurvePresets`, `crates/engine/src/cmd/curves.rs`, `crates/ui-egui/src/panels/edit.rs` | click to add a point; drag a point in both axes (between its neighbours, input / output readout, one undo step per drag; ⌥-drag moves it a tenth as far for fine adjustment, issue #1363); drag empty space to add and drag; double-click removes; reset: double-click a channel selector (that channel), the Reset button under the graph (every curve incl. parametric) or right-click the graph (channel / all); Point Curve preset dropdown: own Linear / Medium Contrast / Strong Contrast, user presets (save the current point curves, delete by right-click; saved with the library), import / export as `.lccurve` JSON; from process V8 the master curve keeps hue as Lightroom's does (largest and smallest channel through the curve, the middle one in proportion), and the red, green and blue curves follow it per channel ([curve-stage.md](curve-stage.md)) | | LR-EDIT-LIGHT-CURVE-RGB | Per-channel curves | P0 | ✅ | `cmd:develop.curve` (`channel`) | | | LR-EDIT-LIGHT-CURVE-REFINESAT | Curve saturation compensation | P1 | ✅ | `ctl:curve.refineSaturation` | | | LR-EDIT-LIGHT-CURVE-TAT | Drag-on-image curve adjust | P1 | ✅ | `cmd:develop.targeted` (`target: curve`) | | @@ -467,7 +467,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-BEHAV-OFFLINE | Offline editing | P1 | ✅ | | local-first: everything works offline | | LR-BEHAV-WEB-SAFETY | Library safety in the browser build | P1 | 🟡 | `cmd:file.backupLibrary`, `cmd:file.restoreLibrary`, `apps/lightcraft-web/src/safety.rs`, `apps/lightcraft-web/src/backup.rs`, `apps/lightcraft-web/src/files.rs` | web only (experimental): Back Up Library (zip of the catalog and every stored original) and a non-destructive Restore; failed saves show as unsaved and are retried; a photo that can't be stored isn't added; one tab per library (Web Locks); notices for storage that isn't persistent and for a library that can't open; `?reset` asks first; a panic shows a message. Missing: `?safe` start, deleting originals of removed photos, zip64 (backups > 4 GB) | | LR-BEHAV-GPU | GPU acceleration | P0 | ✅ | `crates/gpu/src/render.rs`, `cmd:app.gpu`, `docs/gpu-pipeline.md`, `crates/ui-egui/src/panels/notices.rs` | CPU fallback per render on device limits, out of memory, device errors / loss, incomplete or black results (`perf.gpuReason`, `perf.gpuFallback`; each render reports its own reason — `lightcraft_gpu::try_render`, `gpuFallback` per exported file — issue #675); short submissions for slow iGPUs; backend choice (DX12 only on Windows, `LIGHTCRAFT_GPU_BACKEND` / `WGPU_BACKEND`), device created after the window opens, crash sentinel (issue #136); a GPU lost while LightCraft runs (driver reset) stops it with that message and turns GPU rendering off for the next start, which says why (issue #1337; the window's renderer can't survive the lost device); quitting waits (up to 2 s) for renders in flight and starts no new GPU work, so none is inside the driver when the process exits (`crates/gpu/src/exit.rs`, issue #620; seen crashing only on Linux + NVIDIA, other drivers unverified); with GPU rendering on and no adapter found at all (e.g. no Vulkan loader on NixOS outside `nix develop`), the desktop app says once per session that it renders on the CPU and points to Help ▸ System Info (`gpu_notice`; not when the GPU is turned off or only a software adapter exists); no tiling beyond the buffer limit (CPU) | -| LR-BEHAV-RENDER-FIDELITY | Rendering matches Lightroom | P1 | 🟡 | `crates/pipeline/src/lib.rs`, `crates/pipeline/src/tone.rs` | Process V4 calibrates global camera-look Contrast and Blacks against black-box Lightroom exports of Sony ILCE-7CR photos. Held-out response errors are 0.038 and 0.077 stops; V1/V2 keep their rendering. Whites retains V2 and awaits a follow-up. Exposure, Highlights/Shadows, other operators and broader camera coverage remain open (`docs/light-v3.md`). From process V5 a raw's tone curve rolls off into white in stops (past a camera curve's last fitted knot, or from half a stop below the generic curve's white point instead of clipping), so Exposure +1 and +2 keep the highlights the sensor recorded: on 12 CC0 corpus raws and 6 CC0 DNGs on the generic curve, unclipped pixels whose luminance renders at 254 or more fall from up to 22.5 % to 0 at +1 EV and from up to 35 % to at most 0.03 % at +2 EV, apart from one sky that is mostly at the clip (#1632). Not compared with Lightroom's output | +| LR-BEHAV-RENDER-FIDELITY | Rendering matches Lightroom | P1 | 🟡 | `crates/pipeline/src/lib.rs`, `crates/pipeline/src/tone.rs` | Process V4 calibrates global camera-look Contrast and Blacks against black-box Lightroom exports of Sony ILCE-7CR photos. Held-out response errors are 0.038 and 0.077 stops; V1/V2 keep their rendering. Whites retains V2 and awaits a follow-up. Exposure, Highlights/Shadows, other operators and broader camera coverage remain open (`docs/light-v3.md`). From process V8 Whites, the parametric curve and the point curves follow Camera Raw's measured response on synthetic grey steps, the master curve hue-preserving ([curve-stage.md](curve-stage.md)). From process V5 a raw's tone curve rolls off into white in stops (past a camera curve's last fitted knot, or from half a stop below the generic curve's white point instead of clipping), so Exposure +1 and +2 keep the highlights the sensor recorded: on 12 CC0 corpus raws and 6 CC0 DNGs on the generic curve, unclipped pixels whose luminance renders at 254 or more fall from up to 22.5 % to 0 at +1 EV and from up to 35 % to at most 0.03 % at +2 EV, apart from one sky that is mostly at the clip (#1632). Not compared with Lightroom's output | | LR-BEHAV-DRAGDROP | Drag and drop | P1 | ✅ | `crates/ui-egui/src/lib.rs`, `crates/ui-egui/src/panels/grid.rs` (`drag_feedback`), `crates/ui-egui/src/panels/left.rs` (`drop_target`, `album_drag_over`, `top_level_drop_target`, `drag_auto_scroll`), `crates/ui-egui/src/destination.rs`, `crates/ui-egui/src/widgets.rs` (`context_menu`), `crates/ui-egui/src/widgets/text_field.rs`, `crates/ui-egui/src/tests/carried_right_click.rs`, `crates/ui-egui/src/tests/carried_text_field_menu.rs` | a right-click while photos are carried opens no context menu (every menu opened through `widgets::context_menu`: sidebar rows, grid cells, lists; a text field's own Cut / Copy / Paste menu too); files → app (a drop-target card while they hover, then the import review); grid photos → an album row (adds the selection, with a count badge while dragging); sidebar album / folder rows → a folder (moves it; its name follows the pointer); a drag of albums or grid photos near the top or bottom edge of the sidebar scrolls it (faster nearer the edge, only while the pointer is over the sidebar); when another folder has the same name, the dragged label, the Move question and the toast name the folder it is in (`home (/a)`); an album drop's toast does the same for an album of that name in another album folder (two in the same place have nothing to tell them apart and keep the plain name); only the primary button drags photos and drops them: a right-button drag over a grid cell neither picks photos up nor changes the selection, and a right-button release while photos are dragged neither drops them nor ends the drag | | LR-BEHAV-TOAST | Toast notifications | P1 | ✅ | `crates/ui-egui/src/panels.rs` | | | LR-BEHAV-DIALOGS | Dialogs fit the window | P1 | ✅ | `crates/ui-egui/src/dialogs.rs` (`dialog_body`, `list_height`), `crates/ui-egui/src/tests/dialog_fit.rs`, `crates/ui-egui/src/tests/dialog_copy.rs`, `crates/ui-egui/src/tests/dialogs.rs` (`a_click_outside_closes_the_dialog_when_settings_allow_it`) | a dialog taller than the window (Export on a 1366×768 screen, issue #781) never runs off it: its options scroll while the title bar and the Cancel / confirm row stay on screen (the confirm button names its action: Create, Rename, Create Stacks, Export 3 Photos…, with "OK" kept only for a one-field prompt opened with a command that has no verb, `crates/ui-egui/src/tests/dialog_copy.rs`); lists that scroll on their own (What's New, All Metadata, shortcuts, smart-album rules, credits) get shorter first; dialogs that fit look as before; Import keeps its own resizable, scrolling window; Settings → Dialogs → Close a dialog by clicking outside it (off by default, so a stray click never throws away a dialog's choices): a click pressed and released on the dimmed backdrop closes the dialog like Esc and doesn't reach the panels below, while a drag that ends outside (a slider pulled past the edge) or a click that closes a dropdown keeps it; the import review never closes this way (`clicked_backdrop`); a one-line prompt (Rename Folder, New Folder on Disk, the preset and version names, New Library when its name can't be used, Auto-Tag from Tracklog) the engine refuses stays open with its text and shows the reason in a toast, so the name can be corrected, where it used to close without a word; a New Folder on Disk that works says so (“Created folder “Selects” in “2026/Shoot””, naming the parent by its last two folders as dialogs do) | @@ -732,7 +732,7 @@ From `08-lightroom-classic-extras.md` (Classic-only features) and part 2 of `06- | LRC-DEV-CALIB | Calibration panel | P1 | ✅ | `ctl:calibration.*` | | | LRC-DEV-TAT | Targeted adjustment tools | P1 | ✅ | `cmd:develop.targeted` (`target`: curve / hue / sat / lum) | | | LRC-DEV-DEFAULTS | Per-camera raw defaults | P1 | ✅ | `cmd:library.preferences` (`camera`, `import.perCamera`), `crates/ui-egui/src/dialogs/settings.rs` | Settings → Import: raw default and per-camera presets | -| LRC-DEV-PROCESS | Process versions, Update to Current Process | P1 | ✅ | `cmd:develop.updateProcess`, `cmd:develop.reset`, `cmd:develop.get`, `crates/develop/src/settings.rs`, `crates/pipeline/src/finish.rs`, `docs/process-versions.md` | Each photo keeps its saved rendering process. V1 is legacy, V2 preserves Highlights/Shadows detail, V3 is pixel-scale sharpening, V4 calibrates camera-look Contrast and Blacks, V5 rolls raw tone curves off into white in stops (#1632), V6 takes colour noise reduction to the joint method (#815), V7 draws film grain from crystal layers. New photos and Reset use the latest; Update is one undoable step and never downgrades a future number. Copy/paste/sync preserve the receiving process. Persistent render keys include the resolved process from V3 on; V1/V2 keys remain unchanged. | +| LRC-DEV-PROCESS | Process versions, Update to Current Process | P1 | ✅ | `cmd:develop.updateProcess`, `cmd:develop.reset`, `cmd:develop.get`, `crates/develop/src/settings.rs`, `crates/pipeline/src/finish.rs`, `docs/process-versions.md` | Each photo keeps its saved rendering process. V1 is legacy, V2 preserves Highlights/Shadows detail, V3 is pixel-scale sharpening, V4 calibrates camera-look Contrast and Blacks, V5 rolls raw tone curves off into white in stops (#1632), V6 takes colour noise reduction to the joint method (#815), V7 draws film grain from crystal layers, V8 measures Whites and the tone curves against Lightroom and keeps hue through the master curve. New photos and Reset use the latest; Update is one undoable step and never downgrades a future number. Copy/paste/sync preserve the receiving process. Persistent render keys include the resolved process from V3 on; V1/V2 keys remain unchanged. | | LRC-DEV-VIEWOPTIONS | Develop view options | P2 | 🟡 | `cmd:view.viewOptions`, `crates/ui-egui/src/dialogs/settings.rs` (`view_options`) | View ▸ View Options… (⌘J), the Loupe View part: Show Info Overlay with Info 1 / Info 2, and the three lines of each (none, file name, capture date, dimensions, exposure, camera, lens, camera + lens) with Use Defaults; Show Briefly When Photo Changes under each Info (one at most): with the overlay off, that Info shows for 3 s each time the loupe changes photo; General's Show message when loading or rendering photos (on by default; off, the loupe does not say "Rendering…"); applied as they change, saved with the app settings; `view.viewOptions {info1, info2, briefly, loupeMessages}` sets them for agents. Not yet: the Grid View tab, more fields (ratings, metadata, copy name), the video-frame option | | LRC-DEV-LOUPEOVERLAY | Loupe overlay: layout image | P2 | 🟡 | `cmd:view.chooseLayoutImage`, `cmd:view.layoutImage`, `cmd:view.layoutImageOpacity`, `cmd:view.layoutImageMatte`, `crates/ui-egui/src/panels/layout_overlay.rs` | View ▸ Loupe Overlay: a PNG with transparency (a cover layout, a banner's safe areas) fitted and centred over the loupe photo, following zoom and pan; opacity and matte (the photo darkened outside the graphic's box) in steps; ⌥⌘O shows / hides it; read off the UI thread; saved with the UI state. Not yet: the Grid and Guides overlays, moving and resizing the layout with ⌘ held, free opacity / matte sliders | | LRC-DEV-VIDEO | Video frame capture | P2 | ⬜ | | | @@ -805,6 +805,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | 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`) | +| 2026-11-10 | minor | LR-EDIT-LIGHT-WHITES, LR-EDIT-LIGHT-CURVE-PARAM, LR-EDIT-LIGHT-CURVE-POINT, LR-BEHAV-RENDER-FIDELITY, LRC-DEV-PROCESS: process V8 measures Whites and the parametric curve against Camera Raw and applies the master curve hue-preserving ([curve-stage.md](curve-stage.md)); statuses unchanged | | 2026-11-07 | minor | LR-EDIT-EFFECTS-GRAIN, LRC-DEV-PROCESS: process V7 takes film grain to crystal layers ([grain.md](grain.md)); V1 to V6 keep value noise | | 2026-11-06 | minor | LR-EDIT-DETAIL-CNR, LRC-DEV-PROCESS: process V6 takes colour noise reduction to the joint method on linear R−Y / B−Y (issue #815); status unchanged | | 2026-11-05 | minor | LR-BEHAV-RENDER-FIDELITY, LRC-DEV-PROCESS: process V5 rolls a raw's tone curve off into white in stops, past a camera curve's last knot and from half a stop below the generic curve's white point, so raising Exposure no longer turns recorded highlights white (#1632); statuses and counts unchanged | diff --git a/docs/process-versions.md b/docs/process-versions.md index b27367ed6f8..ab2a16b977a 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: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map and, with the parametric curve, comes from measured tables (Whites reaches into the midtones; the regions are broad and add); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V7 keep Whites in the tone map and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the tables. Renders with Whites, the parametric curve and the point curves neutral are 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: Whites and the tone curves measured against Lightroom ([curve-stage.md](curve-stage.md)); V1 to V7 keep theirs | | 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 56fc27ed793..4e7ca2c0d23 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -2,6 +2,14 @@ ## Unreleased +### Whites and the tone curves behave as in Lightroom (process V8) +- Whites now reaches into the upper midtones as Lightroom's does, and the Highlights, Lights, Darks and Shadows + regions of the parametric curve are as broad as Lightroom's and add up the same way: both follow Lightroom's + measured response. A contrast curve no longer turns orange towards red: the point curve keeps colours' hue, and + the red, green and blue curves act on their channel after it. This is rendering process 8: new photos (and Reset) + get it, photos you already edited keep their look until you choose Photo ▸ Update to Current Process. See + [Whites and the tone curves](curve-stage.md). + ### 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 diff --git a/tools/lr_tone_charts.py b/tools/lr_tone_charts.py new file mode 100644 index 00000000000..c67aa2dad20 --- /dev/null +++ b/tools/lr_tone_charts.py @@ -0,0 +1,200 @@ +#!/usr/bin/env python3 +"""Measure Lightroom's Whites and parametric curve on synthetic grey steps (process V8, docs/curve-stage.md). + + python3 tools/lr_tone_charts.py charts OUT_DIR + Writes linear DNG charts (48 grey steps plus colour patches) with the settings embedded as XMP: + one neutral chart, Whites at +-25/50/100 and each parametric region at +-25/50/75/100 (default splits). + (render every DNG through Camera Raw to a 16-bit Adobe RGB (1998) TIFF with the same file name) + python3 tools/lr_tone_charts.py tables RENDER_DIR OUT_RS + Reads the renders and writes the Rust tables of `lightcraft_pipeline::curve_stage`. + +The charts are original test data generated here; nothing in them comes from Adobe. Only Camera Raw's output is +measured. Requires numpy and tifffile (tools/requirements-lr-tone-charts.txt). +""" +import json +import os +import struct +import sys + +import numpy as np + +W, H = 2400, 1600 +CELL = 60 +# linear sRGB -> XYZ (D65) inverse, stored as the DNG's ColorMatrix1 so the chart decodes as scene-linear sRGB +XYZ_TO_SRGB = [[3.2404542, -1.5371385, -0.4985314], [-0.969266, 1.8760108, 0.041556], [0.0556434, -0.2040259, 1.0572252]] +WHITES = (-100, -50, -25, 25, 50, 100) +REGIONS = ("Shadows", "Darks", "Lights", "Highlights") +REGION_AMOUNTS = (-100, -75, -50, -25, 25, 50, 75, 100) + + +def xmp(**settings): + """Camera Raw settings with everything else neutral (no sharpening, noise reduction, lens or vignette correction).""" + d = dict(CameraProfile="Embedded", WhiteBalance="As Shot", Exposure2012="0.00", Contrast2012="0", Highlights2012="0", + Shadows2012="0", Whites2012="0", Blacks2012="0", ToneCurveName2012="Linear", Sharpness="0", LuminanceSmoothing="0", + ColorNoiseReduction="0", LensProfileEnable="0", PostCropVignetteAmount="0", VignetteAmount="0", Texture="0", + Clarity2012="0", Dehaze="0", Vibrance="0", Saturation="0") + d.update({k: str(v) for k, v in settings.items()}) + attrs = " ".join(f'crs:{k}="{v}"' for k, v in d.items()) + return ('' + '').encode("utf8") + + +def write_dng(path, img, xm): + """A minimal linear (LinearRaw) DNG: `img` is scene-linear RGB 0..1, height x width x 3.""" + h, w = img.shape[:2] + px = (np.clip(img, 0, 1) * 65535 + 0.5).astype(" linear sRGB as the exact inverse of the sRGB primaries' matrix (the patches' colours) + x2s = np.linalg.inv(np.array([[0.4124564, 0.3575761, 0.1804375], [0.2126729, 0.7151522, 0.0721750], [0.0193339, 0.1191920, 0.9503041]])) + img = np.full((H, W, 3), 0.18) + patches = [] + + def put(c, **k): + i = len(patches) + x, y = (i % (W // CELL)) * CELL, (i // (W // CELL)) * CELL + ok = bool(np.all(c >= 0) and np.all(c <= 1)) + if ok: + img[y + 6:y + CELL - 6, x + 6:x + CELL - 6] = c + patches.append(dict(y=y + 6, x=x + 6, w=CELL - 12, h=CELL - 12, ok=ok, **k)) + + for g in np.geomspace(0.002, 1, 48): + put(np.array([g, g, g]), kind="grey", v=float(g)) + for lightness in (0.25, 0.4, 0.55, 0.7, 0.82, 0.92): + for chroma in (0.04, 0.08, 0.12): + for hue in range(0, 360, 15): + lab = np.array([lightness, chroma * np.cos(np.radians(hue)), chroma * np.sin(np.radians(hue))]) + put(x2s @ (m1i @ ((m2i @ lab) ** 3)), kind="colour", L=lightness, C=chroma, hue=hue) + return img, patches + + +def variants(): + v = {"neutral": {}} + for a in WHITES: + v[f"whites{a:+d}"] = {"Whites2012": a} + for r in REGIONS: + for a in REGION_AMOUNTS: + v[f"par_{r.lower()}{a:+d}"] = {"Parametric" + r: a} + return v + + +# ---- tables ------------------------------------------------------------------------------------------------- + +ADOBE_TO_XYZ = np.array([[0.5767309, 0.1855540, 0.1881852], [0.2973769, 0.6273491, 0.0752741], [0.0270343, 0.0706872, 0.9911085]]) +# XYZ (D65) -> linear ProPhoto RGB (D50, Bradford), as `RgbSpace::to_space` +XYZ_TO_PROPHOTO = (np.array([[1.3459433, -0.2556075, -0.0511118], [-0.5445989, 1.5081673, 0.0205351], [0.0, 0.0, 1.2118128]]) + @ np.array([[1.0478112, 0.0228866, -0.0501270], [0.0295424, 0.9904844, -0.0170491], + [-0.0092345, 0.0150436, 0.7521316]])) + + +def srgb_encode(v): + v = np.clip(v, 0, None) + return np.where(v <= 0.0031308, v * 12.92, 1.055 * v ** (1 / 2.4) - 0.055) + + +def grey_levels(path, patches): + """The grey steps of a Camera Raw render as sRGB-encoded linear ProPhoto values (the curve stage's domain).""" + import tifffile + a = tifffile.imread(path).astype(np.float64) + a /= 65535.0 if a.max() > 255 else 255.0 + out = [] + for q in patches: + if q["kind"] != "grey" or not q["ok"]: + continue + rgb = a[q["y"] + 8:q["y"] + q["h"] - 8, q["x"] + 8:q["x"] + q["w"] - 8].reshape(-1, 3).mean(0) + xyz = ADOBE_TO_XYZ @ (np.clip(rgb, 0, 1) ** (563 / 256)) + out.append(srgb_encode((XYZ_TO_PROPHOTO @ xyz)[1])) + return np.array(out) + + +def delta_table(neutral, edited): + """Output minus input over 257 evenly spaced inputs, from matched grey steps; zero at both ends.""" + o = np.argsort(neutral) + x, y = neutral[o], np.maximum.accumulate(edited[o]) + grid = np.linspace(0, 1, 257) + d = np.interp(grid, x, y - x) + lo, hi = grid < x[0], grid > x[-1] + d[lo] = np.interp(grid[lo], [0, x[0]], [0, d[~lo][0]]) + d[hi] = np.interp(grid[hi], [x[-1], 1], [d[~hi][-1], 0]) + return d + + +def tables(render_dir, out_rs): + patches = json.load(open(os.path.join(render_dir, "manifest.json")))["patches"] + tif = lambda n: os.path.join(render_dir, f"curve__{n}.tif") + n0 = grey_levels(tif("neutral"), patches) + rows = lambda names: [delta_table(n0, grey_levels(tif(n), patches)) for n in names] + whites = rows([f"whites{a:+d}" for a in WHITES]) + regions = [rows([f"par_{r.lower()}{a:+d}" for a in REGION_AMOUNTS]) for r in REGIONS] + fmt = lambda t: "[" + ", ".join(f"{v:.6f}" for v in t) + "]" + s = ["// @generated by tools/lr_tone_charts.py from Camera Raw renders of its synthetic grey steps (docs/curve-stage.md).", + "// Output minus input of each setting on sRGB-encoded linear ProPhoto values, 257 evenly spaced inputs from 0 to 1.", + "", + f"pub const WHITES_AMOUNTS: [f32; {len(WHITES)}] = [{', '.join(f'{a}.0' for a in WHITES)}];", + f"pub static WHITES: [[f32; 257]; {len(WHITES)}] = [", *[f" {fmt(t)}," for t in whites], "];", + "", + "/// Shadows, Darks, Lights, Highlights at the default splits (25, 50, 75).", + f"pub const REGION_AMOUNTS: [f32; {len(REGION_AMOUNTS)}] = [{', '.join(f'{a}.0' for a in REGION_AMOUNTS)}];", + f"pub static REGIONS: [[[f32; 257]; {len(REGION_AMOUNTS)}]; 4] = ["] + for r in regions: + s += [" ["] + [f" {fmt(t)}," for t in r] + [" ],"] + s += ["];", ""] + with open(out_rs, "w") as f: + f.write("\n".join(s)) + + +def main(): + if len(sys.argv) == 3 and sys.argv[1] == "charts": + out = sys.argv[2] + os.makedirs(out, exist_ok=True) + img, patches = chart() + json.dump(dict(patches=patches), open(os.path.join(out, "manifest.json"), "w")) + for name, settings in variants().items(): + write_dng(os.path.join(out, f"curve__{name}.dng"), img, xmp(**settings)) + elif len(sys.argv) == 4 and sys.argv[1] == "tables": + tables(sys.argv[2], sys.argv[3]) + else: + sys.exit(__doc__) + + +if __name__ == "__main__": + main() diff --git a/tools/requirements-lr-tone-charts.txt b/tools/requirements-lr-tone-charts.txt new file mode 100644 index 00000000000..c91f37d19e9 --- /dev/null +++ b/tools/requirements-lr-tone-charts.txt @@ -0,0 +1,4 @@ +# Python packages for tools/lr_tone_charts.py (crates/pipeline/src/curve_stage_tables.rs, docs/curve-stage.md). +# python3 -m venv .venv-lr-tone && .venv-lr-tone/bin/pip install -r tools/requirements-lr-tone-charts.txt +numpy==2.5.4 +tifffile==2026.11.8 From b16fd0c4321ee47a1846f8e46b67f9a859170c04 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Wed, 11 Nov 2026 06:52:29 +0100 Subject: [PATCH 02/20] LR-BEHAV-RENDER-FIDELITY: doc comments for the V8 curve stage, Gap 3 evidence for V8 Whites (#523) --- crates/pipeline/src/curve_stage.rs | 5 +++++ docs/gaps.md | 3 ++- tools/lr_tone_charts.py | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/pipeline/src/curve_stage.rs b/crates/pipeline/src/curve_stage.rs index bb516c5a432..c460ab7e00a 100644 --- a/crates/pipeline/src/curve_stage.rs +++ b/crates/pipeline/src/curve_stage.rs @@ -89,6 +89,7 @@ fn parametric(c: &ToneCurve) -> Lut1 { lut } +/// The measured Whites curve at `amount`, or `None` at 0. fn whites(amount: f64) -> Option { if amount == 0.0 { return None; @@ -179,11 +180,13 @@ impl CurveStage { } } +/// Linear Rec.2020 to linear ProPhoto and back, built once. fn matrices() -> &'static ([[f32; 3]; 3], [[f32; 3]; 3]) { static M: std::sync::OnceLock<([[f32; 3]; 3], [[f32; 3]; 3])> = std::sync::OnceLock::new(); M.get_or_init(crate::light_v3::prophoto_matrices) } +/// Multiplies a colour by a 3 × 3 matrix. fn mul3(m: &[[f32; 3]; 3], d: [f32; 3]) -> [f32; 3] { std::array::from_fn(|r| m[r][0] * d[0] + m[r][1] * d[1] + m[r][2] * d[2]) } @@ -192,10 +195,12 @@ fn mul3(m: &[[f32; 3]; 3], d: [f32; 3]) -> [f32; 3] { mod tests { use super::*; + /// Default settings on process V8. fn v8() -> DevelopSettings { DevelopSettings { process: Process::V8.version(), ..Default::default() } } + /// V8 settings with only Whites at `v`. fn with_whites(v: f64) -> DevelopSettings { let mut s = v8(); s.light.whites = v; diff --git a/docs/gaps.md b/docs/gaps.md index 4e58bb69807..537eb72531f 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -17,7 +17,7 @@ Hours are Opus 5.5 agent wall-clock hours (see [target-app-parity.md](target-app |---:|---|---|---|---:|---| | 1 B | **Camera colour is estimated, not measured** (LR-PROF-CAMERACOLOR). Raws start from a per-file fit to the camera JPEG, 10 bundled profiles, 52 spectral matrices (plus same-sensor bodies, e.g. the X-T30 through the X-T3) or chart-measured matrices (the EOS D60); others use a neutral matrix (a black-and-white camera JPEG gives its tone curve only, #577; dark JPEG tones also guide the toe, #1307) | ΔE vs camera JPEG 2.9–10 after fitting (raw-parity.md); 1 chart-calibrated model (EOS D60: its Kelvin scale and fallback colour, the look stays the JPEG fit) vs 1,500 Adobe Standard profiles | every raw shooter sees colour that is close but not Lightroom's; some get neutral-matrix colour | 50–90 | [raw-parity](raw-parity.md#colour) | | 2 B | **CR3 variants no public file uses** (LR-IMP-FORMATS): `crx.rs` refuses vertical-tile C-RAW, partial-subband and other plane coding, multi-tile 0x200 and adaptive low-frequency gains, and those files fall back to the preview. All 110 CC0 CR3s on raw.pixls.us (31 folders) decode from sensor data, so none of these variants has a public sample; 26 CR3 bodies are verified (M50 / R100 / R8 exact, R5 Mark II pinned, 22 more pinned on one CC0 file each and checked against the camera JPEG, [cr3.md](cr3.md#further-bodies-one-cc0-file-each)). HEIF stills are `.HIF` files, not CR3; no CR3 sRAW / mRAW sample exists | measured: Canon's share whose camera fully works 73% → 94% (raw-parity.md); 18 of 22 popular Canon bodies write CR3, all 18 now verified | +0.3 points of photographers; the variants surface only as user files that open as a preview | 10–25 | [raw-parity](raw-parity.md#remaining-work-ranked-by-photographers-unlocked-per-hour) | -| 3 B | **Render fidelity partial** (LR-BEHAV-RENDER-FIDELITY): calibrated camera-look Contrast and Blacks; other operators need measurement; from process V5 raw tone curves roll off into white in stops, so Exposure keeps recorded highlights (#1632); from V8 Whites and the tone curves are measured against Camera Raw ([curve-stage.md](curve-stage.md)) | process V3 reduces held-out response error from 0.136 to 0.038 stops for Contrast and 0.424 to 0.077 for Blacks on one Sony camera; Whites remains V2 pending a follow-up | imported Lightroom edits still differ, especially on uncalibrated operators and cameras | 30–60 | [calibrated Light operators](light-v3.md), [process versions](process-versions.md) | +| 3 B | **Render fidelity partial** (LR-BEHAV-RENDER-FIDELITY): calibrated camera-look Contrast and Blacks; other operators need measurement; from process V5 raw tone curves roll off into white in stops, so Exposure keeps recorded highlights (#1632); from V8 Whites and the tone curves are measured against Camera Raw ([curve-stage.md](curve-stage.md)) | process V3 reduces held-out response error from 0.136 to 0.038 stops for Contrast and 0.424 to 0.077 for Blacks on one Sony camera; Whites stays V2 in V4 to V7 | imported Lightroom edits still differ, especially on uncalibrated operators and cameras | 30–60 | [calibrated Light operators](light-v3.md), [process versions](process-versions.md) | | 4 | ~~Original-pixel detail at 100%~~ (LR-VIEW-ZOOM): closed 2026-10-12, see Closed recently | checklist row ✅ | — | 0 | [ui-parity](ui-parity.md) | | 5 B | **AI masks: Subject, Sky, People, Background, Landscape** are heuristics; Object / Describe run SAM 3 but its download has no mirror configured | `crates/segment`; ai-masks.md; MASK rows 67% | masking is how most Lightroom users edit today | 40–70 + model decision | [target-app-parity](target-app-parity.md#ai) | | 6 | **Compressed ORF** (support withdrawn) | #3775 decoder removed pending provenance review; uncompressed support remains | compressed files use embedded JPEG previews when available, not sensor data | pending review | [orf-compression](orf-compression.md) | @@ -90,6 +90,7 @@ Beta-blocking gaps (B) total **~230–430 h**; with the stability and platform w | Date | Change | Summary | |---|---|---| +| 2026-11-11 | minor | Gap 3: from process V8 Whites and the tone curves are measured against Camera Raw ([curve-stage.md](curve-stage.md)); gap not closed | | 2026-11-01 | minor | Gap 13: Lightroom catalog backup zips import directly, and a backup of an imported catalog adds no collection twice (#2592); the gap stays open | | 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). | diff --git a/tools/lr_tone_charts.py b/tools/lr_tone_charts.py index c67aa2dad20..d52b6f6f3a8 100644 --- a/tools/lr_tone_charts.py +++ b/tools/lr_tone_charts.py @@ -90,6 +90,7 @@ def chart(): patches = [] def put(c, **k): + """Place patch colour `c` in the next cell; a colour outside 0..1 is listed but left black.""" i = len(patches) x, y = (i % (W // CELL)) * CELL, (i // (W // CELL)) * CELL ok = bool(np.all(c >= 0) and np.all(c <= 1)) @@ -108,6 +109,7 @@ def put(c, **k): def variants(): + """Name and XMP settings of every chart: neutral, each Whites amount, each region amount.""" v = {"neutral": {}} for a in WHITES: v[f"whites{a:+d}"] = {"Whites2012": a} @@ -127,6 +129,7 @@ def variants(): def srgb_encode(v): + """Linear to sRGB-encoded values.""" v = np.clip(v, 0, None) return np.where(v <= 0.0031308, v * 12.92, 1.055 * v ** (1 / 2.4) - 0.055) @@ -159,6 +162,7 @@ def delta_table(neutral, edited): def tables(render_dir, out_rs): + """Measure the Camera Raw renders in `render_dir` and write the Rust tables to `out_rs`.""" patches = json.load(open(os.path.join(render_dir, "manifest.json")))["patches"] tif = lambda n: os.path.join(render_dir, f"curve__{n}.tif") n0 = grey_levels(tif("neutral"), patches) @@ -183,6 +187,7 @@ def tables(render_dir, out_rs): def main(): + """Command line: `charts OUT_DIR` or `tables RENDER_DIR OUT_RS`.""" if len(sys.argv) == 3 and sys.argv[1] == "charts": out = sys.argv[2] os.makedirs(out, exist_ok=True) From 815ebe60a3d64b20a33f62b90a56d4afe0c3804c Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Wed, 11 Nov 2026 07:45:33 +0100 Subject: [PATCH 03/20] LR-BEHAV-RENDER-FIDELITY: what's new names process 9 (#523) --- docs/whats-new.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/whats-new.md b/docs/whats-new.md index 2f9648725db..344fca12af7 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -6,7 +6,7 @@ - Whites now reaches into the upper midtones as Lightroom's does, and the Highlights, Lights, Darks and Shadows regions of the parametric curve are as broad as Lightroom's and add up the same way: both follow Lightroom's measured response. A contrast curve no longer turns orange towards red: the point curve keeps colours' hue, and - the red, green and blue curves act on their channel after it. This is rendering process 8: new photos (and Reset) + the red, green and blue curves act on their channel after it. This is rendering process 9: new photos (and Reset) get it, photos you already edited keep their look until you choose Photo ▸ Update to Current Process. See [Whites and the tone curves](curve-stage.md). From fc55dde2269e0f436caeb4a86df3e7e425cb32ec Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Wed, 11 Nov 2026 09:12:56 +0100 Subject: [PATCH 04/20] LR-BEHAV-RENDER-FIDELITY: review fixes: neutral-render claims, Whites row, curve graph limit, Python version (#523) --- docs/curve-stage.md | 6 ++++-- docs/parity-checklist.md | 4 ++-- docs/process-versions.md | 2 +- tools/requirements-lr-tone-charts.txt | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/curve-stage.md b/docs/curve-stage.md index b676cb2ef0e..a79fe23fdc8 100644 --- a/docs/curve-stage.md +++ b/docs/curve-stage.md @@ -39,8 +39,8 @@ After the tone map and V4's calibrated Contrast and Blacks, before the colour st 6. Values above SDR white (an HDR render) continue with slope 1. The tone map no longer applies Whites under V9 (`finish::base_tone`), and the V8 output-curve tables are not built -(`FinishParams::curves` is `None`). With Whites, the parametric curve and the point curves all neutral, the stage -does not run and the render is V8's. +(`FinishParams::curves` is `None`). With Whites, the parametric curve and the point curves all neutral, the curve +stage does not run. ## How it was measured @@ -60,6 +60,8 @@ predicted from the grey-step curves under the hue-preserving rule in step 3. The ## Limits - The tables are measured with Lightroom's default splits. Moved splits use the earlier analytic model. +- The Edit panel's curve graph still draws the analytic parametric curve and drags against it. Under V9 at the + default splits the photo renders the measured regions, so the graph's shape can differ from the render's. - The point curves' shape between the points is LightCraft's spline, not measured. What is measured for them is how they apply: hue preserving, then the red, green and blue curves per channel. - Local (mask) Whites keeps the earlier processes' operator. diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 20f276eff2c..ff73818452b 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -185,7 +185,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | From process V2, the same base as Highlights: dark areas keep their local contrast when lifted (#632); from process V8, the gaps in dark lettering on a bright panel are not lifted into bright blocks. Alt/Option-drag shows shadow clipping (white, clipped channels in colour) | | LR-EDIT-LIGHT-WHITES | Whites | P0 | 🟡 | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | From process V9 Whites is measured against Camera Raw renders of synthetic grey steps and reaches into the midtones as Lightroom's does ([curve-stage.md](curve-stage.md)); not yet compared on photos per camera. V4 to V8 preserve V2 Whites for both signs; measured V2 check response error is 0.075 stops on the Sony test photos (`docs/light-v3.md`). Alt/Option-drag shows highlight clipping (black, clipped channels in colour) | | LR-EDIT-LIGHT-BLACKS | Blacks | P0 | 🟡 | `ctl:light.blacks`, `crates/pipeline/src/visualize.rs` | From process V4, global Blacks on the camera-look path uses a fitted per-channel/luminance mix. Check response error 0.424 to 0.077 stops on six held-out Sony photos; deepest tones still differ. Other sources and local adjustments retain V2 (`docs/light-v3.md`). Alt/Option-drag shows shadow clipping (white, clipped channels in colour) | -| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | from process V9 the regions are Camera Raw's measured response at the default splits, broad and additive ([curve-stage.md](curve-stage.md)); the graph draws the renderer's own curve model; dragging the line moves the region under the pointer (one undo step) | +| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | from process V9 the regions are Camera Raw's measured response at the default splits, broad and additive ([curve-stage.md](curve-stage.md)); the graph draws the analytic model of V1 to V8, which under V9 at the default splits can differ from the measured regions the photo renders (follow-up); dragging the line moves the region under the pointer (one undo step) | | LR-EDIT-LIGHT-CURVE-POINT | Point curve | P0 | ✅ | `cmd:develop.curve`, `cmd:curve.reset`, `cmd:curve.presets`, `cmd:curve.applyPreset`, `cmd:curve.savePreset`, `cmd:curve.deletePreset`, `cmd:curve.importPresets`, `cmd:curve.exportPresets`, `cmd:file.importCurvePresets`, `cmd:file.exportCurvePresets`, `crates/engine/src/cmd/curves.rs`, `crates/ui-egui/src/panels/edit.rs` | click to add a point; drag a point in both axes (between its neighbours, input / output readout, one undo step per drag; ⌥-drag moves it a tenth as far for fine adjustment, issue #1363); drag empty space to add and drag; double-click removes; reset: double-click a channel selector (that channel), the Reset button under the graph (every curve incl. parametric) or right-click the graph (channel / all); Point Curve preset dropdown: own Linear / Medium Contrast / Strong Contrast, user presets (save the current point curves, delete by right-click; saved with the library), import / export as `.lccurve` JSON; from process V9 the master curve keeps hue as Lightroom's does (largest and smallest channel through the curve, the middle one in proportion), and the red, green and blue curves follow it per channel ([curve-stage.md](curve-stage.md)) | | LR-EDIT-LIGHT-CURVE-RGB | Per-channel curves | P0 | ✅ | `cmd:develop.curve` (`channel`) | | | LR-EDIT-LIGHT-CURVE-REFINESAT | Curve saturation compensation | P1 | ✅ | `ctl:curve.refineSaturation` | | @@ -467,7 +467,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-BEHAV-OFFLINE | Offline editing | P1 | ✅ | | local-first: everything works offline | | LR-BEHAV-WEB-SAFETY | Library safety in the browser build | P1 | 🟡 | `cmd:file.backupLibrary`, `cmd:file.restoreLibrary`, `apps/lightcraft-web/src/safety.rs`, `apps/lightcraft-web/src/backup.rs`, `apps/lightcraft-web/src/files.rs` | web only (experimental): Back Up Library (zip of the catalog and every stored original) and a non-destructive Restore; failed saves show as unsaved and are retried; a photo that can't be stored isn't added; one tab per library (Web Locks); notices for storage that isn't persistent and for a library that can't open; `?reset` asks first; a panic shows a message. Missing: `?safe` start, deleting originals of removed photos, zip64 (backups > 4 GB) | | LR-BEHAV-GPU | GPU acceleration | P0 | ✅ | `crates/gpu/src/render.rs`, `cmd:app.gpu`, `docs/gpu-pipeline.md`, `crates/ui-egui/src/panels/notices.rs` | CPU fallback per render on device limits, out of memory, device errors / loss, incomplete or black results (`perf.gpuReason`, `perf.gpuFallback`; each render reports its own reason — `lightcraft_gpu::try_render`, `gpuFallback` per exported file — issue #675); short submissions for slow iGPUs; backend choice (DX12 only on Windows, `LIGHTCRAFT_GPU_BACKEND` / `WGPU_BACKEND`), device created after the window opens, crash sentinel (issue #136); a GPU lost while LightCraft runs (driver reset) stops it with that message and turns GPU rendering off for the next start, which says why (issue #1337; the window's renderer can't survive the lost device); quitting waits (up to 2 s) for renders in flight and starts no new GPU work, so none is inside the driver when the process exits (`crates/gpu/src/exit.rs`, issue #620; seen crashing only on Linux + NVIDIA, other drivers unverified); with GPU rendering on and no adapter found at all (e.g. no Vulkan loader on NixOS outside `nix develop`), the desktop app says once per session that it renders on the CPU and points to Help ▸ System Info (`gpu_notice`; not when the GPU is turned off or only a software adapter exists); no tiling beyond the buffer limit (CPU) | -| LR-BEHAV-RENDER-FIDELITY | Rendering matches Lightroom | P1 | 🟡 | `crates/pipeline/src/lib.rs`, `crates/pipeline/src/tone.rs` | Process V4 calibrates global camera-look Contrast and Blacks against black-box Lightroom exports of Sony ILCE-7CR photos. Held-out response errors are 0.038 and 0.077 stops; V1/V2 keep their rendering. Whites retains V2 and awaits a follow-up. Exposure, Highlights/Shadows, other operators and broader camera coverage remain open (`docs/light-v3.md`). From process V9 Whites, the parametric curve and the point curves follow Camera Raw's measured response on synthetic grey steps, the master curve hue-preserving ([curve-stage.md](curve-stage.md)). From process V5 a raw's tone curve rolls off into white in stops (past a camera curve's last fitted knot, or from half a stop below the generic curve's white point instead of clipping), so Exposure +1 and +2 keep the highlights the sensor recorded: on 12 CC0 corpus raws and 6 CC0 DNGs on the generic curve, unclipped pixels whose luminance renders at 254 or more fall from up to 22.5 % to 0 at +1 EV and from up to 35 % to at most 0.03 % at +2 EV, apart from one sky that is mostly at the clip (#1632). Not compared with Lightroom's output | +| LR-BEHAV-RENDER-FIDELITY | Rendering matches Lightroom | P1 | 🟡 | `crates/pipeline/src/lib.rs`, `crates/pipeline/src/tone.rs` | Process V4 calibrates global camera-look Contrast and Blacks against black-box Lightroom exports of Sony ILCE-7CR photos. Held-out response errors are 0.038 and 0.077 stops; V1/V2 keep their rendering. Up to V8 Whites retains V2. Exposure, Highlights/Shadows, other operators and broader camera coverage remain open (`docs/light-v3.md`). From process V9 Whites, the parametric curve and the point curves follow Camera Raw's measured response on synthetic grey steps, the master curve hue-preserving ([curve-stage.md](curve-stage.md)). From process V5 a raw's tone curve rolls off into white in stops (past a camera curve's last fitted knot, or from half a stop below the generic curve's white point instead of clipping), so Exposure +1 and +2 keep the highlights the sensor recorded: on 12 CC0 corpus raws and 6 CC0 DNGs on the generic curve, unclipped pixels whose luminance renders at 254 or more fall from up to 22.5 % to 0 at +1 EV and from up to 35 % to at most 0.03 % at +2 EV, apart from one sky that is mostly at the clip (#1632). Not compared with Lightroom's output | | LR-BEHAV-DRAGDROP | Drag and drop | P1 | ✅ | `crates/ui-egui/src/lib.rs`, `crates/ui-egui/src/panels/grid.rs` (`drag_feedback`), `crates/ui-egui/src/panels/left.rs` (`drop_target`, `album_drag_over`, `top_level_drop_target`, `drag_auto_scroll`), `crates/ui-egui/src/destination.rs`, `crates/ui-egui/src/widgets.rs` (`context_menu`), `crates/ui-egui/src/widgets/text_field.rs`, `crates/ui-egui/src/tests/carried_right_click.rs`, `crates/ui-egui/src/tests/carried_text_field_menu.rs` | a right-click while photos are carried opens no context menu (every menu opened through `widgets::context_menu`: sidebar rows, grid cells, lists; a text field's own Cut / Copy / Paste menu too); files → app (a drop-target card while they hover, then the import review); grid photos → an album row (adds the selection, with a count badge while dragging); sidebar album / folder rows → a folder (moves it; its name follows the pointer); a drag of albums or grid photos near the top or bottom edge of the sidebar scrolls it (faster nearer the edge, only while the pointer is over the sidebar); when another folder has the same name, the dragged label, the Move question and the toast name the folder it is in (`home (/a)`); an album drop's toast does the same for an album of that name in another album folder (two in the same place have nothing to tell them apart and keep the plain name); only the primary button drags photos and drops them: a right-button drag over a grid cell neither picks photos up nor changes the selection, and a right-button release while photos are dragged neither drops them nor ends the drag | | LR-BEHAV-TOAST | Toast notifications | P1 | ✅ | `crates/ui-egui/src/panels.rs` | | | LR-BEHAV-DIALOGS | Dialogs fit the window | P1 | ✅ | `crates/ui-egui/src/dialogs.rs` (`dialog_body`, `list_height`), `crates/ui-egui/src/tests/dialog_fit.rs`, `crates/ui-egui/src/tests/dialog_copy.rs`, `crates/ui-egui/src/tests/dialogs.rs` (`a_click_outside_closes_the_dialog_when_settings_allow_it`) | a dialog taller than the window (Export on a 1366×768 screen, issue #781) never runs off it: its options scroll while the title bar and the Cancel / confirm row stay on screen (the confirm button names its action: Create, Rename, Create Stacks, Export 3 Photos…, with "OK" kept only for a one-field prompt opened with a command that has no verb, `crates/ui-egui/src/tests/dialog_copy.rs`); lists that scroll on their own (What's New, All Metadata, shortcuts, smart-album rules, credits) get shorter first; dialogs that fit look as before; Import keeps its own resizable, scrolling window; Settings → Dialogs → Close a dialog by clicking outside it (off by default, so a stray click never throws away a dialog's choices): a click pressed and released on the dimmed backdrop closes the dialog like Esc and doesn't reach the panels below, while a drag that ends outside (a slider pulled past the edge) or a click that closes a dropdown keeps it; the import review never closes this way (`clicked_backdrop`); a one-line prompt (Rename Folder, New Folder on Disk, the preset and version names, New Library when its name can't be used, Auto-Tag from Tracklog) the engine refuses stays open with its text and shows the reason in a toast, so the name can be corrected, where it used to close without a word; a New Folder on Disk that works says so (“Created folder “Selects” in “2026/Shoot””, naming the parent by its last two folders as dialogs do) | diff --git a/docs/process-versions.md b/docs/process-versions.md index efc87d030ce..64af9269227 100644 --- a/docs/process-versions.md +++ b/docs/process-versions.md @@ -17,7 +17,7 @@ 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: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map and, with the parametric curve, comes from measured tables (Whites reaches into the midtones; the regions are broad and add); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V8 keep Whites in the tone map and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the tables. Renders with Whites, the parametric curve and the point curves neutral are V8's. | +| **V9** (the latest) | V8 plus: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map and, with the parametric curve, comes from measured tables (Whites reaches into the midtones; the regions are broad and add); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V8 keep Whites in the tone map and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the tables. With Whites, the parametric curve and the point curves neutral the curve stage does not run. | ## The rule diff --git a/tools/requirements-lr-tone-charts.txt b/tools/requirements-lr-tone-charts.txt index c91f37d19e9..290206bba41 100644 --- a/tools/requirements-lr-tone-charts.txt +++ b/tools/requirements-lr-tone-charts.txt @@ -1,4 +1,5 @@ # Python packages for tools/lr_tone_charts.py (crates/pipeline/src/curve_stage_tables.rs, docs/curve-stage.md). +# Needs Python 3.12 or newer (numpy 2.5); use a matching interpreter, e.g. python3.12 -m venv. # python3 -m venv .venv-lr-tone && .venv-lr-tone/bin/pip install -r tools/requirements-lr-tone-charts.txt numpy==2.5.4 tifffile==2026.11.8 From 51544671dc8f1e901db129183772578a85fe7d50 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Wed, 11 Nov 2026 10:06:36 +0100 Subject: [PATCH 05/20] LR-BEHAV-RENDER-FIDELITY: review fixes: measured curve tables only at default splits, python3.12 setup command (#523) --- docs/parity-checklist.md | 2 +- docs/process-versions.md | 2 +- tools/requirements-lr-tone-charts.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index ff73818452b..f80837830c1 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -467,7 +467,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-BEHAV-OFFLINE | Offline editing | P1 | ✅ | | local-first: everything works offline | | LR-BEHAV-WEB-SAFETY | Library safety in the browser build | P1 | 🟡 | `cmd:file.backupLibrary`, `cmd:file.restoreLibrary`, `apps/lightcraft-web/src/safety.rs`, `apps/lightcraft-web/src/backup.rs`, `apps/lightcraft-web/src/files.rs` | web only (experimental): Back Up Library (zip of the catalog and every stored original) and a non-destructive Restore; failed saves show as unsaved and are retried; a photo that can't be stored isn't added; one tab per library (Web Locks); notices for storage that isn't persistent and for a library that can't open; `?reset` asks first; a panic shows a message. Missing: `?safe` start, deleting originals of removed photos, zip64 (backups > 4 GB) | | LR-BEHAV-GPU | GPU acceleration | P0 | ✅ | `crates/gpu/src/render.rs`, `cmd:app.gpu`, `docs/gpu-pipeline.md`, `crates/ui-egui/src/panels/notices.rs` | CPU fallback per render on device limits, out of memory, device errors / loss, incomplete or black results (`perf.gpuReason`, `perf.gpuFallback`; each render reports its own reason — `lightcraft_gpu::try_render`, `gpuFallback` per exported file — issue #675); short submissions for slow iGPUs; backend choice (DX12 only on Windows, `LIGHTCRAFT_GPU_BACKEND` / `WGPU_BACKEND`), device created after the window opens, crash sentinel (issue #136); a GPU lost while LightCraft runs (driver reset) stops it with that message and turns GPU rendering off for the next start, which says why (issue #1337; the window's renderer can't survive the lost device); quitting waits (up to 2 s) for renders in flight and starts no new GPU work, so none is inside the driver when the process exits (`crates/gpu/src/exit.rs`, issue #620; seen crashing only on Linux + NVIDIA, other drivers unverified); with GPU rendering on and no adapter found at all (e.g. no Vulkan loader on NixOS outside `nix develop`), the desktop app says once per session that it renders on the CPU and points to Help ▸ System Info (`gpu_notice`; not when the GPU is turned off or only a software adapter exists); no tiling beyond the buffer limit (CPU) | -| LR-BEHAV-RENDER-FIDELITY | Rendering matches Lightroom | P1 | 🟡 | `crates/pipeline/src/lib.rs`, `crates/pipeline/src/tone.rs` | Process V4 calibrates global camera-look Contrast and Blacks against black-box Lightroom exports of Sony ILCE-7CR photos. Held-out response errors are 0.038 and 0.077 stops; V1/V2 keep their rendering. Up to V8 Whites retains V2. Exposure, Highlights/Shadows, other operators and broader camera coverage remain open (`docs/light-v3.md`). From process V9 Whites, the parametric curve and the point curves follow Camera Raw's measured response on synthetic grey steps, the master curve hue-preserving ([curve-stage.md](curve-stage.md)). From process V5 a raw's tone curve rolls off into white in stops (past a camera curve's last fitted knot, or from half a stop below the generic curve's white point instead of clipping), so Exposure +1 and +2 keep the highlights the sensor recorded: on 12 CC0 corpus raws and 6 CC0 DNGs on the generic curve, unclipped pixels whose luminance renders at 254 or more fall from up to 22.5 % to 0 at +1 EV and from up to 35 % to at most 0.03 % at +2 EV, apart from one sky that is mostly at the clip (#1632). Not compared with Lightroom's output | +| LR-BEHAV-RENDER-FIDELITY | Rendering matches Lightroom | P1 | 🟡 | `crates/pipeline/src/lib.rs`, `crates/pipeline/src/tone.rs` | Process V4 calibrates global camera-look Contrast and Blacks against black-box Lightroom exports of Sony ILCE-7CR photos. Held-out response errors are 0.038 and 0.077 stops; V1/V2 keep their rendering. Up to V8 Whites retains V2. Exposure, Highlights/Shadows, other operators and broader camera coverage remain open (`docs/light-v3.md`). From process V9 Whites, the parametric curve (at the default splits; moved splits keep the analytic model) and the point curves follow Camera Raw's measured response on synthetic grey steps, the master curve hue-preserving ([curve-stage.md](curve-stage.md)). From process V5 a raw's tone curve rolls off into white in stops (past a camera curve's last fitted knot, or from half a stop below the generic curve's white point instead of clipping), so Exposure +1 and +2 keep the highlights the sensor recorded: on 12 CC0 corpus raws and 6 CC0 DNGs on the generic curve, unclipped pixels whose luminance renders at 254 or more fall from up to 22.5 % to 0 at +1 EV and from up to 35 % to at most 0.03 % at +2 EV, apart from one sky that is mostly at the clip (#1632). Not compared with Lightroom's output | | LR-BEHAV-DRAGDROP | Drag and drop | P1 | ✅ | `crates/ui-egui/src/lib.rs`, `crates/ui-egui/src/panels/grid.rs` (`drag_feedback`), `crates/ui-egui/src/panels/left.rs` (`drop_target`, `album_drag_over`, `top_level_drop_target`, `drag_auto_scroll`), `crates/ui-egui/src/destination.rs`, `crates/ui-egui/src/widgets.rs` (`context_menu`), `crates/ui-egui/src/widgets/text_field.rs`, `crates/ui-egui/src/tests/carried_right_click.rs`, `crates/ui-egui/src/tests/carried_text_field_menu.rs` | a right-click while photos are carried opens no context menu (every menu opened through `widgets::context_menu`: sidebar rows, grid cells, lists; a text field's own Cut / Copy / Paste menu too); files → app (a drop-target card while they hover, then the import review); grid photos → an album row (adds the selection, with a count badge while dragging); sidebar album / folder rows → a folder (moves it; its name follows the pointer); a drag of albums or grid photos near the top or bottom edge of the sidebar scrolls it (faster nearer the edge, only while the pointer is over the sidebar); when another folder has the same name, the dragged label, the Move question and the toast name the folder it is in (`home (/a)`); an album drop's toast does the same for an album of that name in another album folder (two in the same place have nothing to tell them apart and keep the plain name); only the primary button drags photos and drops them: a right-button drag over a grid cell neither picks photos up nor changes the selection, and a right-button release while photos are dragged neither drops them nor ends the drag | | LR-BEHAV-TOAST | Toast notifications | P1 | ✅ | `crates/ui-egui/src/panels.rs` | | | LR-BEHAV-DIALOGS | Dialogs fit the window | P1 | ✅ | `crates/ui-egui/src/dialogs.rs` (`dialog_body`, `list_height`), `crates/ui-egui/src/tests/dialog_fit.rs`, `crates/ui-egui/src/tests/dialog_copy.rs`, `crates/ui-egui/src/tests/dialogs.rs` (`a_click_outside_closes_the_dialog_when_settings_allow_it`) | a dialog taller than the window (Export on a 1366×768 screen, issue #781) never runs off it: its options scroll while the title bar and the Cancel / confirm row stay on screen (the confirm button names its action: Create, Rename, Create Stacks, Export 3 Photos…, with "OK" kept only for a one-field prompt opened with a command that has no verb, `crates/ui-egui/src/tests/dialog_copy.rs`); lists that scroll on their own (What's New, All Metadata, shortcuts, smart-album rules, credits) get shorter first; dialogs that fit look as before; Import keeps its own resizable, scrolling window; Settings → Dialogs → Close a dialog by clicking outside it (off by default, so a stray click never throws away a dialog's choices): a click pressed and released on the dimmed backdrop closes the dialog like Esc and doesn't reach the panels below, while a drag that ends outside (a slider pulled past the edge) or a click that closes a dropdown keeps it; the import review never closes this way (`clicked_backdrop`); a one-line prompt (Rename Folder, New Folder on Disk, the preset and version names, New Library when its name can't be used, Auto-Tag from Tracklog) the engine refuses stays open with its text and shows the reason in a toast, so the name can be corrected, where it used to close without a word; a New Folder on Disk that works says so (“Created folder “Selects” in “2026/Shoot””, naming the parent by its last two folders as dialogs do) | diff --git a/docs/process-versions.md b/docs/process-versions.md index 64af9269227..3993fd7be04 100644 --- a/docs/process-versions.md +++ b/docs/process-versions.md @@ -17,7 +17,7 @@ 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: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map and, with the parametric curve, comes from measured tables (Whites reaches into the midtones; the regions are broad and add); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V8 keep Whites in the tone map and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the tables. With Whites, the parametric curve and the point curves neutral the curve stage does not run. | +| **V9** (the latest) | V8 plus: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map and, with the parametric curve at Lightroom's default splits, comes from measured tables (Whites reaches into the midtones; the regions are broad and add; moved splits keep the analytic model of V1 to V8); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V8 keep Whites in the tone map and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the tables. With Whites, the parametric curve and the point curves neutral the curve stage does not run. | ## The rule diff --git a/tools/requirements-lr-tone-charts.txt b/tools/requirements-lr-tone-charts.txt index 290206bba41..3763d03c1d7 100644 --- a/tools/requirements-lr-tone-charts.txt +++ b/tools/requirements-lr-tone-charts.txt @@ -1,5 +1,5 @@ # Python packages for tools/lr_tone_charts.py (crates/pipeline/src/curve_stage_tables.rs, docs/curve-stage.md). # Needs Python 3.12 or newer (numpy 2.5); use a matching interpreter, e.g. python3.12 -m venv. -# python3 -m venv .venv-lr-tone && .venv-lr-tone/bin/pip install -r tools/requirements-lr-tone-charts.txt +# python3.12 -m venv .venv-lr-tone && .venv-lr-tone/bin/pip install -r tools/requirements-lr-tone-charts.txt numpy==2.5.4 tifffile==2026.11.8 From b1f6a6677c9fc935ecaee913fa371f59c87beb72 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Wed, 11 Nov 2026 15:33:01 +0100 Subject: [PATCH 06/20] LR-EDIT-LIGHT-CURVE-PARAM: the parametric graph draws and drags the curve the photo renders, measured under process V9 (#523) --- crates/pipeline/src/curve.rs | 5 +- crates/pipeline/src/curve_stage.rs | 150 ++++++++++++++++++++++-- crates/pipeline/src/lib.rs | 1 + crates/ui-egui/src/panels/edit.rs | 2 +- crates/ui-egui/src/panels/edit/curve.rs | 20 ++-- crates/ui-egui/src/tests/curve.rs | 43 ++++--- docs/curve-stage.md | 11 +- docs/parity-checklist.md | 3 +- 8 files changed, 192 insertions(+), 43 deletions(-) diff --git a/crates/pipeline/src/curve.rs b/crates/pipeline/src/curve.rs index b2c2b0b1410..f9449a6d454 100644 --- a/crates/pipeline/src/curve.rs +++ b/crates/pipeline/src/curve.rs @@ -16,8 +16,9 @@ pub const PARAM_LUT: usize = 1024; /// The parametric (region) curve of a [`ToneCurve`]: the four region amounts, each a cosine bump /// over its window between two splits, summed and then forced monotone. /// -/// This is the renderer's curve, not an approximation of it — both `curve_luts` in the pipeline -/// and the curve editor in the UI use this struct so they can never disagree. +/// This is the renderer's curve, not an approximation of it: processes V1 to V8 render it, and V9 +/// renders it when the splits are moved. The curve editor draws it through +/// [`crate::curve_stage::ParametricGraph`], which picks the measured regions where V9 renders those. #[derive(Clone, Debug)] pub struct ParametricCurve { /// The curve, sampled and already forced monotone. diff --git a/crates/pipeline/src/curve_stage.rs b/crates/pipeline/src/curve_stage.rs index 954e0900aad..a427054c66b 100644 --- a/crates/pipeline/src/curve_stage.rs +++ b/crates/pipeline/src/curve_stage.rs @@ -19,6 +19,7 @@ use lightcraft_color::transfer::{linear_to_srgb, srgb_to_linear}; use lightcraft_develop::{DevelopSettings, Process, ToneCurve}; use lightcraft_geom::Point; +use crate::curve::ParametricCurve; use crate::curve_stage_tables as t; use crate::light_v3::PRO_Y; @@ -74,19 +75,106 @@ fn measured_delta(amounts: &[f32; K], tables: &[[f32; 257]; K], 0.0 } +/// Whether `c` holds Lightroom's default splits, the ones the region tables are measured with. +fn default_splits(c: &ToneCurve) -> bool { + [c.split_shadows, c.split_mid, c.split_highlights].iter().zip(DEFAULT_SPLITS).all(|(s, d)| (s - d).abs() <= 1e-6) +} + +/// The measured regions at `x`, before the curve is kept monotone: the four deltas added to the diagonal. +fn regions_at(amounts: [f32; 4], x: f32) -> f32 { + let d: f32 = amounts.iter().zip(t::REGIONS.iter()).map(|(a, r)| measured_delta(&t::REGION_AMOUNTS, r, *a, x)).sum(); + (x + d).clamp(0.0, 1.0) +} + +/// The measured parametric curve at the default splits. +fn measured_parametric(amounts: [f32; 4]) -> Lut1 { + let mut lut = Lut1::from_fn(N, |x| regions_at(amounts, x)); + monotone(&mut lut); + lut +} + /// The parametric curve: the measured regions at the default splits, else the analytic model of earlier processes. fn parametric(c: &ToneCurve) -> Lut1 { - let splits = [c.split_shadows, c.split_mid, c.split_highlights]; - if splits.iter().zip(DEFAULT_SPLITS).any(|(s, d)| (s - d).abs() > 1e-6) { - return crate::curve::ParametricCurve::new(c).to_lut(); + if !default_splits(c) { + return ParametricCurve::new(c).to_lut(); + } + measured_parametric([c.shadows, c.darks, c.lights, c.highlights].map(|v| v as f32)) +} + +/// The parametric curve as `s`'s process renders it, for the Edit panel's graph and its drag: the measured regions +/// under V9 at the default splits, else the analytic [`ParametricCurve`] (earlier processes, and V9 with moved +/// splits). Whites is left out, as Lightroom's graph leaves it out. +#[derive(Clone, Debug)] +pub struct ParametricGraph { + model: ParametricCurve, + /// The measured curve, when it is the one rendered. + measured: Option, +} + +impl ParametricGraph { + pub fn new(s: &DevelopSettings) -> ParametricGraph { + let model = ParametricCurve::new(&s.curve); + let measured = (s.process.process() >= Process::V9 && default_splits(&s.curve)).then(|| measured_parametric(model.amounts.map(|a| a as f32))); + ParametricGraph { model, measured } + } + + /// Whether the graph is the measured curve (else the analytic one). + pub fn is_measured(&self) -> bool { + self.measured.is_some() + } + + /// The curve at `x` (0 = black, 1 = white). + pub fn at(&self, x: f64) -> f64 { + match &self.measured { + Some(lut) => lut.eval(if x.is_nan() { 0.0 } else { x as f32 }) as f64, + None => self.model.at(x), + } + } + + /// The region that owns graph position `x` (the splits tile the graph: [`ParametricCurve::region_at`]). + pub fn region_at(&self, x: f64) -> usize { + self.model.region_at(x) + } + + /// Region `region`'s slider amount. + pub fn amount(&self, region: usize) -> f64 { + self.model.amounts.get(region).copied().unwrap_or(0.0) + } + + /// The amount for region `region` after a drag that grabbed the curve at `x`, with the region at `from`, and moved + /// it `delta` in output level (a fraction of the graph's height; up is positive). The other regions stay as they + /// are. A level the region cannot reach saturates at ±100; no motion keeps `from`. + pub fn dragged_amount(&self, region: usize, x: f64, from: f64, delta: f64) -> f64 { + if delta == 0.0 || !delta.is_finite() { + return from; + } + if self.measured.is_none() { + let per_unit = self.model.level_per_unit(region, x); + return if per_unit.abs() > f64::EPSILON { (from + delta / per_unit).clamp(-100.0, 100.0).round() } else { from }; + } + // the measured regions are tables, not linear in the amount: search the amount whose level is the target, + // on the side of `from` the drag goes to (so a flat stretch never makes the slider jump back) + let x = x.clamp(0.0, 1.0) as f32; + let level = |a: f64| { + let mut amounts = self.model.amounts.map(|v| v as f32); + if let Some(v) = amounts.get_mut(region) { + *v = a as f32; + } + regions_at(amounts, x) as f64 + }; + let target = level(from) + delta; + let (mut lo, mut hi) = if delta > 0.0 { (from, 100.0) } else { (-100.0, from) }; + for _ in 0..40 { + let mid = (lo + hi) / 2.0; + if level(mid) < target { + lo = mid; + } else { + hi = mid; + } + } + let a = if delta > 0.0 { hi } else { lo }; + a.clamp(-100.0, 100.0).round() } - let amounts = [c.shadows, c.darks, c.lights, c.highlights].map(|v| v as f32); - let mut lut = Lut1::from_fn(N, |x| { - let d: f32 = amounts.iter().zip(t::REGIONS.iter()).map(|(a, r)| measured_delta(&t::REGION_AMOUNTS, r, *a, x)).sum(); - (x + d).clamp(0.0, 1.0) - }); - monotone(&mut lut); - lut } /// The measured Whites curve at `amount`, or `None` at 0. @@ -262,6 +350,48 @@ mod tests { assert_eq!(stage.base.v, crate::curve::ParametricCurve::new(&s.curve).to_lut().v); } + #[test] + fn the_graph_is_the_curve_the_stage_renders() { + let mut s = v9(); + (s.curve.shadows, s.curve.darks, s.curve.lights, s.curve.highlights) = (40.0, -30.0, 25.0, -60.0); + let graph = ParametricGraph::new(&s); + assert!(graph.is_measured()); + let stage = CurveStage::new(&s).expect("regions set"); + for i in 0..=64 { + let x = i as f32 / 64.0; + assert!((graph.at(x as f64) as f32 - stage.base.eval(x)).abs() < 1e-6, "{x}"); + } + // moved splits and earlier processes draw the analytic curve, as they render it + s.curve.split_mid = 40.0; + let moved = ParametricGraph::new(&s); + assert!(!moved.is_measured()); + assert_eq!(moved.at(0.6), ParametricCurve::new(&s.curve).at(0.6)); + s.curve.split_mid = 50.0; + let v8 = DevelopSettings { process: Process::V8.version(), ..s }; + assert!(!ParametricGraph::new(&v8).is_measured()); + } + + #[test] + fn a_graph_drag_puts_the_measured_curve_where_the_hand_is() { + let mut s = v9(); + s.curve.darks = 30.0; + let graph = ParametricGraph::new(&s); + for (region, x) in [(0usize, 0.15f64), (1, 0.375), (2, 0.625), (3, 0.85)] { + for delta in [-0.04, 0.03] { + let from = graph.amount(region); + let a = graph.dragged_amount(region, x, from, delta); + let mut after = s.clone(); + let c = &mut after.curve; + *[&mut c.shadows, &mut c.darks, &mut c.lights, &mut c.highlights][region] = a; + let got = ParametricGraph::new(&after).at(x) - graph.at(x); + assert!((got - delta).abs() < 0.004, "region {region} at {x}: moved {got}, wanted {delta} (amount {from} → {a})"); + } + assert_eq!(graph.dragged_amount(region, x, graph.amount(region), 0.0), graph.amount(region), "no motion, no change"); + assert_eq!(graph.dragged_amount(region, x, 0.0, 1.0), 100.0, "out of reach saturates high"); + assert_eq!(graph.dragged_amount(region, x, 0.0, -1.0), -100.0, "and low"); + } + } + #[test] fn tone_order_never_reverses_and_every_table_fits_the_gpu() { for w in [-100.0, -50.0, 37.0, 100.0] { diff --git a/crates/pipeline/src/lib.rs b/crates/pipeline/src/lib.rs index 445e90b57e9..44426eed2d4 100644 --- a/crates/pipeline/src/lib.rs +++ b/crates/pipeline/src/lib.rs @@ -60,6 +60,7 @@ pub mod upright; pub mod visualize; pub use curve::{PARAM_AMOUNTS, PARAM_LUT, ParametricCurve}; +pub use curve_stage::ParametricGraph; pub use output::{DeepImage, DeepSamples, DisplaySpace, OutputDepth, OutputSpace, OutputTrc, Proof, ProofLut, proof_profile, register_proof_profile}; pub use visualize::{MaskView, Overlay}; diff --git a/crates/ui-egui/src/panels/edit.rs b/crates/ui-egui/src/panels/edit.rs index 195bcb6488c..9cc2a5c7a57 100644 --- a/crates/ui-egui/src/panels/edit.rs +++ b/crates/ui-egui/src/panels/edit.rs @@ -6,7 +6,7 @@ use egui::{Align2, Color32, Pos2, Rect, RichText, Sense, Stroke, pos2, vec2}; use lightcraft_catalog::PhotoId; use lightcraft_develop::{ControlSpec, DevelopSettings, Section, Track, WbMode, controls}; use lightcraft_geom::Point; -use lightcraft_pipeline::{PARAM_AMOUNTS, ParametricCurve}; +use lightcraft_pipeline::{PARAM_AMOUNTS, ParametricGraph}; use lightcraft_raster::Histogram; use serde_json::{Value, json}; diff --git a/crates/ui-egui/src/panels/edit/curve.rs b/crates/ui-egui/src/panels/edit/curve.rs index 0eec3a5e447..a15c7b5960f 100644 --- a/crates/ui-egui/src/panels/edit/curve.rs +++ b/crates/ui-egui/src/panels/edit/curve.rs @@ -1,7 +1,7 @@ use super::histogram::preview_histogram; use super::sliders::control; use super::{ - Align2, Color32, DevelopSettings, Icon, LightcraftApp, Mesh, PARAM_AMOUNTS, ParametricCurve, PhotoId, Point, Pos2, Rect, RichText, Sense, Stroke, + Align2, Color32, DevelopSettings, Icon, LightcraftApp, Mesh, PARAM_AMOUNTS, ParametricGraph, PhotoId, Point, Pos2, Rect, RichText, Sense, Stroke, Tokens, Vertex, controls, hex, json, paint, pos2, register, text_button, vec2, }; @@ -85,7 +85,7 @@ fn param_drag(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect, resp: &egui:: return; } let t = Tokens::get(ui.ctx()); - let model = ParametricCurve::new(&d.curve); + let model = ParametricGraph::new(d); let to_screen = |x: f64, y: f64| pos2(r.left() + x as f32 * r.width(), r.bottom() - y as f32 * r.height()); let from_screen_x = |q: Pos2| ((q.x - r.left()) / r.width()).clamp(0.0, 1.0) as f64; // the graph x of a point, and how far it is from the drawn curve (in screen points) @@ -110,7 +110,7 @@ fn param_drag(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect, resp: &egui:: let x = from_screen_x(q); let _ = app.run("develop.beginInteraction", json!({"label": "Parametric Curve"})); let region = model.region_at(x); - let initial_amount = model.amounts.get(region).copied().unwrap_or(0.0); + let initial_amount = model.amount(region); let start_pos = to_screen(x, model.at(x)); dragged = Some((region, x, initial_amount, start_pos.y)); ui.data_mut(|dd| dd.insert_temp(cursor_id, start_pos)); @@ -127,9 +127,7 @@ fn param_drag(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect, resp: &egui:: ui.data_mut(|d| d.insert_temp(cursor_id, cursor)); let delta_y = start_y - cursor.y; let delta_level = (delta_y / r.height()) as f64; - let per_unit = model.level_per_unit(region, x); - let new_amount = - if per_unit.abs() > f64::EPSILON { (initial_amount + delta_level / per_unit).clamp(-100.0, 100.0).round() } else { initial_amount }; + let new_amount = model.dragged_amount(region, x, initial_amount, delta_level); if let Some(&id) = PARAM_AMOUNTS.get(region) { set = Some((id, new_amount)); } @@ -238,11 +236,11 @@ pub(super) fn curve_editor(app: &mut LightcraftApp, ui: &mut egui::Ui, id: Photo let to_screen = |x: f64, y: f64| pos2(r.left() + x as f32 * r.width(), r.bottom() - y as f32 * r.height()); let from_screen = |q: Pos2| (((q.x - r.left()) / r.width()).clamp(0.0, 1.0) as f64, ((r.bottom() - q.y) / r.height()).clamp(0.0, 1.0) as f64); if ch == "parametric" { - // The Effective curve: the model the renderer builds from the four region sliders, sampled - // here and rebuilt every frame. The graph holds no state of its own, so a slider moved by - // hand, a Reset or an Undo redraws it from the settings in the same frame it changes. - let c = &d.curve; - let model = ParametricCurve::new(c); + // The Effective curve: the one the renderer builds from the four region sliders for this + // process (the measured regions under V9 at the default splits), sampled here and rebuilt every + // frame. The graph holds no state of its own, so a slider moved by hand, a Reset or an Undo + // redraws it from the settings in the same frame it changes. + let model = ParametricGraph::new(d); let pts: Vec = (0..=CURVE_SAMPLES).map(|i| to_screen(i as f64 / CURVE_SAMPLES as f64, model.at(i as f64 / CURVE_SAMPLES as f64))).collect(); p.add(egui::Shape::line(pts, Stroke::new(2.0, Color32::from_gray(220)))); diff --git a/crates/ui-egui/src/tests/curve.rs b/crates/ui-egui/src/tests/curve.rs index a658ee9a829..f3618611460 100644 --- a/crates/ui-egui/src/tests/curve.rs +++ b/crates/ui-egui/src/tests/curve.rs @@ -6,7 +6,7 @@ use serde_json::json; use crate::headless::Headless; use crate::{LightcraftApp, Services}; -use lightcraft_pipeline::ParametricCurve; +use lightcraft_pipeline::{ParametricCurve, ParametricGraph}; const T: Duration = Duration::from_secs(20); @@ -36,6 +36,11 @@ fn exec(h: &mut Headless, command: &str, params: serde_json::Value) -> serde_jso r["result"].clone() } +/// The parametric graph the panel draws for the selected photo's settings (its process decides measured or analytic). +fn graph(h: &Headless) -> ParametricGraph { + ParametricGraph::new(&develop(h)) +} + fn develop(h: &Headless) -> lightcraft_develop::DevelopSettings { let id = h.app.session.active().expect("active photo"); (*h.app.session.develop_of(id).unwrap_or_default()).clone() @@ -272,9 +277,10 @@ fn the_parametric_graph_paints_the_model_the_renderer_uses() { h.step(); let settings = develop(&h).curve; assert_eq!(settings, c, "the sliders hold the folded shape"); - let graph = curve_graph_rect(&mut h); - let painted = painted_param_curve(&h, graph); - let model = ParametricCurve::new(&c); + let model = graph(&h); + let rect = curve_graph_rect(&mut h); + let painted = painted_param_curve(&h, rect); + assert!(model.is_measured(), "the demo photo is on the latest process, which renders the measured regions"); let mut checked = 0; for i in 0..=24 { let x = i as f64 / 24.0; @@ -397,8 +403,8 @@ fn one_graph_drag_that_moves_several_regions_is_one_undo_step() { } /// The screen point where a drag should grab the curve: graph fraction `fx`, on the line itself. -fn on_curve(r: [f32; 4], c: &lightcraft_develop::ToneCurve, fx: f32) -> [f32; 2] { - let y = ParametricCurve::new(c).at(fx as f64); +fn on_curve(r: [f32; 4], g: &ParametricGraph, fx: f32) -> [f32; 2] { + let y = g.at(fx as f64); [r[0] + fx * r[2], r[1] + (1.0 - y as f32) * r[3]] } @@ -411,9 +417,10 @@ fn dragging_the_curve_moves_the_region_slider() { h.step(); let r = curve_graph_rect(&mut h); let c = develop(&h).curve; + let g = graph(&h); let undo_before = h.app.session.undo.len(); // grab the line inside the Lights window (x = 0.625) and pull it down - let [x, y] = on_curve(r, &c, 0.625); + let [x, y] = on_curve(r, &g, 0.625); let d = h.request("ui.drag", json!({"x": x, "y": y, "toX": x, "toY": y + 0.08 * r[3], "steps": 8}), T); assert_eq!(d["ok"], true, "{d}"); h.step(); @@ -426,8 +433,12 @@ fn dragging_the_curve_moves_the_region_slider() { // the graph really is redrawn below where the line was let graph = curve_graph_rect(&mut h); let painted = painted_param_curve(&h, graph)(0.625); - let before_level = ParametricCurve::new(&c).at(0.625); + let before_level = g.at(0.625); assert!(painted < before_level - 0.02, "the painted line followed the drag down: {painted} vs before {before_level}"); + // and lands where the hand is: 0.08 lower, less the steps of the 8 that egui's drag threshold (6 points) swallows + let step = 0.08 * r[3] as f64 / 8.0; + let moved = 0.08 - (6.0 / step).floor() * step / r[3] as f64; + assert!((before_level - painted - moved).abs() < 0.006, "the line moved {} for a hand motion of {moved}", before_level - painted); // and Undo takes the whole gesture back to where it started exec(&mut h, "edit.undo", json!({})); assert_eq!(develop(&h).curve, c, "undo restores the value the drag started from"); @@ -445,7 +456,7 @@ fn a_horizontal_drag_with_zero_vertical_motion_changes_nothing() { assert_eq!(before.darks, 60.0); assert_eq!(before.lights, 0.0); let r = curve_graph_rect(&mut h); - let [x, y] = on_curve(r, &before, 0.51); + let [x, y] = on_curve(r, &graph(&h), 0.51); // Drag purely horizontally from x=0.51: dx = 20 px, dy = 0 let d = h.request("ui.drag", json!({"x": x, "y": y, "toX": x + 20.0, "toY": y, "steps": 6}), T); assert_eq!(d["ok"], true, "{d}"); @@ -461,16 +472,16 @@ fn a_horizontal_drag_with_zero_vertical_motion_changes_nothing() { fn dragging_the_curve_up_raises_the_region_slider() { let mut h = curve_open("parametric"); let r = curve_graph_rect(&mut h); - let c = develop(&h).curve; + let g = graph(&h); // x = 0.375 is inside the Darks window - let [x, y] = on_curve(r, &c, 0.375); + let [x, y] = on_curve(r, &g, 0.375); let d = h.request("ui.drag", json!({"x": x, "y": y, "toX": x, "toY": y - 0.08 * r[3], "steps": 8}), T); assert_eq!(d["ok"], true, "{d}"); h.step(); let after = develop(&h).curve; assert!(after.darks > 0.0, "the Darks slider follows the line up: {}", after.darks); assert_eq!((after.shadows, after.lights, after.highlights), (0.0, 0.0, 0.0), "the other regions stay put: {after:?}"); - assert!(ParametricCurve::new(&after).at(0.375) > ParametricCurve::new(&c).at(0.375), "the curve is drawn bent up at the Darks region"); + assert!(graph(&h).at(0.375) > g.at(0.375), "the curve is drawn bent up at the Darks region"); } /// Which region a drag moves is decided by where on the line it is grabbed: the same drag gesture @@ -482,9 +493,9 @@ fn the_region_dragged_is_the_one_under_the_pointer() { { let mut h = curve_open("parametric"); let r = curve_graph_rect(&mut h); - let c = develop(&h).curve; - assert_eq!(ParametricCurve::new(&c).region_at(fx as f64), region, "x = {fx} belongs to {control}"); - let [x, y] = on_curve(r, &c, fx); + let g = graph(&h); + assert_eq!(g.region_at(fx as f64), region, "x = {fx} belongs to {control}"); + let [x, y] = on_curve(r, &g, fx); let d = h.request("ui.drag", json!({"x": x, "y": y, "toX": x, "toY": y - 0.06 * r[3], "steps": 6}), T); assert_eq!(d["ok"], true, "{d}"); h.step(); @@ -531,7 +542,7 @@ fn hovering_the_line_names_the_region_it_would_move() { exec(&mut h, "develop.set", json!({"control": "curve.lights", "value": 60})); h.step(); let r = curve_graph_rect(&mut h); - let [x, y] = on_curve(r, &develop(&h).curve, 0.625); + let [x, y] = on_curve(r, &graph(&h), 0.625); let q = h.request("ui.move", json!({"x": x, "y": y}), T); assert_eq!(q["ok"], true, "{q}"); h.step(); diff --git a/docs/curve-stage.md b/docs/curve-stage.md index a79fe23fdc8..c6321f92d9e 100644 --- a/docs/curve-stage.md +++ b/docs/curve-stage.md @@ -42,6 +42,14 @@ The tone map no longer applies Whites under V9 (`finish::base_tone`), and the V8 (`FinishParams::curves` is `None`). With Whites, the parametric curve and the point curves all neutral, the curve stage does not run. +## The Edit panel's graph + +The parametric graph draws the curve the photo renders, from `curve_stage::ParametricGraph`: the measured regions +under V9 at the default splits, else the analytic model. Dragging the line moves the region under the pointer by +the amount that puts the drawn curve where the pointer is. The measured tables are not linear in the amount, so the +amount is searched for, on the side of the starting value the drag moves to. A level out of the region's reach +saturates at ±100. Whites is not part of the graph, as in Lightroom. + ## How it was measured `tools/lr_tone_charts.py charts OUT_DIR` writes linear DNG charts: 48 grey steps from 0.002 to 1 and OkLCh colour @@ -60,8 +68,6 @@ predicted from the grey-step curves under the hue-preserving rule in step 3. The ## Limits - The tables are measured with Lightroom's default splits. Moved splits use the earlier analytic model. -- The Edit panel's curve graph still draws the analytic parametric curve and drags against it. Under V9 at the - default splits the photo renders the measured regions, so the graph's shape can differ from the render's. - The point curves' shape between the points is LightCraft's spline, not measured. What is measured for them is how they apply: hue preserving, then the red, green and blue curves per channel. - Local (mask) Whites keeps the earlier processes' operator. @@ -72,3 +78,4 @@ predicted from the grey-step curves under the hue-preserving rule in step 3. The | Date | Change | Summary | |---|---|---| | 2026-11-10 | minor | Process V9: measured Whites and parametric curve, hue-preserving master curve | +| 2026-11-11 | minor | The Edit panel's parametric graph draws and drags the measured regions under V9 | diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index f80837830c1..133f39bc24d 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -185,7 +185,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | From process V2, the same base as Highlights: dark areas keep their local contrast when lifted (#632); from process V8, the gaps in dark lettering on a bright panel are not lifted into bright blocks. Alt/Option-drag shows shadow clipping (white, clipped channels in colour) | | LR-EDIT-LIGHT-WHITES | Whites | P0 | 🟡 | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | From process V9 Whites is measured against Camera Raw renders of synthetic grey steps and reaches into the midtones as Lightroom's does ([curve-stage.md](curve-stage.md)); not yet compared on photos per camera. V4 to V8 preserve V2 Whites for both signs; measured V2 check response error is 0.075 stops on the Sony test photos (`docs/light-v3.md`). Alt/Option-drag shows highlight clipping (black, clipped channels in colour) | | LR-EDIT-LIGHT-BLACKS | Blacks | P0 | 🟡 | `ctl:light.blacks`, `crates/pipeline/src/visualize.rs` | From process V4, global Blacks on the camera-look path uses a fitted per-channel/luminance mix. Check response error 0.424 to 0.077 stops on six held-out Sony photos; deepest tones still differ. Other sources and local adjustments retain V2 (`docs/light-v3.md`). Alt/Option-drag shows shadow clipping (white, clipped channels in colour) | -| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | from process V9 the regions are Camera Raw's measured response at the default splits, broad and additive ([curve-stage.md](curve-stage.md)); the graph draws the analytic model of V1 to V8, which under V9 at the default splits can differ from the measured regions the photo renders (follow-up); dragging the line moves the region under the pointer (one undo step) | +| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | from process V9 the regions are Camera Raw's measured response at the default splits, broad and additive ([curve-stage.md](curve-stage.md)); the graph draws the curve the photo renders (`ParametricGraph`: the measured regions under V9 at the default splits, else the analytic model); dragging the line moves the region under the pointer (one undo step) | | LR-EDIT-LIGHT-CURVE-POINT | Point curve | P0 | ✅ | `cmd:develop.curve`, `cmd:curve.reset`, `cmd:curve.presets`, `cmd:curve.applyPreset`, `cmd:curve.savePreset`, `cmd:curve.deletePreset`, `cmd:curve.importPresets`, `cmd:curve.exportPresets`, `cmd:file.importCurvePresets`, `cmd:file.exportCurvePresets`, `crates/engine/src/cmd/curves.rs`, `crates/ui-egui/src/panels/edit.rs` | click to add a point; drag a point in both axes (between its neighbours, input / output readout, one undo step per drag; ⌥-drag moves it a tenth as far for fine adjustment, issue #1363); drag empty space to add and drag; double-click removes; reset: double-click a channel selector (that channel), the Reset button under the graph (every curve incl. parametric) or right-click the graph (channel / all); Point Curve preset dropdown: own Linear / Medium Contrast / Strong Contrast, user presets (save the current point curves, delete by right-click; saved with the library), import / export as `.lccurve` JSON; from process V9 the master curve keeps hue as Lightroom's does (largest and smallest channel through the curve, the middle one in proportion), and the red, green and blue curves follow it per channel ([curve-stage.md](curve-stage.md)) | | LR-EDIT-LIGHT-CURVE-RGB | Per-channel curves | P0 | ✅ | `cmd:develop.curve` (`channel`) | | | LR-EDIT-LIGHT-CURVE-REFINESAT | Curve saturation compensation | P1 | ✅ | `ctl:curve.refineSaturation` | | @@ -1056,3 +1056,4 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | 2026-10-17 | minor | LR-EXP-DIALOG: built-in export presets for the issue #2104 delivery targets — Instagram Feed (1080 px, screen sharpening), Instagram Story / Reel (1920 px), Web / Portfolio (2048 px, copyright and creator metadata), Full Resolution Master (full size, Display P3, quality 95); LR-EXP-PREVIOUS drops its stale "no named export presets yet" note; status unchanged (✅) | | 2026-10-20 | patch | LR-EXP-DIALOG: the four built-in export presets are translated in all 17 catalogs (translations pending native-speaker review); Instagram Story / Reel states that it applies no crop to 9:16; status unchanged (✅) | | 2026-10-31 | patch | LRC-LIB-VISUALSEARCH: Find Similar Photos reads the photos on a worker thread under an activity row with ✕ instead of on the UI thread, where a large library left the window not responding (#3468). A stopped search leaves the view as it was and keeps what it read; a control request gets the same `{photos}` when the search ends. | +| 2026-11-11 | patch | LR-EDIT-LIGHT-CURVE-PARAM: the graph draws and drags the curve the photo renders, the measured regions under V9 at the default splits; status unchanged (✅) | From 0bbd0fcc6cd336cca012c8c664060bb64184133d Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Wed, 11 Nov 2026 17:17:31 +0100 Subject: [PATCH 07/20] LR-BEHAV-RENDER-FIDELITY: review fixes: the chart tool refuses renders that are not 16-bit Adobe RGB (1998) (#523) --- tools/lr_tone_charts.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tools/lr_tone_charts.py b/tools/lr_tone_charts.py index 0657b769e3e..5aaf67d17da 100644 --- a/tools/lr_tone_charts.py +++ b/tools/lr_tone_charts.py @@ -134,11 +134,31 @@ def srgb_encode(v): return np.where(v <= 0.0031308, v * 12.92, 1.055 * v ** (1 / 2.4) - 0.055) +ADOBE_RGB_NAME = "Adobe RGB (1998)" + + +def read_render(path): + """A Camera Raw render as RGB 0..1, after checking it is the 16-bit Adobe RGB (1998) TIFF the tables assume. + + Another export setting would still give plausible numbers, but wrong ones, so it is refused. + """ + import tifffile + with tifffile.TiffFile(path) as t: + page = t.pages[0] + icc = page.tags.get(34675) # InterColorProfile + profile = bytes(icc.value) if icc is not None else b"" + a = page.asarray() + if a.dtype != np.uint16 or a.ndim != 3 or a.shape[2] != 3: + raise SystemExit(f"{path}: expected a 16-bit RGB TIFF, got {a.dtype} {a.shape}") + # the profile's description: ASCII in ICC v2, UTF-16 in v4 + if not any(n in profile for n in (ADOBE_RGB_NAME.encode(), ADOBE_RGB_NAME.encode("utf-16-be"))): + raise SystemExit(f"{path}: expected an embedded {ADOBE_RGB_NAME} profile (export from Camera Raw in that colour space)") + return a.astype(np.float64) / 65535.0 + + def grey_levels(path, patches): """The grey steps of a Camera Raw render as sRGB-encoded linear ProPhoto values (the curve stage's domain).""" - import tifffile - a = tifffile.imread(path).astype(np.float64) - a /= 65535.0 if a.max() > 255 else 255.0 + a = read_render(path) out = [] for q in patches: if q["kind"] != "grey" or not q["ok"]: From 6f565fec203b9de86512c11701122767eb42a308 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Wed, 11 Nov 2026 17:23:27 +0100 Subject: [PATCH 08/20] LR-EDIT-LIGHT-CURVE-PARAM: review fixes: a graph drag searches the curve as drawn and leaves a region that cannot move it; the panel builds the graph once per frame (#523) --- crates/pipeline/src/curve_stage.rs | 82 +++++++++++++++++++++---- crates/ui-egui/src/panels/edit/curve.rs | 5 +- docs/curve-stage.md | 6 +- 3 files changed, 76 insertions(+), 17 deletions(-) diff --git a/crates/pipeline/src/curve_stage.rs b/crates/pipeline/src/curve_stage.rs index a427054c66b..21857197fbf 100644 --- a/crates/pipeline/src/curve_stage.rs +++ b/crates/pipeline/src/curve_stage.rs @@ -26,6 +26,9 @@ use crate::light_v3::PRO_Y; /// Entries per table (as the shipping curve tables). pub const N: usize = 1024; +/// The least a region must be able to move the drawn parametric curve for a drag to move its slider: half an 8-bit level. +const REACH_MIN: f64 = 0.5 / 255.0; + /// Lightroom's default parametric splits: the measured region tables hold for them only. const DEFAULT_SPLITS: [f64; 3] = [25.0, 50.0, 75.0]; @@ -82,8 +85,12 @@ fn default_splits(c: &ToneCurve) -> bool { /// The measured regions at `x`, before the curve is kept monotone: the four deltas added to the diagonal. fn regions_at(amounts: [f32; 4], x: f32) -> f32 { - let d: f32 = amounts.iter().zip(t::REGIONS.iter()).map(|(a, r)| measured_delta(&t::REGION_AMOUNTS, r, *a, x)).sum(); - (x + d).clamp(0.0, 1.0) + (x + regions_delta(amounts, x)).clamp(0.0, 1.0) +} + +/// The sum of the four measured region deltas at `x`. +fn regions_delta(amounts: [f32; 4], x: f32) -> f32 { + amounts.iter().zip(t::REGIONS.iter()).map(|(a, r)| measured_delta(&t::REGION_AMOUNTS, r, *a, x)).sum() } /// The measured parametric curve at the default splits. @@ -143,7 +150,8 @@ impl ParametricGraph { /// The amount for region `region` after a drag that grabbed the curve at `x`, with the region at `from`, and moved /// it `delta` in output level (a fraction of the graph's height; up is positive). The other regions stay as they - /// are. A level the region cannot reach saturates at ±100; no motion keeps `from`. + /// are, and the level is the drawn curve's (kept monotone). A level the region cannot reach saturates at ±100; no + /// motion, or a region that cannot visibly move the line in that direction, keeps `from`. pub fn dragged_amount(&self, region: usize, x: f64, from: f64, delta: f64) -> f64 { if delta == 0.0 || !delta.is_finite() { return from; @@ -152,19 +160,46 @@ impl ParametricGraph { let per_unit = self.model.level_per_unit(region, x); return if per_unit.abs() > f64::EPSILON { (from + delta / per_unit).clamp(-100.0, 100.0).round() } else { from }; } - // the measured regions are tables, not linear in the amount: search the amount whose level is the target, - // on the side of `from` the drag goes to (so a flat stretch never makes the slider jump back) - let x = x.clamp(0.0, 1.0) as f32; + // The measured regions are tables, not linear in the amount: search the amount that puts the drawn curve at the + // target, on the side of `from` the drag goes to (so a flat stretch never makes the slider jump back). The drawn + // curve is kept monotone, a running maximum, so its level at `x` reads the table entries up to `x`; the other + // regions' share of them is the same for every amount tried. + let Some(table) = t::REGIONS.get(region) else { return from }; + let pos = x.clamp(0.0, 1.0) as f32 * (N - 1) as f32; + let j = (pos as usize).min(N - 2); + let f = pos - j as f32; + let mut others = self.model.amounts.map(|v| v as f32); + if let Some(v) = others.get_mut(region) { + *v = 0.0; + } + let entries: Vec<(f32, f32)> = (0..=j + 1) + .map(|i| { + let g = i as f32 / (N - 1) as f32; + (g, regions_delta(others, g)) + }) + .collect(); let level = |a: f64| { - let mut amounts = self.model.amounts.map(|v| v as f32); - if let Some(v) = amounts.get_mut(region) { - *v = a as f32; + let (mut m, mut at) = (f32::NEG_INFINITY, [0.0f32; 2]); + for (i, (g, rest)) in entries.iter().enumerate() { + m = m.max((g + rest + measured_delta(&t::REGION_AMOUNTS, table, a as f32, *g)).clamp(0.0, 1.0)); + if let Some(v) = i.checked_sub(j).and_then(|k| at.get_mut(k)) { + *v = m; + } } - regions_at(amounts, x) as f64 + (at[0] + (at[1] - at[0]) * f) as f64 }; - let target = level(from) + delta; + let (start, end) = (level(from), if delta > 0.0 { 100.0 } else { -100.0 }); + let (target, reach) = (start + delta, level(end)); + // where the drawn line is held by a peak to its left, the region may hardly move it: then the slider stays + if (reach - start).abs() < REACH_MIN { + return from; + } + if (delta > 0.0 && reach < target) || (delta < 0.0 && reach > target) { + return end; + } let (mut lo, mut hi) = if delta > 0.0 { (from, 100.0) } else { (-100.0, from) }; - for _ in 0..40 { + // 20 halvings of the 200-wide range are well inside the rounding to whole amounts + for _ in 0..20 { let mid = (lo + hi) / 2.0; if level(mid) < target { lo = mid; @@ -392,6 +427,29 @@ mod tests { } } + #[test] + fn a_graph_drag_follows_the_drawn_curve_where_it_is_flattened() { + // Lights +100 and Highlights -100 fold the measured curve back above 0.75; the drawn curve is held flat there + let mut s = v9(); + (s.curve.shadows, s.curve.darks, s.curve.lights, s.curve.highlights) = (-50.0, 100.0, 100.0, -100.0); + let graph = ParametricGraph::new(&s); + let x = 0.86; + let raw = regions_at(graph.model.amounts.map(|v| v as f32), x as f32) as f64; + assert!(graph.at(x) - raw > 0.1, "the stretch is flattened, or this proves nothing: {} vs {raw}", graph.at(x)); + let drawn = |region: usize, a: f64| { + let mut after = s.clone(); + let c = &mut after.curve; + *[&mut c.shadows, &mut c.darks, &mut c.lights, &mut c.highlights][region] = a; + ParametricGraph::new(&after).at(x) + }; + // Lights lowers the peak that holds the line: the drawn line moves with the hand + let a = graph.dragged_amount(2, x, 100.0, -0.03); + assert!((drawn(2, a) - graph.at(x) + 0.03).abs() < 0.004, "Lights {a} moved the line {}", drawn(2, a) - graph.at(x)); + // Highlights hardly moves the held line at all, so its slider stays rather than running to the end + assert!(drawn(3, 100.0) - graph.at(x) < REACH_MIN, "Highlights cannot lift the held line"); + assert_eq!(graph.dragged_amount(3, x, -100.0, 0.03), -100.0); + } + #[test] fn tone_order_never_reverses_and_every_table_fits_the_gpu() { for w in [-100.0, -50.0, 37.0, 100.0] { diff --git a/crates/ui-egui/src/panels/edit/curve.rs b/crates/ui-egui/src/panels/edit/curve.rs index a15c7b5960f..159704927a7 100644 --- a/crates/ui-egui/src/panels/edit/curve.rs +++ b/crates/ui-egui/src/panels/edit/curve.rs @@ -80,12 +80,11 @@ const PARAM_GRAB: f32 = 14.0; /// The whole gesture runs inside one `develop` interaction, so it is one undo step (Ctrl+Z takes the /// gesture back, not the last frame of it), and every write goes through `develop.set`, so the /// slider, the curve and what is drawn are the same state rather than three things kept in step. -fn param_drag(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect, resp: &egui::Response, d: &DevelopSettings) { +fn param_drag(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect, resp: &egui::Response, d: &DevelopSettings, model: &ParametricGraph) { if r.width() <= 1.0 || r.height() <= 1.0 { return; } let t = Tokens::get(ui.ctx()); - let model = ParametricGraph::new(d); let to_screen = |x: f64, y: f64| pos2(r.left() + x as f32 * r.width(), r.bottom() - y as f32 * r.height()); let from_screen_x = |q: Pos2| ((q.x - r.left()) / r.width()).clamp(0.0, 1.0) as f64; // the graph x of a point, and how far it is from the drawn curve (in screen points) @@ -244,7 +243,7 @@ pub(super) fn curve_editor(app: &mut LightcraftApp, ui: &mut egui::Ui, id: Photo let pts: Vec = (0..=CURVE_SAMPLES).map(|i| to_screen(i as f64 / CURVE_SAMPLES as f64, model.at(i as f64 / CURVE_SAMPLES as f64))).collect(); p.add(egui::Shape::line(pts, Stroke::new(2.0, Color32::from_gray(220)))); - param_drag(app, ui, r, &resp, d); + param_drag(app, ui, r, &resp, d, &model); curve_footer(app, ui, d); for &c in PARAM_AMOUNTS.iter().rev() { control(app, ui, d, c, true); diff --git a/docs/curve-stage.md b/docs/curve-stage.md index c6321f92d9e..2fe3bde85eb 100644 --- a/docs/curve-stage.md +++ b/docs/curve-stage.md @@ -47,8 +47,10 @@ stage does not run. The parametric graph draws the curve the photo renders, from `curve_stage::ParametricGraph`: the measured regions under V9 at the default splits, else the analytic model. Dragging the line moves the region under the pointer by the amount that puts the drawn curve where the pointer is. The measured tables are not linear in the amount, so the -amount is searched for, on the side of the starting value the drag moves to. A level out of the region's reach -saturates at ±100. Whites is not part of the graph, as in Lightroom. +amount is searched for, on the side of the starting value the drag moves to, on the curve as drawn (kept monotone, so +where opposite regions fold it back the line is held flat by the peak to its left). A level out of the region's reach +saturates at ±100. A region that cannot move the line by half an 8-bit level in that direction keeps its value. +Whites is not part of the graph, as in Lightroom. ## How it was measured From a8b4d7efaef55186c0a3fda0df1f27ad2819ceb2 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Wed, 11 Nov 2026 17:24:19 +0100 Subject: [PATCH 09/20] LR-BEHAV-RENDER-FIDELITY: review fixes: the measured tables are read without allocating per sample (#523) --- crates/pipeline/src/curve_stage.rs | 74 ++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/crates/pipeline/src/curve_stage.rs b/crates/pipeline/src/curve_stage.rs index 954e0900aad..2f7bab330d2 100644 --- a/crates/pipeline/src/curve_stage.rs +++ b/crates/pipeline/src/curve_stage.rs @@ -49,26 +49,29 @@ fn table_at(v: &[f32; 257], x: f32) -> f32 { } } -/// The delta at `x` of a setting measured at `amounts` (sorted, without 0), linearly between the measured amounts -/// and towards 0 below the smallest; clamped to the measured range. +/// The delta at `x` of a setting measured at `amounts` (ascending, without 0), linearly between the measured amounts +/// and towards 0 below the smallest; clamped to the measured range. Runs per table sample, so it allocates nothing. fn measured_delta(amounts: &[f32; K], tables: &[[f32; 257]; K], amount: f32, x: f32) -> f32 { if amount == 0.0 || K == 0 { return 0.0; } - // the measured amounts with 0 between the negative and positive ones - let mut keys: Vec<(f32, Option<&[f32; 257]>)> = amounts.iter().zip(tables.iter()).map(|(a, v)| (*a, Some(v))).collect(); - keys.push((0.0, None)); - keys.sort_by(|a, b| a.0.total_cmp(&b.0)); - let (lo, hi) = (keys.first().map_or(0.0, |k| k.0), keys.last().map_or(0.0, |k| k.0)); + // the measured amounts with 0 (delta 0) between the negative and positive ones: key `i` of K + 1 + let zero = amounts.partition_point(|a| *a < 0.0); + let key = |i: usize| -> (f32, f32) { + let k = match i.cmp(&zero) { + std::cmp::Ordering::Less => i, + std::cmp::Ordering::Equal => return (0.0, 0.0), + std::cmp::Ordering::Greater => i - 1, + }; + (amounts.get(k).copied().unwrap_or(0.0), tables.get(k).map_or(0.0, |v| table_at(v, x))) + }; + let (lo, hi) = (key(0).0, key(K).0); let a = amount.clamp(lo, hi); - let at = |k: &(f32, Option<&[f32; 257]>)| k.1.map_or(0.0, |v| table_at(v, x)); - for w in keys.windows(2) { - if let [k0, k1] = w - && a >= k0.0 - && a <= k1.0 - { - let f = if k1.0 > k0.0 { (a - k0.0) / (k1.0 - k0.0) } else { 0.0 }; - return at(k0) * (1.0 - f) + at(k1) * f; + for i in 0..K { + let ((a0, v0), (a1, v1)) = (key(i), key(i + 1)); + if a >= a0 && a <= a1 { + let f = if a1 > a0 { (a - a0) / (a1 - a0) } else { 0.0 }; + return v0 * (1.0 - f) + v1 * f; } } 0.0 @@ -262,6 +265,47 @@ mod tests { assert_eq!(stage.base.v, crate::curve::ParametricCurve::new(&s.curve).to_lut().v); } + /// The earlier implementation, which built and sorted the keys per call. + fn measured_delta_sorted(amounts: &[f32; K], tables: &[[f32; 257]; K], amount: f32, x: f32) -> f32 { + if amount == 0.0 || K == 0 { + return 0.0; + } + // the measured amounts with 0 between the negative and positive ones + let mut keys: Vec<(f32, Option<&[f32; 257]>)> = amounts.iter().zip(tables.iter()).map(|(a, v)| (*a, Some(v))).collect(); + keys.push((0.0, None)); + keys.sort_by(|a, b| a.0.total_cmp(&b.0)); + let (lo, hi) = (keys.first().map_or(0.0, |k| k.0), keys.last().map_or(0.0, |k| k.0)); + let a = amount.clamp(lo, hi); + let at = |k: &(f32, Option<&[f32; 257]>)| k.1.map_or(0.0, |v| table_at(v, x)); + for w in keys.windows(2) { + if let [k0, k1] = w + && a >= k0.0 + && a <= k1.0 + { + let f = if k1.0 > k0.0 { (a - k0.0) / (k1.0 - k0.0) } else { 0.0 }; + return at(k0) * (1.0 - f) + at(k1) * f; + } + } + 0.0 + } + + #[test] + fn measured_delta_reads_the_tables_as_the_sorting_version_did() { + assert!(t::REGION_AMOUNTS.windows(2).all(|w| w[0] < w[1]) && t::WHITES_AMOUNTS.windows(2).all(|w| w[0] < w[1])); + for amount in [-150.0f32, -100.0, -80.0, -75.0, -30.0, -1.0, 0.0, 0.5, 12.0, 25.0, 60.0, 100.0, 140.0] { + for i in 0..=40 { + let x = i as f32 / 40.0; + for r in &t::REGIONS { + assert_eq!(measured_delta(&t::REGION_AMOUNTS, r, amount, x), measured_delta_sorted(&t::REGION_AMOUNTS, r, amount, x)); + } + assert_eq!( + measured_delta(&t::WHITES_AMOUNTS, &t::WHITES, amount, x), + measured_delta_sorted(&t::WHITES_AMOUNTS, &t::WHITES, amount, x) + ); + } + } + } + #[test] fn tone_order_never_reverses_and_every_table_fits_the_gpu() { for w in [-100.0, -50.0, 37.0, 100.0] { From 8bec5c5d4f40931384bad8d6f7ef8bae6ba1fae2 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Wed, 11 Nov 2026 18:35:08 +0100 Subject: [PATCH 10/20] LR-EDIT-LIGHT-CURVE-PARAM: review fixes: doc comments on the graph's constructor, the curve editor and the graph tests (#523) --- crates/pipeline/src/curve_stage.rs | 6 +++++- crates/ui-egui/src/panels/edit/curve.rs | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/pipeline/src/curve_stage.rs b/crates/pipeline/src/curve_stage.rs index bc9f16b5515..605532b3bfd 100644 --- a/crates/pipeline/src/curve_stage.rs +++ b/crates/pipeline/src/curve_stage.rs @@ -122,6 +122,7 @@ pub struct ParametricGraph { } impl ParametricGraph { + /// The graph for `s`: measured when `s`'s process is V9 or later and the splits are the defaults. pub fn new(s: &DevelopSettings) -> ParametricGraph { let model = ParametricCurve::new(&s.curve); let measured = (s.process.process() >= Process::V9 && default_splits(&s.curve)).then(|| measured_parametric(model.amounts.map(|a| a as f32))); @@ -429,6 +430,7 @@ mod tests { } } + /// What the graph draws is the stage's base curve, and the analytic one where the stage uses that. #[test] fn the_graph_is_the_curve_the_stage_renders() { let mut s = v9(); @@ -450,6 +452,7 @@ mod tests { assert!(!ParametricGraph::new(&v8).is_measured()); } + /// In every region, the amount a drag picks moves the drawn curve by the drag's motion. #[test] fn a_graph_drag_puts_the_measured_curve_where_the_hand_is() { let mut s = v9(); @@ -471,9 +474,10 @@ mod tests { } } + /// Where opposite regions fold the measured curve back, the drag follows the curve as drawn (held flat by the peak + /// to its left): Lights +100 and Highlights −100 fold it above 0.75. #[test] fn a_graph_drag_follows_the_drawn_curve_where_it_is_flattened() { - // Lights +100 and Highlights -100 fold the measured curve back above 0.75; the drawn curve is held flat there let mut s = v9(); (s.curve.shadows, s.curve.darks, s.curve.lights, s.curve.highlights) = (-50.0, 100.0, 100.0, -100.0); let graph = ParametricGraph::new(&s); diff --git a/crates/ui-egui/src/panels/edit/curve.rs b/crates/ui-egui/src/panels/edit/curve.rs index 159704927a7..a7ea96bc5c5 100644 --- a/crates/ui-egui/src/panels/edit/curve.rs +++ b/crates/ui-egui/src/panels/edit/curve.rs @@ -159,6 +159,8 @@ fn param_drag(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect, resp: &egui:: } } +/// The Tone Curve flyout: the channel row, the graph of the selected channel (the parametric curve, or a point curve +/// with its points) with its drag, the presets row and the sliders below. pub(super) fn curve_editor(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, d: &DevelopSettings) { let t = Tokens::get(ui.ctx()); // channel selector From 14909c49141bc8c4b569c87645417638620e06c3 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Wed, 18 Nov 2026 17:27:45 +0100 Subject: [PATCH 11/20] curve_stage: say in apply's doc that values above white are added back after the curves (review on #4076) --- crates/pipeline/src/curve_stage.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/pipeline/src/curve_stage.rs b/crates/pipeline/src/curve_stage.rs index 2f7bab330d2..cfc5e4c25a8 100644 --- a/crates/pipeline/src/curve_stage.rs +++ b/crates/pipeline/src/curve_stage.rs @@ -143,7 +143,11 @@ impl CurveStage { Some(CurveStage { chan, base, refine }) } - /// Linear Rec.2020 in and out (display referred, after the tone map). Values above white keep slope 1. + /// Linear Rec.2020 in and out (display referred, after the tone map). + /// + /// The curves are looked up on the colour clamped to [0, 1] in linear ProPhoto; whatever a channel had + /// above white is added back after them, so HDR input keeps slope 1 above white and is not clipped by an + /// active curve (`hdr_values_keep_slope_one_above_white`). pub fn apply(&self, d: [f32; 3]) -> [f32; 3] { let (to, from) = matrices(); let p = mul3(to, d); From 789c1a0467e962d15f3969834269bab02482dd9a Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Tue, 24 Nov 2026 08:18:38 +0100 Subject: [PATCH 12/20] LR-BEHAV-RENDER-FIDELITY: Whites and the parametric regions are a fitted model, not measured tables (#523) Review on #4076: the clean-room standard's Assets section rules out tables sampled from another app's output. `curve_stage_tables.rs` and the tool step that wrote it (`lr_tone_charts.py tables`) are gone. - `curve_stage_model.rs` holds only the model's 140 constants, written by `lr_tone_charts.py fit` from the same chart renders. Per slider direction, two smooth bumps whose gain, position and width change with the amount; the fit keeps every response growing with the amount. - Against the measured responses, as rendered: 0.05 to 0.52 8-bit levels RMS, 2.29 at most (table in docs/curve-stage.md). - Held-out photos, this branch's table build vs the model: tone 7.094 -> 7.079, colour 1.332 -> 1.327 (OkLab x 100). - Tests stay relational: responses grow with the slider and stay inside black and white, the regions peak in tone order; the folded-curve drag test uses settings where the held line sits below white. - Code comments and the release note describe the stage in our own words; provenance stays in docs/curve-stage.md and the tool. --- crates/develop/src/settings.rs | 7 +- crates/pipeline/src/curve_stage.rs | 223 ++++++++++------------ crates/pipeline/src/curve_stage_model.rs | 19 ++ crates/pipeline/src/curve_stage_tables.rs | 57 ------ crates/pipeline/src/finish.rs | 5 +- crates/pipeline/src/lib.rs | 2 +- crates/ui-egui/src/panels/edit/curve.rs | 2 +- crates/ui-egui/src/tests/curve.rs | 4 +- docs/curve-stage.md | 60 ++++-- docs/parity-checklist.md | 2 +- docs/process-versions.md | 2 +- docs/whats-new.md | 13 +- tools/lr_tone_charts.py | 116 ++++++++--- tools/requirements-lr-tone-charts.txt | 3 +- 14 files changed, 281 insertions(+), 234 deletions(-) create mode 100644 crates/pipeline/src/curve_stage_model.rs delete mode 100644 crates/pipeline/src/curve_stage_tables.rs diff --git a/crates/develop/src/settings.rs b/crates/develop/src/settings.rs index 941e6013a4e..6a2c3895fc8 100644 --- a/crates/develop/src/settings.rs +++ b/crates/develop/src/settings.rs @@ -102,9 +102,10 @@ pub enum Process { /// V7, with the Highlights/Shadows base taken of log luminance without its fine detail (clamped /// between a fine and a 3× wider median), so gaps in dark lettering aren't lifted into bright blocks. V8, - /// V8, with Whites and the parametric curve measured against Lightroom, and the tone curves applied as - /// Lightroom does: Whites, the parametric and point curve hue-preserving in linear ProPhoto RGB, then the - /// red, green and blue curves per channel, before the colour stage (`lightcraft_pipeline::curve_stage`). + /// V8, with Whites and the parametric curve from a fitted model, and the tone curves applied + /// hue-preserving: Whites, the parametric and point curve in linear ProPhoto RGB, then the red, green and + /// blue curves per channel, before the colour stage (`lightcraft_pipeline::curve_stage`, + /// `docs/curve-stage.md`). V9, } diff --git a/crates/pipeline/src/curve_stage.rs b/crates/pipeline/src/curve_stage.rs index 116a5e8b304..135ba3b3fe6 100644 --- a/crates/pipeline/src/curve_stage.rs +++ b/crates/pipeline/src/curve_stage.rs @@ -1,15 +1,14 @@ -//! Process V9's tone-curve stage ([`lightcraft_develop::Process::V9`], `docs/curve-stage.md`): Whites, the -//! parametric curve and the point curves, applied the way Lightroom applies them. +//! Process V9's tone-curve stage ([`lightcraft_develop::Process::V9`]): Whites, the parametric curve and the point +//! curves. `docs/curve-stage.md` records how the model was measured and fitted. //! -//! Measured on Camera Raw renders of synthetic charts (`tools/lr_tone_charts.py`): //! - Whites, the parametric curve, the master point curve, Contrast and Blacks act hue-preserving on linear ProPhoto //! RGB: the curve maps the largest and the smallest channel (on sRGB-encoded values), and the middle channel keeps -//! its relative position between them in linear light. Predicting coloured patches from the curve measured on -//! grey steps this way leaves 0.03 to 0.16 (OkLab × 100), against 0.3 to 3.4 for V8. +//! its relative position between them in linear light. //! - The red, green and blue curves act per channel on sRGB-encoded linear ProPhoto RGB, after the master curve. -//! - Whites and the four parametric regions are tables of Camera Raw's measured output (`curve_stage_tables`): -//! Whites reaches into the midtones (Whites −50 lowers encoded 0.6 by about 10/255), and each region is broad and -//! overlapping. The regions add: the sum of single regions reproduces three at once within 1/255. +//! - Whites reaches into the midtones, and each parametric region is broad and overlapping; the regions add. +//! - Whites and the four regions come from a fitted model (`curve_stage_model`, written by `tools/lr_tone_charts.py +//! fit`): per slider direction, two smooth bumps whose gain, position and width change with the amount +//! ([`response`]). //! //! The stage runs after the tone map and Process V4's calibrated Contrast and Blacks, before the colour stage. It //! replaces V8's curves on encoded output values; the tone map leaves Whites to it. @@ -20,7 +19,7 @@ use lightcraft_develop::{DevelopSettings, Process, ToneCurve}; use lightcraft_geom::Point; use crate::curve::ParametricCurve; -use crate::curve_stage_tables as t; +use crate::curve_stage_model as m; use crate::light_v3::PRO_Y; /// Entries per table (as the shipping curve tables). @@ -29,7 +28,7 @@ pub const N: usize = 1024; /// The least a region must be able to move the drawn parametric curve for a drag to move its slider: half an 8-bit level. const REACH_MIN: f64 = 0.5 / 255.0; -/// Lightroom's default parametric splits: the measured region tables hold for them only. +/// The default parametric splits (25, 50, 75): the fitted regions hold for them only. const DEFAULT_SPLITS: [f64; 3] = [25.0, 50.0, 75.0]; /// The stage's tables: `base` (Whites, then the parametric curve, then the master point curve) acts hue-preserving, @@ -42,101 +41,88 @@ pub struct CurveStage { pub refine: f32, } -/// A measured delta table (257 entries over 0..1) at `x`. -fn table_at(v: &[f32; 257], x: f32) -> f32 { - let p = x.clamp(0.0, 1.0) * 256.0; - let i = (p as usize).min(255); - let f = p - i as f32; - match (v.get(i), v.get(i + 1)) { - (Some(a), Some(b)) => a + (b - a) * f, - _ => 0.0, +/// A bump of peak 1 at `p / (p + q)`, 0 at black and white and outside them. +fn bump(x: f64, p: f64, q: f64) -> f64 { + if x <= 0.0 || x >= 1.0 { + return 0.0; } + let peak = p / (p + q); + (p * (x / peak).ln() + q * ((1.0 - x) / (1.0 - peak)).ln()).exp() } -/// The delta at `x` of a setting measured at `amounts` (ascending, without 0), linearly between the measured amounts -/// and towards 0 below the smallest; clamped to the measured range. Runs per table sample, so it allocates nothing. -fn measured_delta(amounts: &[f32; K], tables: &[[f32; 257]; K], amount: f32, x: f32) -> f32 { - if amount == 0.0 || K == 0 { +/// The fitted response of a slider at `amount` (−100 to 100, clamped) for input `x`: output minus input on +/// sRGB-encoded values. Per direction, two bumps with gain `a1 t + a2 t² + a3 t³` (t = |amount| / 100) and shape +/// exponents `e^(p0 + p1 t)`, `e^(q0 + q1 t)`. +fn response(fit: &[m::Response; 2], amount: f32, x: f32) -> f32 { + if amount == 0.0 || !amount.is_finite() { return 0.0; } - // the measured amounts with 0 (delta 0) between the negative and positive ones: key `i` of K + 1 - let zero = amounts.partition_point(|a| *a < 0.0); - let key = |i: usize| -> (f32, f32) { - let k = match i.cmp(&zero) { - std::cmp::Ordering::Less => i, - std::cmp::Ordering::Equal => return (0.0, 0.0), - std::cmp::Ordering::Greater => i - 1, - }; - (amounts.get(k).copied().unwrap_or(0.0), tables.get(k).map_or(0.0, |v| table_at(v, x))) - }; - let (lo, hi) = (key(0).0, key(K).0); - let a = amount.clamp(lo, hi); - for i in 0..K { - let ((a0, v0), (a1, v1)) = (key(i), key(i + 1)); - if a >= a0 && a <= a1 { - let f = if a1 > a0 { (a - a0) / (a1 - a0) } else { 0.0 }; - return v0 * (1.0 - f) + v1 * f; - } - } - 0.0 + let [negative, positive] = fit; + let side = if amount < 0.0 { negative } else { positive }; + let (t, x) = ((f64::from(amount) / 100.0).abs().min(1.0), f64::from(x)); + let r: f64 = side + .iter() + .map(|[a1, a2, a3, p0, p1, q0, q1]| (a1 * t + a2 * t * t + a3 * t * t * t) * bump(x, (p0 + p1 * t).exp(), (q0 + q1 * t).exp())) + .sum(); + r as f32 } -/// Whether `c` holds Lightroom's default splits, the ones the region tables are measured with. +/// Whether `c` holds the default splits, the ones the regions are fitted for. fn default_splits(c: &ToneCurve) -> bool { [c.split_shadows, c.split_mid, c.split_highlights].iter().zip(DEFAULT_SPLITS).all(|(s, d)| (s - d).abs() <= 1e-6) } -/// The measured regions at `x`, before the curve is kept monotone: the four deltas added to the diagonal. +/// The fitted regions at `x`, before the curve is kept monotone: the four responses added to the diagonal. fn regions_at(amounts: [f32; 4], x: f32) -> f32 { (x + regions_delta(amounts, x)).clamp(0.0, 1.0) } -/// The sum of the four measured region deltas at `x`. +/// The sum of the four fitted region responses at `x`. fn regions_delta(amounts: [f32; 4], x: f32) -> f32 { - amounts.iter().zip(t::REGIONS.iter()).map(|(a, r)| measured_delta(&t::REGION_AMOUNTS, r, *a, x)).sum() + amounts.iter().zip(m::REGIONS.iter()).map(|(a, r)| response(r, *a, x)).sum() } -/// The measured parametric curve at the default splits. -fn measured_parametric(amounts: [f32; 4]) -> Lut1 { +/// The fitted parametric curve at the default splits. +fn fitted_parametric(amounts: [f32; 4]) -> Lut1 { let mut lut = Lut1::from_fn(N, |x| regions_at(amounts, x)); monotone(&mut lut); lut } -/// The parametric curve: the measured regions at the default splits, else the analytic model of earlier processes. +/// The parametric curve: the fitted regions at the default splits, else the analytic model of earlier processes. fn parametric(c: &ToneCurve) -> Lut1 { if !default_splits(c) { return ParametricCurve::new(c).to_lut(); } - measured_parametric([c.shadows, c.darks, c.lights, c.highlights].map(|v| v as f32)) + fitted_parametric([c.shadows, c.darks, c.lights, c.highlights].map(|v| v as f32)) } -/// The parametric curve as `s`'s process renders it, for the Edit panel's graph and its drag: the measured regions +/// The parametric curve as `s`'s process renders it, for the Edit panel's graph and its drag: the fitted regions /// under V9 at the default splits, else the analytic [`ParametricCurve`] (earlier processes, and V9 with moved -/// splits). Whites is left out, as Lightroom's graph leaves it out. +/// splits). Whites is left out of the graph. #[derive(Clone, Debug)] pub struct ParametricGraph { model: ParametricCurve, - /// The measured curve, when it is the one rendered. - measured: Option, + /// The fitted curve, when it is the one rendered. + fitted: Option, } impl ParametricGraph { - /// The graph for `s`: measured when `s`'s process is V9 or later and the splits are the defaults. + /// The graph for `s`: the fitted curve when `s`'s process is V9 or later and the splits are the defaults. pub fn new(s: &DevelopSettings) -> ParametricGraph { let model = ParametricCurve::new(&s.curve); - let measured = (s.process.process() >= Process::V9 && default_splits(&s.curve)).then(|| measured_parametric(model.amounts.map(|a| a as f32))); - ParametricGraph { model, measured } + let fitted = (s.process.process() >= Process::V9 && default_splits(&s.curve)).then(|| fitted_parametric(model.amounts.map(|a| a as f32))); + ParametricGraph { model, fitted } } - /// Whether the graph is the measured curve (else the analytic one). - pub fn is_measured(&self) -> bool { - self.measured.is_some() + /// Whether the graph is the fitted curve (else the analytic one). + pub fn is_fitted(&self) -> bool { + self.fitted.is_some() } /// The curve at `x` (0 = black, 1 = white). pub fn at(&self, x: f64) -> f64 { - match &self.measured { + match &self.fitted { Some(lut) => lut.eval(if x.is_nan() { 0.0 } else { x as f32 }) as f64, None => self.model.at(x), } @@ -160,15 +146,15 @@ impl ParametricGraph { if delta == 0.0 || !delta.is_finite() { return from; } - if self.measured.is_none() { + if self.fitted.is_none() { let per_unit = self.model.level_per_unit(region, x); return if per_unit.abs() > f64::EPSILON { (from + delta / per_unit).clamp(-100.0, 100.0).round() } else { from }; } - // The measured regions are tables, not linear in the amount: search the amount that puts the drawn curve at the - // target, on the side of `from` the drag goes to (so a flat stretch never makes the slider jump back). The drawn - // curve is kept monotone, a running maximum, so its level at `x` reads the table entries up to `x`; the other + // The fitted regions are not linear in the amount: search the amount that puts the drawn curve at the target, + // on the side of `from` the drag goes to (so a flat stretch never makes the slider jump back). The drawn curve + // is kept monotone, a running maximum, so its level at `x` reads the curve's entries up to `x`; the other // regions' share of them is the same for every amount tried. - let Some(table) = t::REGIONS.get(region) else { return from }; + let Some(fit) = m::REGIONS.get(region) else { return from }; let pos = x.clamp(0.0, 1.0) as f32 * (N - 1) as f32; let j = (pos as usize).min(N - 2); let f = pos - j as f32; @@ -185,7 +171,7 @@ impl ParametricGraph { let level = |a: f64| { let (mut m, mut at) = (f32::NEG_INFINITY, [0.0f32; 2]); for (i, (g, rest)) in entries.iter().enumerate() { - m = m.max((g + rest + measured_delta(&t::REGION_AMOUNTS, table, a as f32, *g)).clamp(0.0, 1.0)); + m = m.max((g + rest + response(fit, a as f32, *g)).clamp(0.0, 1.0)); if let Some(v) = i.checked_sub(j).and_then(|k| at.get_mut(k)) { *v = m; } @@ -216,12 +202,12 @@ impl ParametricGraph { } } -/// The measured Whites curve at `amount`, or `None` at 0. +/// The fitted Whites curve at `amount`, or `None` at 0. fn whites(amount: f64) -> Option { if amount == 0.0 { return None; } - let mut lut = Lut1::from_fn(N, |x| (x + measured_delta(&t::WHITES_AMOUNTS, &t::WHITES, amount as f32, x)).clamp(0.0, 1.0)); + let mut lut = Lut1::from_fn(N, |x| (x + response(&m::WHITES, amount as f32, x)).clamp(0.0, 1.0)); monotone(&mut lut); Some(lut) } @@ -393,45 +379,44 @@ mod tests { assert_eq!(stage.base.v, crate::curve::ParametricCurve::new(&s.curve).to_lut().v); } - /// The earlier implementation, which built and sorted the keys per call. - fn measured_delta_sorted(amounts: &[f32; K], tables: &[[f32; 257]; K], amount: f32, x: f32) -> f32 { - if amount == 0.0 || K == 0 { - return 0.0; - } - // the measured amounts with 0 between the negative and positive ones - let mut keys: Vec<(f32, Option<&[f32; 257]>)> = amounts.iter().zip(tables.iter()).map(|(a, v)| (*a, Some(v))).collect(); - keys.push((0.0, None)); - keys.sort_by(|a, b| a.0.total_cmp(&b.0)); - let (lo, hi) = (keys.first().map_or(0.0, |k| k.0), keys.last().map_or(0.0, |k| k.0)); - let a = amount.clamp(lo, hi); - let at = |k: &(f32, Option<&[f32; 257]>)| k.1.map_or(0.0, |v| table_at(v, x)); - for w in keys.windows(2) { - if let [k0, k1] = w - && a >= k0.0 - && a <= k1.0 - { - let f = if k1.0 > k0.0 { (a - k0.0) / (k1.0 - k0.0) } else { 0.0 }; - return at(k0) * (1.0 - f) + at(k1) * f; + /// Every fitted response grows with its slider in the slider's direction, never acts against it, and is 0 at black, + /// at white and at amount 0; amounts beyond ±100 act as ±100. + #[test] + fn fitted_responses_grow_with_the_slider_and_stay_inside_black_and_white() { + let fits = std::iter::once(&m::WHITES).chain(m::REGIONS.iter()); + for (i, fit) in fits.enumerate() { + for sign in [-1.0f32, 1.0] { + for k in 0..=64 { + let x = k as f32 / 64.0; + let mut prev = 0.0f32; + for a in (0..=20).map(|j| sign * 5.0 * j as f32) { + let r = sign * response(fit, a, x); + // steadily: never back by more than a twentieth of an 8-bit level + assert!(r >= -1e-6 && r + 0.05 / 255.0 >= prev, "fit {i} at {x}, amount {a}: {r} after {prev}"); + prev = r; + } + assert_eq!(response(fit, sign * 150.0, x), response(fit, sign * 100.0, x)); + } + assert_eq!(response(fit, sign * 60.0, 0.0), 0.0); + assert_eq!(response(fit, sign * 60.0, 1.0), 0.0); } + assert_eq!(response(fit, 0.0, 0.5), 0.0); + assert_eq!(response(fit, f32::NAN, 0.5), 0.0); } - 0.0 } + /// The four regions peak in tone order: Shadows lowest, then Darks, Lights, Highlights, each one's strongest lift + /// above the one before's. #[test] - fn measured_delta_reads_the_tables_as_the_sorting_version_did() { - assert!(t::REGION_AMOUNTS.windows(2).all(|w| w[0] < w[1]) && t::WHITES_AMOUNTS.windows(2).all(|w| w[0] < w[1])); - for amount in [-150.0f32, -100.0, -80.0, -75.0, -30.0, -1.0, 0.0, 0.5, 12.0, 25.0, 60.0, 100.0, 140.0] { - for i in 0..=40 { - let x = i as f32 / 40.0; - for r in &t::REGIONS { - assert_eq!(measured_delta(&t::REGION_AMOUNTS, r, amount, x), measured_delta_sorted(&t::REGION_AMOUNTS, r, amount, x)); - } - assert_eq!( - measured_delta(&t::WHITES_AMOUNTS, &t::WHITES, amount, x), - measured_delta_sorted(&t::WHITES_AMOUNTS, &t::WHITES, amount, x) - ); - } - } + fn the_regions_peak_in_tone_order() { + let peak = |fit: &[m::Response; 2]| { + (0..=256) + .map(|k| k as f32 / 256.0) + .fold((0.0f32, 0.0f32), |b, x| if response(fit, 50.0, x) > b.1 { (x, response(fit, 50.0, x)) } else { b }) + .0 + }; + let peaks = m::REGIONS.each_ref().map(peak); + assert!(peaks.windows(2).all(|w| w[0] < w[1]), "{peaks:?}"); } /// What the graph draws is the stage's base curve, and the analytic one where the stage uses that. @@ -440,7 +425,7 @@ mod tests { let mut s = v9(); (s.curve.shadows, s.curve.darks, s.curve.lights, s.curve.highlights) = (40.0, -30.0, 25.0, -60.0); let graph = ParametricGraph::new(&s); - assert!(graph.is_measured()); + assert!(graph.is_fitted()); let stage = CurveStage::new(&s).expect("regions set"); for i in 0..=64 { let x = i as f32 / 64.0; @@ -449,16 +434,16 @@ mod tests { // moved splits and earlier processes draw the analytic curve, as they render it s.curve.split_mid = 40.0; let moved = ParametricGraph::new(&s); - assert!(!moved.is_measured()); + assert!(!moved.is_fitted()); assert_eq!(moved.at(0.6), ParametricCurve::new(&s.curve).at(0.6)); s.curve.split_mid = 50.0; let v8 = DevelopSettings { process: Process::V8.version(), ..s }; - assert!(!ParametricGraph::new(&v8).is_measured()); + assert!(!ParametricGraph::new(&v8).is_fitted()); } /// In every region, the amount a drag picks moves the drawn curve by the drag's motion. #[test] - fn a_graph_drag_puts_the_measured_curve_where_the_hand_is() { + fn a_graph_drag_puts_the_fitted_curve_where_the_hand_is() { let mut s = v9(); s.curve.darks = 30.0; let graph = ParametricGraph::new(&s); @@ -478,28 +463,32 @@ mod tests { } } - /// Where opposite regions fold the measured curve back, the drag follows the curve as drawn (held flat by the peak - /// to its left): Lights +100 and Highlights −100 fold it above 0.75. + /// Where opposite regions fold the fitted curve back, the drag follows the curve as drawn (held flat by the peak + /// to its left): Lights +80 and Highlights −100 fold it above 0.75. A region that reaches the peak moves the held + /// line with the hand; one that cannot reach it keeps its value instead of running to the end. #[test] fn a_graph_drag_follows_the_drawn_curve_where_it_is_flattened() { let mut s = v9(); - (s.curve.shadows, s.curve.darks, s.curve.lights, s.curve.highlights) = (-50.0, 100.0, 100.0, -100.0); + (s.curve.shadows, s.curve.darks, s.curve.lights, s.curve.highlights) = (-50.0, 100.0, 80.0, -100.0); let graph = ParametricGraph::new(&s); let x = 0.86; let raw = regions_at(graph.model.amounts.map(|v| v as f32), x as f32) as f64; - assert!(graph.at(x) - raw > 0.1, "the stretch is flattened, or this proves nothing: {} vs {raw}", graph.at(x)); + assert!(graph.at(x) - raw > 0.05, "the stretch is flattened, or this proves nothing: {} vs {raw}", graph.at(x)); let drawn = |region: usize, a: f64| { let mut after = s.clone(); let c = &mut after.curve; *[&mut c.shadows, &mut c.darks, &mut c.lights, &mut c.highlights][region] = a; ParametricGraph::new(&after).at(x) }; - // Lights lowers the peak that holds the line: the drawn line moves with the hand - let a = graph.dragged_amount(2, x, 100.0, -0.03); - assert!((drawn(2, a) - graph.at(x) + 0.03).abs() < 0.004, "Lights {a} moved the line {}", drawn(2, a) - graph.at(x)); - // Highlights hardly moves the held line at all, so its slider stays rather than running to the end - assert!(drawn(3, 100.0) - graph.at(x) < REACH_MIN, "Highlights cannot lift the held line"); - assert_eq!(graph.dragged_amount(3, x, -100.0, 0.03), -100.0); + for (region, delta) in [(2usize, -0.03), (3, 0.03)] { + let from = graph.amount(region); + let a = graph.dragged_amount(region, x, from, delta); + let moved = drawn(region, a) - graph.at(x); + assert!((moved - delta).abs() < 0.004, "region {region}: {from} → {a} moved the line {moved}"); + } + // Shadows does not reach the peak that holds the line, so its slider stays + assert!((drawn(0, 100.0) - graph.at(x)).abs() < REACH_MIN, "Shadows cannot move the held line"); + assert_eq!(graph.dragged_amount(0, x, -50.0, 0.03), -50.0); } #[test] diff --git a/crates/pipeline/src/curve_stage_model.rs b/crates/pipeline/src/curve_stage_model.rs new file mode 100644 index 00000000000..aae839e7df8 --- /dev/null +++ b/crates/pipeline/src/curve_stage_model.rs @@ -0,0 +1,19 @@ +// Written by `tools/lr_tone_charts.py fit`: LightCraft's model of Whites and the parametric regions, fitted to the +// tool's grey-step charts (provenance in docs/curve-stage.md). Constants of the model only. + +/// One bump of a response: `[a1, a2, a3, p0, p1, q0, q1]`, gain `a1 t + a2 t² + a3 t³` (t = |amount| / 100), shape +/// exponents `e^(p0 + p1 t)` and `e^(q0 + q1 t)` ([`crate::curve_stage`]). +pub type Bump = [f64; 7]; +/// A slider direction's response: two bumps, added. +pub type Response = [Bump; 2]; + +/// Whites: negative, positive. +pub const WHITES: [Response; 2] = [[[-8.677986e-02, 2.059910e-02, -1.475161e-03, 1.084063e+00, -7.146165e-02, 7.463740e-01, -1.101123e+00], [-6.097932e-02, 2.162057e-02, -1.096353e-02, 1.843174e+00, 7.765309e-01, -1.820367e-01, 2.624658e-01]], [[4.491106e-02, 2.338704e-01, -4.586305e-02, 9.656835e-01, -4.030916e-01, -1.003725e+00, 5.542276e-01], [1.938421e-02, -8.766121e-02, 1.285831e-01, 4.062532e+00, -2.298370e+00, 3.928699e+00, -2.151902e+00]]]; + +/// Shadows, Darks, Lights, Highlights at the default splits (25, 50, 75): negative, positive. +pub const REGIONS: [[Response; 2]; 4] = [ + [[[-2.304904e-01, 5.397332e-01, -6.521258e-01, 5.201966e-01, -2.332761e+00, 2.029401e+00, 3.919508e-01], [2.322669e-02, -2.558633e-01, 1.479527e-01, 1.186677e+00, 5.075634e-01, 2.511894e+00, 3.430482e-01]], [[6.250307e-02, -3.253250e-03, 1.768197e-03, -5.212752e-01, -7.111264e-02, 2.313180e+00, -1.136211e-01], [6.286758e-02, 2.093856e-02, 8.466331e-03, 1.302920e+00, 1.043781e-01, 2.604516e+00, 8.384981e-02]]], + [[[2.129550e-01, -1.408218e+00, 2.309347e+00, 4.947582e-01, -1.714892e+00, 1.699307e+00, -6.420795e-01], [-5.249287e-01, 1.634143e+00, -2.399744e+00, 7.555377e-02, -1.304895e+00, 6.002093e-01, 2.401095e-01]], [[1.031476e-01, 3.281627e-02, 1.671911e-02, 5.258136e-01, 3.590506e-01, 9.760341e-01, 2.054602e-01], [6.812073e-02, 1.988377e-03, 5.246361e-03, -1.268885e+00, 1.303334e-01, 3.041567e-01, -9.264136e-02]]], + [[[-1.891098e-01, -2.287609e-02, 4.896024e-03, 1.011762e+00, -7.761107e-02, 4.262329e-02, -9.366133e-02], [-1.171421e-02, -1.146297e-02, -1.531020e-02, 1.645838e+00, 5.732118e-02, 1.456855e+00, 1.833067e-01]], [[-1.125586e-01, 1.431238e+00, -2.702337e+00, 1.792564e+00, -2.246400e-01, 4.144821e-01, -6.849247e-01], [5.280858e-01, -1.775048e+00, 2.776570e+00, 9.675963e-01, 3.076062e-01, 5.110037e-01, -9.632875e-01]]], + [[[-1.081283e-01, -3.328262e-02, -1.114034e-03, 1.725021e+00, -4.534782e-02, 8.818974e-02, -8.042736e-03], [2.358962e-02, 9.943229e-03, 1.375851e-03, 2.617848e+00, -4.358847e-02, 2.360366e+00, -4.425145e-02]], [[-6.006532e-02, 4.574089e-01, -2.733591e-01, 2.232173e+00, 5.657972e-01, 7.143387e-01, 9.022714e-01], [2.802296e-01, -7.070198e-01, 5.853124e-01, 2.094691e+00, 5.061273e-01, 7.808968e-01, -1.635143e+00]]], +]; diff --git a/crates/pipeline/src/curve_stage_tables.rs b/crates/pipeline/src/curve_stage_tables.rs deleted file mode 100644 index 768fcb7ef51..00000000000 --- a/crates/pipeline/src/curve_stage_tables.rs +++ /dev/null @@ -1,57 +0,0 @@ -// @generated by tools/lr_tone_charts.py from Camera Raw renders of its synthetic grey steps (docs/curve-stage.md). -// Output minus input of each setting on sRGB-encoded linear ProPhoto values, 257 evenly spaced inputs from 0 to 1. - -pub const WHITES_AMOUNTS: [f32; 6] = [-100.0, -50.0, -25.0, 25.0, 50.0, 100.0]; -pub static WHITES: [[f32; 257]; 6] = [ - [0.000000, 0.000000, 0.000000, -0.000115, -0.000262, -0.000282, -0.000280, -0.000241, -0.000213, -0.000216, -0.000229, -0.000303, -0.000375, -0.000435, -0.000492, -0.000540, -0.000588, -0.000634, -0.000679, -0.000739, -0.000800, -0.000869, -0.000949, -0.001028, -0.001128, -0.001240, -0.001352, -0.001477, -0.001619, -0.001762, -0.001904, -0.002002, -0.002093, -0.002185, -0.002276, -0.002425, -0.002578, -0.002731, -0.002884, -0.003029, -0.003167, -0.003305, -0.003443, -0.003582, -0.003749, -0.003925, -0.004101, -0.004276, -0.004452, -0.004625, -0.004797, -0.004968, -0.005139, -0.005311, -0.005482, -0.005703, -0.005924, -0.006145, -0.006365, -0.006586, -0.006807, -0.007026, -0.007246, -0.007466, -0.007686, -0.007906, -0.008126, -0.008373, -0.008635, -0.008897, -0.009159, -0.009421, -0.009683, -0.009945, -0.010238, -0.010534, -0.010830, -0.011127, -0.011423, -0.011719, -0.012016, -0.012349, -0.012699, -0.013049, -0.013399, -0.013749, -0.014099, -0.014449, -0.014799, -0.015189, -0.015580, -0.015970, -0.016360, -0.016750, -0.017141, -0.017531, -0.017921, -0.018365, -0.018821, -0.019277, -0.019733, -0.020189, -0.020645, -0.021101, -0.021557, -0.022017, -0.022533, -0.023050, -0.023566, -0.024083, -0.024599, -0.025116, -0.025632, -0.026149, -0.026665, -0.027240, -0.027837, -0.028434, -0.029031, -0.029627, -0.030224, -0.030821, -0.031418, -0.032015, -0.032612, -0.033245, -0.033891, -0.034538, -0.035184, -0.035830, -0.036477, -0.037123, -0.037769, -0.038416, -0.039062, -0.039694, -0.040247, -0.040800, -0.041354, -0.041907, -0.042461, -0.043014, -0.043567, -0.044121, -0.044674, -0.045228, -0.045801, -0.046389, -0.046978, -0.047567, -0.048156, -0.048744, -0.049333, -0.049922, -0.050510, -0.051099, -0.051692, -0.052335, -0.052977, -0.053620, -0.054263, -0.054905, -0.055548, -0.056190, -0.056833, -0.057476, -0.058118, -0.058807, -0.059508, -0.060209, -0.060911, -0.061612, -0.062313, -0.063014, -0.063716, -0.064417, -0.065118, -0.065860, -0.066614, -0.067368, -0.068122, -0.068877, -0.069631, -0.070385, -0.071139, -0.071894, -0.072650, -0.073448, -0.074245, -0.075042, -0.075839, -0.076636, -0.077434, -0.078231, -0.079028, -0.079825, -0.080644, -0.081470, -0.082296, -0.083121, -0.083947, -0.084772, -0.085598, -0.086424, -0.087249, -0.088070, -0.088891, -0.089713, -0.090534, -0.091355, -0.092176, -0.092997, -0.093818, -0.094591, -0.095338, -0.096086, -0.096833, -0.097581, -0.098329, -0.099076, -0.099824, -0.100370, -0.100889, -0.101407, -0.101925, -0.102443, -0.102962, -0.103480, -0.103672, -0.103685, -0.103698, -0.103711, -0.103724, -0.103737, -0.103750, -0.102762, -0.101769, -0.100777, -0.099784, -0.098791, -0.097798, -0.095053, -0.092290, -0.089527, -0.086764, -0.084001, -0.079339, -0.073815, -0.068290, -0.062766, -0.056620, -0.047795, -0.038970, -0.030145, -0.020499, -0.010248, 0.000000], - [0.000000, 0.000000, 0.000000, -0.000115, -0.000262, -0.000282, -0.000280, -0.000241, -0.000213, -0.000216, -0.000229, -0.000303, -0.000362, -0.000342, -0.000361, -0.000481, -0.000584, -0.000629, -0.000675, -0.000737, -0.000799, -0.000867, -0.000942, -0.001016, -0.001114, -0.001228, -0.001342, -0.001450, -0.001552, -0.001653, -0.001755, -0.001854, -0.001952, -0.002051, -0.002149, -0.002281, -0.002416, -0.002551, -0.002686, -0.002827, -0.002972, -0.003118, -0.003263, -0.003408, -0.003547, -0.003685, -0.003822, -0.003960, -0.004098, -0.004249, -0.004411, -0.004572, -0.004733, -0.004894, -0.005056, -0.005261, -0.005466, -0.005671, -0.005876, -0.006080, -0.006285, -0.006462, -0.006638, -0.006814, -0.006991, -0.007167, -0.007343, -0.007550, -0.007772, -0.007994, -0.008217, -0.008439, -0.008661, -0.008884, -0.009132, -0.009384, -0.009636, -0.009888, -0.010140, -0.010392, -0.010643, -0.010911, -0.011186, -0.011462, -0.011737, -0.012012, -0.012288, -0.012563, -0.012838, -0.013154, -0.013470, -0.013786, -0.014102, -0.014418, -0.014734, -0.015050, -0.015366, -0.015714, -0.016071, -0.016427, -0.016783, -0.017140, -0.017496, -0.017852, -0.018209, -0.018567, -0.018960, -0.019353, -0.019746, -0.020140, -0.020533, -0.020926, -0.021319, -0.021712, -0.022105, -0.022531, -0.022969, -0.023407, -0.023846, -0.024284, -0.024722, -0.025160, -0.025599, -0.026037, -0.026475, -0.026923, -0.027375, -0.027827, -0.028279, -0.028731, -0.029183, -0.029634, -0.030086, -0.030538, -0.030990, -0.031423, -0.031754, -0.032085, -0.032417, -0.032748, -0.033079, -0.033411, -0.033742, -0.034073, -0.034405, -0.034736, -0.035069, -0.035404, -0.035739, -0.036073, -0.036408, -0.036743, -0.037077, -0.037412, -0.037747, -0.038082, -0.038416, -0.038748, -0.039080, -0.039412, -0.039744, -0.040076, -0.040408, -0.040740, -0.041072, -0.041404, -0.041736, -0.042057, -0.042374, -0.042692, -0.043009, -0.043326, -0.043644, -0.043961, -0.044279, -0.044596, -0.044913, -0.045210, -0.045500, -0.045790, -0.046080, -0.046370, -0.046661, -0.046951, -0.047241, -0.047531, -0.047818, -0.048053, -0.048289, -0.048524, -0.048760, -0.048995, -0.049231, -0.049466, -0.049702, -0.049937, -0.050104, -0.050252, -0.050400, -0.050548, -0.050695, -0.050843, -0.050991, -0.051139, -0.051287, -0.051339, -0.051388, -0.051437, -0.051486, -0.051535, -0.051584, -0.051633, -0.051683, -0.051635, -0.051537, -0.051439, -0.051341, -0.051243, -0.051146, -0.051048, -0.050950, -0.050664, -0.050351, -0.050038, -0.049725, -0.049412, -0.049099, -0.048786, -0.048276, -0.047660, -0.047043, -0.046427, -0.045810, -0.045194, -0.044577, -0.043540, -0.042501, -0.041462, -0.040423, -0.039384, -0.038345, -0.036747, -0.035143, -0.033539, -0.031934, -0.030330, -0.028242, -0.025934, -0.023626, -0.021318, -0.018876, -0.015857, -0.012837, -0.009818, -0.006628, -0.003314, 0.000000], - [0.000000, 0.000000, 0.000000, -0.000096, -0.000224, -0.000267, -0.000245, -0.000104, -0.000027, -0.000130, -0.000228, -0.000300, -0.000357, -0.000337, -0.000338, -0.000392, -0.000441, -0.000477, -0.000512, -0.000549, -0.000585, -0.000641, -0.000721, -0.000802, -0.000869, -0.000929, -0.000988, -0.001060, -0.001151, -0.001242, -0.001332, -0.001401, -0.001466, -0.001531, -0.001596, -0.001706, -0.001818, -0.001931, -0.002044, -0.002140, -0.002224, -0.002308, -0.002392, -0.002476, -0.002571, -0.002669, -0.002768, -0.002866, -0.002964, -0.003073, -0.003190, -0.003306, -0.003423, -0.003540, -0.003656, -0.003790, -0.003925, -0.004059, -0.004193, -0.004327, -0.004461, -0.004584, -0.004706, -0.004829, -0.004952, -0.005074, -0.005197, -0.005321, -0.005447, -0.005573, -0.005698, -0.005824, -0.005950, -0.006075, -0.006233, -0.006394, -0.006556, -0.006717, -0.006879, -0.007040, -0.007202, -0.007371, -0.007545, -0.007718, -0.007891, -0.008064, -0.008238, -0.008411, -0.008584, -0.008777, -0.008969, -0.009161, -0.009354, -0.009546, -0.009739, -0.009931, -0.010123, -0.010331, -0.010542, -0.010753, -0.010964, -0.011175, -0.011386, -0.011597, -0.011808, -0.012019, -0.012243, -0.012468, -0.012692, -0.012916, -0.013140, -0.013364, -0.013588, -0.013813, -0.014037, -0.014283, -0.014536, -0.014790, -0.015044, -0.015298, -0.015552, -0.015806, -0.016060, -0.016314, -0.016568, -0.016806, -0.017038, -0.017269, -0.017501, -0.017733, -0.017965, -0.018197, -0.018429, -0.018660, -0.018892, -0.019112, -0.019271, -0.019429, -0.019587, -0.019745, -0.019904, -0.020062, -0.020220, -0.020379, -0.020537, -0.020695, -0.020846, -0.020990, -0.021135, -0.021280, -0.021425, -0.021569, -0.021714, -0.021859, -0.022004, -0.022148, -0.022292, -0.022427, -0.022561, -0.022695, -0.022830, -0.022964, -0.023098, -0.023233, -0.023367, -0.023502, -0.023636, -0.023754, -0.023867, -0.023981, -0.024094, -0.024207, -0.024321, -0.024434, -0.024548, -0.024661, -0.024774, -0.024866, -0.024951, -0.025036, -0.025121, -0.025206, -0.025292, -0.025377, -0.025462, -0.025547, -0.025629, -0.025670, -0.025711, -0.025752, -0.025793, -0.025834, -0.025875, -0.025916, -0.025957, -0.025998, -0.025998, -0.025986, -0.025975, -0.025963, -0.025951, -0.025939, -0.025928, -0.025916, -0.025904, -0.025834, -0.025762, -0.025689, -0.025617, -0.025545, -0.025473, -0.025401, -0.025328, -0.025208, -0.025064, -0.024920, -0.024775, -0.024631, -0.024487, -0.024342, -0.024198, -0.023963, -0.023714, -0.023466, -0.023217, -0.022968, -0.022720, -0.022471, -0.022140, -0.021764, -0.021387, -0.021011, -0.020634, -0.020258, -0.019881, -0.019330, -0.018779, -0.018227, -0.017676, -0.017124, -0.016573, -0.015824, -0.015074, -0.014323, -0.013572, -0.012822, -0.011889, -0.010874, -0.009859, -0.008844, -0.007785, -0.006538, -0.005290, -0.004043, -0.002728, -0.001364, 0.000000], - [0.000000, 0.000000, 0.000004, 0.000007, 0.000012, 0.000032, 0.000045, 0.000043, 0.000043, 0.000043, 0.000042, 0.000036, 0.000043, 0.000120, 0.000175, 0.000171, 0.000179, 0.000226, 0.000273, 0.000311, 0.000349, 0.000381, 0.000405, 0.000429, 0.000479, 0.000545, 0.000612, 0.000660, 0.000680, 0.000700, 0.000719, 0.000776, 0.000838, 0.000900, 0.000962, 0.001031, 0.001099, 0.001168, 0.001237, 0.001297, 0.001353, 0.001408, 0.001463, 0.001518, 0.001577, 0.001636, 0.001696, 0.001755, 0.001815, 0.001891, 0.001980, 0.002068, 0.002156, 0.002244, 0.002332, 0.002395, 0.002458, 0.002521, 0.002584, 0.002648, 0.002711, 0.002808, 0.002906, 0.003004, 0.003102, 0.003200, 0.003297, 0.003400, 0.003505, 0.003611, 0.003716, 0.003821, 0.003926, 0.004032, 0.004151, 0.004273, 0.004395, 0.004516, 0.004638, 0.004760, 0.004881, 0.005011, 0.005145, 0.005278, 0.005412, 0.005545, 0.005679, 0.005812, 0.005946, 0.006092, 0.006237, 0.006383, 0.006529, 0.006674, 0.006820, 0.006966, 0.007112, 0.007278, 0.007449, 0.007620, 0.007791, 0.007962, 0.008133, 0.008304, 0.008475, 0.008647, 0.008834, 0.009021, 0.009208, 0.009396, 0.009583, 0.009770, 0.009958, 0.010145, 0.010332, 0.010538, 0.010750, 0.010963, 0.011175, 0.011388, 0.011600, 0.011812, 0.012025, 0.012237, 0.012450, 0.012632, 0.012804, 0.012975, 0.013147, 0.013318, 0.013490, 0.013661, 0.013833, 0.014004, 0.014175, 0.014343, 0.014493, 0.014642, 0.014791, 0.014941, 0.015090, 0.015240, 0.015389, 0.015538, 0.015688, 0.015837, 0.015989, 0.016144, 0.016299, 0.016454, 0.016609, 0.016764, 0.016919, 0.017074, 0.017229, 0.017384, 0.017539, 0.017690, 0.017841, 0.017992, 0.018144, 0.018295, 0.018446, 0.018597, 0.018749, 0.018900, 0.019051, 0.019198, 0.019344, 0.019490, 0.019635, 0.019781, 0.019927, 0.020073, 0.020219, 0.020364, 0.020510, 0.020649, 0.020785, 0.020921, 0.021057, 0.021194, 0.021330, 0.021466, 0.021602, 0.021739, 0.021874, 0.021991, 0.022108, 0.022225, 0.022342, 0.022459, 0.022576, 0.022693, 0.022810, 0.022927, 0.023029, 0.023128, 0.023227, 0.023326, 0.023425, 0.023523, 0.023622, 0.023721, 0.023820, 0.023898, 0.023976, 0.024053, 0.024131, 0.024209, 0.024287, 0.024365, 0.024442, 0.024500, 0.024547, 0.024595, 0.024642, 0.024689, 0.024737, 0.024784, 0.024832, 0.024839, 0.024842, 0.024844, 0.024846, 0.024849, 0.024851, 0.024853, 0.024802, 0.024721, 0.024641, 0.024560, 0.024480, 0.024399, 0.024319, 0.024114, 0.023909, 0.023704, 0.023499, 0.023293, 0.023088, 0.022686, 0.022283, 0.021879, 0.021475, 0.021072, 0.020448, 0.019725, 0.019001, 0.018278, 0.017293, 0.015181, 0.013069, 0.010956, 0.007812, 0.003905, 0.000000], - [0.000000, 0.000074, 0.000125, 0.000231, 0.000267, 0.000269, 0.000316, 0.000448, 0.000536, 0.000503, 0.000469, 0.000429, 0.000417, 0.000552, 0.000665, 0.000728, 0.000803, 0.000921, 0.001038, 0.001193, 0.001351, 0.001497, 0.001630, 0.001762, 0.001902, 0.002047, 0.002192, 0.002339, 0.002490, 0.002641, 0.002792, 0.003019, 0.003256, 0.003493, 0.003731, 0.003912, 0.004089, 0.004267, 0.004444, 0.004658, 0.004898, 0.005139, 0.005379, 0.005619, 0.005873, 0.006130, 0.006388, 0.006645, 0.006902, 0.007164, 0.007429, 0.007694, 0.007959, 0.008224, 0.008489, 0.008774, 0.009058, 0.009343, 0.009628, 0.009912, 0.010197, 0.010532, 0.010867, 0.011202, 0.011538, 0.011873, 0.012208, 0.012575, 0.012959, 0.013343, 0.013727, 0.014111, 0.014495, 0.014879, 0.015296, 0.015716, 0.016137, 0.016557, 0.016978, 0.017398, 0.017819, 0.018281, 0.018764, 0.019247, 0.019729, 0.020212, 0.020694, 0.021177, 0.021660, 0.022208, 0.022756, 0.023304, 0.023852, 0.024401, 0.024949, 0.025497, 0.026045, 0.026634, 0.027233, 0.027832, 0.028430, 0.029029, 0.029628, 0.030227, 0.030825, 0.031429, 0.032111, 0.032793, 0.033474, 0.034156, 0.034838, 0.035520, 0.036201, 0.036883, 0.037565, 0.038266, 0.038975, 0.039684, 0.040393, 0.041102, 0.041811, 0.042520, 0.043228, 0.043937, 0.044646, 0.045200, 0.045698, 0.046195, 0.046693, 0.047190, 0.047688, 0.048186, 0.048683, 0.049181, 0.049679, 0.050172, 0.050642, 0.051112, 0.051581, 0.052051, 0.052521, 0.052991, 0.053460, 0.053930, 0.054400, 0.054870, 0.055335, 0.055795, 0.056256, 0.056717, 0.057178, 0.057639, 0.058099, 0.058560, 0.059021, 0.059482, 0.059940, 0.060371, 0.060802, 0.061232, 0.061663, 0.062094, 0.062525, 0.062955, 0.063386, 0.063817, 0.064247, 0.064643, 0.065028, 0.065414, 0.065800, 0.066185, 0.066571, 0.066957, 0.067342, 0.067728, 0.068114, 0.068443, 0.068753, 0.069064, 0.069374, 0.069685, 0.069995, 0.070306, 0.070616, 0.070927, 0.071233, 0.071471, 0.071709, 0.071946, 0.072184, 0.072422, 0.072660, 0.072897, 0.073135, 0.073373, 0.073549, 0.073708, 0.073868, 0.074027, 0.074186, 0.074346, 0.074505, 0.074664, 0.074823, 0.074873, 0.074920, 0.074966, 0.075013, 0.075059, 0.075106, 0.075152, 0.075199, 0.075137, 0.075020, 0.074903, 0.074786, 0.074670, 0.074553, 0.074436, 0.074319, 0.073978, 0.073606, 0.073233, 0.072861, 0.072488, 0.072115, 0.071743, 0.071119, 0.070356, 0.069593, 0.068831, 0.068068, 0.067306, 0.066543, 0.065205, 0.063864, 0.062523, 0.061182, 0.059841, 0.058501, 0.055362, 0.052205, 0.049048, 0.045891, 0.042734, 0.039062, 0.035155, 0.031249, 0.027343, 0.023437, 0.019530, 0.015624, 0.011718, 0.007812, 0.003905, 0.000000], - [0.000000, 0.000500, 0.001050, 0.001608, 0.002124, 0.002641, 0.003061, 0.003303, 0.003534, 0.003731, 0.003895, 0.003860, 0.003920, 0.004480, 0.005071, 0.005740, 0.006429, 0.007182, 0.007935, 0.008852, 0.009777, 0.010736, 0.011738, 0.012740, 0.013790, 0.014871, 0.015953, 0.017110, 0.018378, 0.019646, 0.020914, 0.022253, 0.023603, 0.024952, 0.026301, 0.027757, 0.029220, 0.030684, 0.032148, 0.033662, 0.035214, 0.036765, 0.038316, 0.039868, 0.041479, 0.043107, 0.044734, 0.046362, 0.047990, 0.049693, 0.051446, 0.053199, 0.054951, 0.056704, 0.058458, 0.060353, 0.062248, 0.064143, 0.066038, 0.067933, 0.069828, 0.071984, 0.074141, 0.076298, 0.078455, 0.080612, 0.082769, 0.085098, 0.087516, 0.089934, 0.092353, 0.094771, 0.097190, 0.099608, 0.102268, 0.104958, 0.107648, 0.110338, 0.113028, 0.115718, 0.118408, 0.121306, 0.124302, 0.127299, 0.130295, 0.133292, 0.136288, 0.139284, 0.142281, 0.145455, 0.148629, 0.151804, 0.154979, 0.158153, 0.161328, 0.164503, 0.167677, 0.170547, 0.173344, 0.176141, 0.178938, 0.181735, 0.184532, 0.187329, 0.190126, 0.192895, 0.195221, 0.197546, 0.199871, 0.202196, 0.204522, 0.206847, 0.209172, 0.211497, 0.213823, 0.215741, 0.217504, 0.219267, 0.221030, 0.222793, 0.224556, 0.226319, 0.228082, 0.229845, 0.231608, 0.232962, 0.234169, 0.235376, 0.236582, 0.237789, 0.238996, 0.240202, 0.241409, 0.242616, 0.243822, 0.244972, 0.245824, 0.246675, 0.247527, 0.248378, 0.249229, 0.250081, 0.250932, 0.251784, 0.252635, 0.253487, 0.254150, 0.254663, 0.255176, 0.255689, 0.256201, 0.256714, 0.257227, 0.257740, 0.258253, 0.258766, 0.259249, 0.259381, 0.259513, 0.259645, 0.259777, 0.259909, 0.260041, 0.260173, 0.260305, 0.260437, 0.260570, 0.260342, 0.260015, 0.259689, 0.259363, 0.259036, 0.258710, 0.258383, 0.258057, 0.257731, 0.257404, 0.256644, 0.255745, 0.254845, 0.253946, 0.253046, 0.252147, 0.251248, 0.250348, 0.249449, 0.248501, 0.246825, 0.245149, 0.243472, 0.241796, 0.240119, 0.238443, 0.236767, 0.235090, 0.233414, 0.230383, 0.226974, 0.223565, 0.220155, 0.216746, 0.213337, 0.209928, 0.206518, 0.203109, 0.199218, 0.195312, 0.191405, 0.187499, 0.183593, 0.179687, 0.175780, 0.171874, 0.167968, 0.164062, 0.160155, 0.156249, 0.152343, 0.148437, 0.144530, 0.140624, 0.136718, 0.132812, 0.128905, 0.124999, 0.121093, 0.117187, 0.113280, 0.109374, 0.105468, 0.101562, 0.097655, 0.093749, 0.089843, 0.085937, 0.082030, 0.078124, 0.074218, 0.070312, 0.066405, 0.062499, 0.058593, 0.054687, 0.050780, 0.046874, 0.042968, 0.039062, 0.035155, 0.031249, 0.027343, 0.023437, 0.019530, 0.015624, 0.011718, 0.007812, 0.003905, 0.000000], -]; - -/// Shadows, Darks, Lights, Highlights at the default splits (25, 50, 75). -pub const REGION_AMOUNTS: [f32; 8] = [-100.0, -75.0, -50.0, -25.0, 25.0, 50.0, 75.0, 100.0]; -pub static REGIONS: [[[f32; 257]; 8]; 4] = [ - [ - [0.000000, -0.003906, -0.007812, -0.011719, -0.015625, -0.019531, -0.023438, -0.027344, -0.031250, -0.035156, -0.039062, -0.042969, -0.046875, -0.050781, -0.054687, -0.058593, -0.062499, -0.066404, -0.070310, -0.074214, -0.078119, -0.082020, -0.085917, -0.089814, -0.093689, -0.097549, -0.101408, -0.105222, -0.108969, -0.112716, -0.116463, -0.119858, -0.123204, -0.126550, -0.129896, -0.132087, -0.134192, -0.136297, -0.138402, -0.139029, -0.138591, -0.138153, -0.137715, -0.137277, -0.136208, -0.134968, -0.133728, -0.132488, -0.131248, -0.130007, -0.128764, -0.127522, -0.126280, -0.125038, -0.123793, -0.122191, -0.120589, -0.118988, -0.117386, -0.115784, -0.114182, -0.112299, -0.110414, -0.108530, -0.106645, -0.104760, -0.102875, -0.100853, -0.098758, -0.096664, -0.094569, -0.092474, -0.090380, -0.088285, -0.086074, -0.083848, -0.081623, -0.079397, -0.077171, -0.074945, -0.072719, -0.070470, -0.068210, -0.065950, -0.063690, -0.061429, -0.059169, -0.056909, -0.054648, -0.052496, -0.050343, -0.048191, -0.046039, -0.043887, -0.041734, -0.039582, -0.037430, -0.035503, -0.033629, -0.031756, -0.029882, -0.028009, -0.026135, -0.024262, -0.022388, -0.020543, -0.019148, -0.017753, -0.016358, -0.014963, -0.013569, -0.012174, -0.010779, -0.009384, -0.007989, -0.007096, -0.006394, -0.005692, -0.004989, -0.004287, -0.003585, -0.002883, -0.002181, -0.001479, -0.000777, -0.000550, -0.000494, -0.000438, -0.000382, -0.000326, -0.000270, -0.000214, -0.000159, -0.000103, -0.000047, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], - [0.000000, -0.003906, -0.007810, -0.011714, -0.015617, -0.019520, -0.023420, -0.027317, -0.031213, -0.035106, -0.038996, -0.042869, -0.046738, -0.050579, -0.054409, -0.058210, -0.061993, -0.065718, -0.069443, -0.072985, -0.076518, -0.079914, -0.083141, -0.086369, -0.089272, -0.091958, -0.094644, -0.096916, -0.098582, -0.100248, -0.101914, -0.102339, -0.102591, -0.102842, -0.103094, -0.102809, -0.102485, -0.102160, -0.101836, -0.101648, -0.101559, -0.101469, -0.101380, -0.101290, -0.100926, -0.100488, -0.100049, -0.099610, -0.099171, -0.098507, -0.097696, -0.096884, -0.096073, -0.095261, -0.094447, -0.093356, -0.092265, -0.091174, -0.090084, -0.088993, -0.087902, -0.086539, -0.085174, -0.083810, -0.082445, -0.081080, -0.079715, -0.078211, -0.076633, -0.075055, -0.073477, -0.071899, -0.070321, -0.068743, -0.067045, -0.065333, -0.063620, -0.061908, -0.060195, -0.058482, -0.056770, -0.055028, -0.053272, -0.051517, -0.049761, -0.048005, -0.046250, -0.044494, -0.042738, -0.041056, -0.039375, -0.037694, -0.036012, -0.034331, -0.032650, -0.030969, -0.029287, -0.027782, -0.026319, -0.024855, -0.023392, -0.021929, -0.020466, -0.019003, -0.017539, -0.016098, -0.015009, -0.013919, -0.012830, -0.011740, -0.010651, -0.009561, -0.008472, -0.007382, -0.006293, -0.005591, -0.005039, -0.004486, -0.003933, -0.003380, -0.002827, -0.002274, -0.001722, -0.001169, -0.000616, -0.000437, -0.000392, -0.000348, -0.000304, -0.000259, -0.000215, -0.000170, -0.000126, -0.000082, -0.000037, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], - [0.000000, -0.003889, -0.007766, -0.011628, -0.015484, -0.019325, -0.023153, -0.026956, -0.030743, -0.034487, -0.038207, -0.041789, -0.045327, -0.048632, -0.051842, -0.054816, -0.057642, -0.059991, -0.062341, -0.063894, -0.065409, -0.066430, -0.066845, -0.067260, -0.067075, -0.066490, -0.065904, -0.065464, -0.065235, -0.065006, -0.064777, -0.064648, -0.064532, -0.064417, -0.064302, -0.063994, -0.063672, -0.063350, -0.063027, -0.062616, -0.062141, -0.061666, -0.061190, -0.060715, -0.060164, -0.059592, -0.059020, -0.058449, -0.057877, -0.057219, -0.056506, -0.055792, -0.055079, -0.054365, -0.053651, -0.052854, -0.052057, -0.051260, -0.050464, -0.049667, -0.048870, -0.047994, -0.047118, -0.046242, -0.045365, -0.044489, -0.043613, -0.042704, -0.041779, -0.040854, -0.039928, -0.039003, -0.038078, -0.037152, -0.036206, -0.035257, -0.034309, -0.033360, -0.032411, -0.031463, -0.030514, -0.029568, -0.028622, -0.027676, -0.026731, -0.025785, -0.024839, -0.023894, -0.022948, -0.022057, -0.021166, -0.020276, -0.019385, -0.018494, -0.017603, -0.016712, -0.015821, -0.015026, -0.014254, -0.013482, -0.012710, -0.011938, -0.011166, -0.010394, -0.009622, -0.008861, -0.008269, -0.007678, -0.007087, -0.006495, -0.005904, -0.005312, -0.004721, -0.004129, -0.003538, -0.003150, -0.002841, -0.002531, -0.002221, -0.001912, -0.001602, -0.001292, -0.000983, -0.000673, -0.000363, -0.000262, -0.000235, -0.000209, -0.000182, -0.000155, -0.000129, -0.000102, -0.000076, -0.000049, -0.000022, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], - [0.000000, -0.003216, -0.006332, -0.009343, -0.012326, -0.015215, -0.018012, -0.020640, -0.023188, -0.025512, -0.027735, -0.029351, -0.030826, -0.031553, -0.032123, -0.032295, -0.032353, -0.032045, -0.031737, -0.032000, -0.032289, -0.032629, -0.033031, -0.033434, -0.033802, -0.034148, -0.034493, -0.034792, -0.035021, -0.035251, -0.035480, -0.035605, -0.035715, -0.035825, -0.035935, -0.035913, -0.035882, -0.035851, -0.035820, -0.035735, -0.035609, -0.035484, -0.035359, -0.035234, -0.035025, -0.034794, -0.034563, -0.034332, -0.034101, -0.033801, -0.033455, -0.033109, -0.032763, -0.032417, -0.032070, -0.031651, -0.031232, -0.030812, -0.030393, -0.029974, -0.029555, -0.029057, -0.028559, -0.028061, -0.027563, -0.027065, -0.026567, -0.026037, -0.025490, -0.024943, -0.024396, -0.023849, -0.023303, -0.022756, -0.022183, -0.021607, -0.021032, -0.020456, -0.019880, -0.019304, -0.018729, -0.018149, -0.017566, -0.016984, -0.016402, -0.015820, -0.015238, -0.014655, -0.014073, -0.013525, -0.012977, -0.012429, -0.011880, -0.011332, -0.010784, -0.010236, -0.009688, -0.009199, -0.008724, -0.008250, -0.007775, -0.007301, -0.006826, -0.006352, -0.005877, -0.005409, -0.005050, -0.004690, -0.004331, -0.003971, -0.003612, -0.003253, -0.002893, -0.002534, -0.002174, -0.001938, -0.001748, -0.001559, -0.001369, -0.001180, -0.000990, -0.000801, -0.000611, -0.000422, -0.000232, -0.000169, -0.000152, -0.000135, -0.000118, -0.000101, -0.000083, -0.000066, -0.000049, -0.000032, -0.000014, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], - [0.000000, 0.003646, 0.006659, 0.009375, 0.011731, 0.013420, 0.014676, 0.015142, 0.015370, 0.014932, 0.014561, 0.014594, 0.014704, 0.015220, 0.015721, 0.016189, 0.016651, 0.017095, 0.017538, 0.017972, 0.018404, 0.018805, 0.019166, 0.019527, 0.019867, 0.020193, 0.020519, 0.020826, 0.021106, 0.021387, 0.021667, 0.021886, 0.022098, 0.022309, 0.022520, 0.022666, 0.022807, 0.022948, 0.023088, 0.023182, 0.023242, 0.023302, 0.023362, 0.023422, 0.023400, 0.023355, 0.023310, 0.023265, 0.023221, 0.023123, 0.022990, 0.022858, 0.022725, 0.022592, 0.022459, 0.022224, 0.021989, 0.021754, 0.021519, 0.021284, 0.021049, 0.020741, 0.020433, 0.020124, 0.019816, 0.019508, 0.019199, 0.018846, 0.018470, 0.018094, 0.017718, 0.017341, 0.016965, 0.016589, 0.016177, 0.015761, 0.015345, 0.014929, 0.014513, 0.014097, 0.013681, 0.013261, 0.012839, 0.012416, 0.011994, 0.011572, 0.011150, 0.010728, 0.010306, 0.009902, 0.009498, 0.009094, 0.008689, 0.008285, 0.007881, 0.007477, 0.007073, 0.006710, 0.006356, 0.006003, 0.005650, 0.005297, 0.004943, 0.004590, 0.004237, 0.003889, 0.003626, 0.003364, 0.003102, 0.002840, 0.002577, 0.002315, 0.002053, 0.001791, 0.001528, 0.001357, 0.001221, 0.001085, 0.000948, 0.000812, 0.000676, 0.000540, 0.000404, 0.000267, 0.000131, 0.000088, 0.000079, 0.000070, 0.000061, 0.000052, 0.000043, 0.000034, 0.000026, 0.000017, 0.000008, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], - [0.000000, 0.009101, 0.016045, 0.021283, 0.025025, 0.026425, 0.027479, 0.027901, 0.028224, 0.028275, 0.028387, 0.028865, 0.029436, 0.030492, 0.031508, 0.032421, 0.033364, 0.034399, 0.035435, 0.036317, 0.037192, 0.038050, 0.038889, 0.039728, 0.040518, 0.041276, 0.042034, 0.042754, 0.043416, 0.044078, 0.044741, 0.045302, 0.045849, 0.046396, 0.046943, 0.047349, 0.047744, 0.048140, 0.048536, 0.048827, 0.049044, 0.049260, 0.049476, 0.049693, 0.049744, 0.049751, 0.049758, 0.049765, 0.049772, 0.049646, 0.049434, 0.049222, 0.049010, 0.048798, 0.048584, 0.048137, 0.047690, 0.047243, 0.046796, 0.046348, 0.045901, 0.045257, 0.044610, 0.043964, 0.043318, 0.042672, 0.042026, 0.041275, 0.040470, 0.039665, 0.038860, 0.038055, 0.037250, 0.036444, 0.035538, 0.034620, 0.033702, 0.032783, 0.031865, 0.030947, 0.030028, 0.029095, 0.028155, 0.027215, 0.026275, 0.025335, 0.024395, 0.023455, 0.022515, 0.021619, 0.020723, 0.019827, 0.018931, 0.018034, 0.017138, 0.016242, 0.015346, 0.014552, 0.013783, 0.013014, 0.012245, 0.011476, 0.010707, 0.009938, 0.009168, 0.008411, 0.007845, 0.007278, 0.006712, 0.006145, 0.005579, 0.005012, 0.004445, 0.003879, 0.003312, 0.002945, 0.002654, 0.002363, 0.002071, 0.001780, 0.001489, 0.001198, 0.000906, 0.000615, 0.000324, 0.000229, 0.000206, 0.000183, 0.000159, 0.000136, 0.000113, 0.000090, 0.000066, 0.000043, 0.000020, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], - [0.000000, 0.016424, 0.026872, 0.032718, 0.036179, 0.037852, 0.039251, 0.040147, 0.040939, 0.041440, 0.042015, 0.043039, 0.044157, 0.045770, 0.047360, 0.048891, 0.050438, 0.052038, 0.053639, 0.055094, 0.056543, 0.057972, 0.059376, 0.060780, 0.062128, 0.063438, 0.064749, 0.066005, 0.067181, 0.068356, 0.069532, 0.070566, 0.071581, 0.072595, 0.073610, 0.074423, 0.075221, 0.076019, 0.076817, 0.077447, 0.077957, 0.078467, 0.078977, 0.079487, 0.079717, 0.079872, 0.080026, 0.080181, 0.080336, 0.080261, 0.080036, 0.079811, 0.079586, 0.079361, 0.079132, 0.078488, 0.077845, 0.077201, 0.076558, 0.075914, 0.075270, 0.074259, 0.073245, 0.072231, 0.071217, 0.070203, 0.069189, 0.067969, 0.066640, 0.065312, 0.063983, 0.062655, 0.061327, 0.059998, 0.058504, 0.056989, 0.055474, 0.053959, 0.052444, 0.050929, 0.049414, 0.047861, 0.046290, 0.044719, 0.043148, 0.041577, 0.040006, 0.038435, 0.036864, 0.035383, 0.033902, 0.032421, 0.030940, 0.029460, 0.027979, 0.026498, 0.025017, 0.023711, 0.022447, 0.021184, 0.019920, 0.018656, 0.017392, 0.016128, 0.014864, 0.013620, 0.012702, 0.011785, 0.010867, 0.009949, 0.009031, 0.008113, 0.007195, 0.006278, 0.005360, 0.004765, 0.004294, 0.003823, 0.003353, 0.002882, 0.002411, 0.001940, 0.001469, 0.000998, 0.000527, 0.000374, 0.000336, 0.000298, 0.000260, 0.000222, 0.000184, 0.000146, 0.000108, 0.000070, 0.000032, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], - [0.000000, 0.025013, 0.036949, 0.042838, 0.046705, 0.048947, 0.050910, 0.052362, 0.053694, 0.054690, 0.055763, 0.057303, 0.058964, 0.061264, 0.063530, 0.065707, 0.067897, 0.070128, 0.072358, 0.074526, 0.076691, 0.078814, 0.080885, 0.082956, 0.084966, 0.086934, 0.088903, 0.090823, 0.092674, 0.094525, 0.096376, 0.098048, 0.099696, 0.101343, 0.102991, 0.104385, 0.105761, 0.107137, 0.108512, 0.109656, 0.110634, 0.111611, 0.112588, 0.113565, 0.114129, 0.114580, 0.115032, 0.115483, 0.115935, 0.116025, 0.115879, 0.115733, 0.115587, 0.115441, 0.115289, 0.114462, 0.113635, 0.112808, 0.111982, 0.111155, 0.110328, 0.108885, 0.107438, 0.105990, 0.104543, 0.103096, 0.101648, 0.099869, 0.097916, 0.095962, 0.094009, 0.092055, 0.090102, 0.088148, 0.085917, 0.083652, 0.081387, 0.079122, 0.076857, 0.074592, 0.072327, 0.070013, 0.067676, 0.065339, 0.063001, 0.060664, 0.058327, 0.055990, 0.053653, 0.051465, 0.049278, 0.047092, 0.044905, 0.042718, 0.040531, 0.038344, 0.036158, 0.034252, 0.032414, 0.030575, 0.028737, 0.026898, 0.025060, 0.023222, 0.021383, 0.019575, 0.018249, 0.016923, 0.015598, 0.014272, 0.012946, 0.011621, 0.010295, 0.008969, 0.007644, 0.006791, 0.006119, 0.005447, 0.004775, 0.004103, 0.003431, 0.002759, 0.002087, 0.001415, 0.000743, 0.000525, 0.000472, 0.000418, 0.000365, 0.000312, 0.000258, 0.000205, 0.000152, 0.000098, 0.000045, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], - ], - [ - [0.000000, -0.003906, -0.007812, -0.011719, -0.015625, -0.019531, -0.023438, -0.027344, -0.031250, -0.035156, -0.039062, -0.042969, -0.046875, -0.050781, -0.054688, -0.058594, -0.062500, -0.066406, -0.070312, -0.074219, -0.078125, -0.082031, -0.085938, -0.089844, -0.093750, -0.097656, -0.101562, -0.105469, -0.109375, -0.113281, -0.117187, -0.121093, -0.124999, -0.128906, -0.132812, -0.136717, -0.140621, -0.144526, -0.148431, -0.152333, -0.156234, -0.160135, -0.164036, -0.167937, -0.171819, -0.175697, -0.179574, -0.183452, -0.187329, -0.191141, -0.194911, -0.198680, -0.202449, -0.206219, -0.209984, -0.213377, -0.216770, -0.220162, -0.223555, -0.226947, -0.230340, -0.232560, -0.234772, -0.236984, -0.239196, -0.241409, -0.243621, -0.244545, -0.244792, -0.245038, -0.245285, -0.245532, -0.245779, -0.246025, -0.246172, -0.246307, -0.246442, -0.246576, -0.246711, -0.246845, -0.246980, -0.246882, -0.246673, -0.246464, -0.246254, -0.246045, -0.245836, -0.245627, -0.245418, -0.244803, -0.244185, -0.243568, -0.242951, -0.242334, -0.241716, -0.241099, -0.240482, -0.239553, -0.238550, -0.237547, -0.236544, -0.235540, -0.234537, -0.233534, -0.232531, -0.231509, -0.230200, -0.228890, -0.227580, -0.226271, -0.224961, -0.223651, -0.222342, -0.221032, -0.219723, -0.218225, -0.216656, -0.215087, -0.213517, -0.211948, -0.210379, -0.208810, -0.207241, -0.205671, -0.204102, -0.202374, -0.200589, -0.198804, -0.197019, -0.195235, -0.193450, -0.191665, -0.189880, -0.188095, -0.186310, -0.184500, -0.182559, -0.180619, -0.178678, -0.176738, -0.174798, -0.172857, -0.170917, -0.168976, -0.167036, -0.165095, -0.163099, -0.161058, -0.159017, -0.156976, -0.154936, -0.152895, -0.150854, -0.148813, -0.146772, -0.144731, -0.142686, -0.140594, -0.138502, -0.136410, -0.134318, -0.132226, -0.130134, -0.128042, -0.125950, -0.123858, -0.121766, -0.119682, -0.117600, -0.115518, -0.113436, -0.111355, -0.109273, -0.107191, -0.105109, -0.103027, -0.100945, -0.098905, -0.096878, -0.094851, -0.092824, -0.090797, -0.088770, -0.086743, -0.084717, -0.082690, -0.080669, -0.078748, -0.076826, -0.074905, -0.072983, -0.071062, -0.069140, -0.067219, -0.065297, -0.063375, -0.061571, -0.059799, -0.058027, -0.056255, -0.054484, -0.052712, -0.050940, -0.049168, -0.047396, -0.045808, -0.044226, -0.042644, -0.041063, -0.039481, -0.037899, -0.036317, -0.034735, -0.033291, -0.031918, -0.030545, -0.029173, -0.027800, -0.026427, -0.025054, -0.023681, -0.022501, -0.021348, -0.020196, -0.019043, -0.017890, -0.016738, -0.015585, -0.014581, -0.013657, -0.012734, -0.011811, -0.010888, -0.009964, -0.009041, -0.008335, -0.007630, -0.006925, -0.006220, -0.005514, -0.004809, -0.004309, -0.003811, -0.003313, -0.002815, -0.002317, -0.001941, -0.001619, -0.001297, -0.000976, -0.000683, -0.000518, -0.000353, -0.000188, -0.000092, -0.000046, 0.000000], - [0.000000, -0.003906, -0.007812, -0.011717, -0.015622, -0.019528, -0.023434, -0.027338, -0.031242, -0.035145, -0.039048, -0.042950, -0.046852, -0.050752, -0.054650, -0.058542, -0.062434, -0.066322, -0.070211, -0.074086, -0.077960, -0.081820, -0.085661, -0.089502, -0.093311, -0.097100, -0.100888, -0.104624, -0.108282, -0.111941, -0.115599, -0.119092, -0.122562, -0.126032, -0.129502, -0.132580, -0.135629, -0.138678, -0.141728, -0.144400, -0.146802, -0.149204, -0.151605, -0.154007, -0.155625, -0.157031, -0.158436, -0.159842, -0.161247, -0.162285, -0.163082, -0.163880, -0.164677, -0.165474, -0.166274, -0.167365, -0.168456, -0.169547, -0.170638, -0.171729, -0.172819, -0.173662, -0.174504, -0.175345, -0.176186, -0.177028, -0.177869, -0.178537, -0.179113, -0.179690, -0.180267, -0.180843, -0.181420, -0.181997, -0.182333, -0.182640, -0.182947, -0.183253, -0.183560, -0.183867, -0.184174, -0.184268, -0.184262, -0.184256, -0.184250, -0.184244, -0.184238, -0.184232, -0.184226, -0.183930, -0.183633, -0.183336, -0.183039, -0.182742, -0.182445, -0.182148, -0.181851, -0.181319, -0.180731, -0.180143, -0.179554, -0.178966, -0.178378, -0.177789, -0.177201, -0.176597, -0.175739, -0.174881, -0.174023, -0.173166, -0.172308, -0.171450, -0.170592, -0.169734, -0.168876, -0.167842, -0.166740, -0.165638, -0.164537, -0.163435, -0.162333, -0.161232, -0.160130, -0.159028, -0.157927, -0.156676, -0.155371, -0.154066, -0.152762, -0.151457, -0.150152, -0.148847, -0.147543, -0.146238, -0.144933, -0.143603, -0.142137, -0.140671, -0.139205, -0.137739, -0.136274, -0.134808, -0.133342, -0.131876, -0.130410, -0.128944, -0.127420, -0.125848, -0.124276, -0.122704, -0.121133, -0.119561, -0.117989, -0.116417, -0.114845, -0.113274, -0.111698, -0.110072, -0.108446, -0.106820, -0.105194, -0.103568, -0.101942, -0.100316, -0.098690, -0.097064, -0.095438, -0.093809, -0.092180, -0.090550, -0.088921, -0.087291, -0.085662, -0.084032, -0.082403, -0.080773, -0.079144, -0.077546, -0.075959, -0.074372, -0.072785, -0.071198, -0.069611, -0.068024, -0.066437, -0.064850, -0.063268, -0.061761, -0.060254, -0.058748, -0.057241, -0.055735, -0.054228, -0.052722, -0.051215, -0.049709, -0.048298, -0.046915, -0.045531, -0.044148, -0.042764, -0.041380, -0.039997, -0.038613, -0.037230, -0.035986, -0.034747, -0.033507, -0.032268, -0.031029, -0.029789, -0.028550, -0.027310, -0.026179, -0.025103, -0.024027, -0.022951, -0.021875, -0.020798, -0.019722, -0.018646, -0.017719, -0.016812, -0.015906, -0.014999, -0.014093, -0.013186, -0.012280, -0.011490, -0.010765, -0.010040, -0.009316, -0.008591, -0.007866, -0.007141, -0.006584, -0.006028, -0.005472, -0.004916, -0.004360, -0.003804, -0.003410, -0.003017, -0.002625, -0.002233, -0.001840, -0.001542, -0.001286, -0.001030, -0.000774, -0.000541, -0.000410, -0.000279, -0.000148, -0.000072, -0.000036, 0.000000], - [0.000000, -0.003896, -0.007794, -0.011686, -0.015574, -0.019462, -0.023345, -0.027217, -0.031086, -0.034947, -0.038802, -0.042626, -0.046444, -0.050238, -0.054009, -0.057720, -0.061406, -0.065011, -0.068615, -0.072035, -0.075446, -0.078709, -0.081790, -0.084872, -0.087704, -0.090369, -0.093035, -0.095368, -0.097214, -0.099060, -0.100906, -0.101989, -0.102964, -0.103939, -0.104914, -0.105335, -0.105714, -0.106094, -0.106474, -0.107069, -0.107820, -0.108570, -0.109321, -0.110071, -0.110713, -0.111326, -0.111938, -0.112550, -0.113163, -0.113641, -0.114032, -0.114423, -0.114814, -0.115205, -0.115595, -0.115822, -0.116050, -0.116277, -0.116505, -0.116732, -0.116960, -0.116991, -0.117021, -0.117052, -0.117082, -0.117112, -0.117142, -0.117070, -0.116945, -0.116820, -0.116695, -0.116570, -0.116444, -0.116319, -0.116069, -0.115804, -0.115539, -0.115274, -0.115009, -0.114743, -0.114478, -0.114121, -0.113720, -0.113318, -0.112917, -0.112516, -0.112114, -0.111713, -0.111312, -0.110791, -0.110269, -0.109748, -0.109226, -0.108704, -0.108183, -0.107661, -0.107140, -0.106545, -0.105933, -0.105321, -0.104709, -0.104096, -0.103484, -0.102872, -0.102260, -0.101643, -0.100944, -0.100245, -0.099546, -0.098846, -0.098147, -0.097448, -0.096749, -0.096050, -0.095351, -0.094604, -0.093838, -0.093073, -0.092308, -0.091542, -0.090777, -0.090012, -0.089246, -0.088481, -0.087716, -0.086909, -0.086088, -0.085266, -0.084445, -0.083623, -0.082802, -0.081980, -0.081159, -0.080337, -0.079516, -0.078688, -0.077828, -0.076968, -0.076109, -0.075249, -0.074389, -0.073529, -0.072669, -0.071810, -0.070950, -0.070090, -0.069215, -0.068328, -0.067441, -0.066554, -0.065667, -0.064781, -0.063894, -0.063007, -0.062120, -0.061233, -0.060346, -0.059456, -0.058566, -0.057676, -0.056786, -0.055896, -0.055006, -0.054116, -0.053226, -0.052336, -0.051447, -0.050570, -0.049697, -0.048824, -0.047950, -0.047077, -0.046204, -0.045331, -0.044458, -0.043585, -0.042712, -0.041861, -0.041019, -0.040176, -0.039333, -0.038490, -0.037647, -0.036804, -0.035962, -0.035119, -0.034279, -0.033476, -0.032674, -0.031871, -0.031069, -0.030266, -0.029463, -0.028661, -0.027858, -0.027056, -0.026307, -0.025573, -0.024839, -0.024105, -0.023371, -0.022638, -0.021904, -0.021170, -0.020436, -0.019767, -0.019101, -0.018435, -0.017768, -0.017102, -0.016435, -0.015769, -0.015102, -0.014491, -0.013909, -0.013326, -0.012744, -0.012161, -0.011579, -0.010996, -0.010414, -0.009906, -0.009408, -0.008910, -0.008412, -0.007914, -0.007417, -0.006919, -0.006483, -0.006081, -0.005679, -0.005277, -0.004875, -0.004473, -0.004071, -0.003755, -0.003438, -0.003122, -0.002806, -0.002490, -0.002174, -0.001953, -0.001733, -0.001512, -0.001292, -0.001072, -0.000900, -0.000750, -0.000601, -0.000451, -0.000316, -0.000241, -0.000165, -0.000090, -0.000045, -0.000023, 0.000000], - [0.000000, -0.003245, -0.006451, -0.009562, -0.012604, -0.015620, -0.018545, -0.021305, -0.024020, -0.026613, -0.029128, -0.031179, -0.033102, -0.034352, -0.035460, -0.036218, -0.036875, -0.037210, -0.037546, -0.037927, -0.038310, -0.038883, -0.039689, -0.040494, -0.041371, -0.042295, -0.043219, -0.044099, -0.044914, -0.045729, -0.046543, -0.047334, -0.048121, -0.048909, -0.049696, -0.050409, -0.051117, -0.051824, -0.052532, -0.053184, -0.053796, -0.054408, -0.055020, -0.055632, -0.056188, -0.056729, -0.057271, -0.057812, -0.058353, -0.058826, -0.059254, -0.059683, -0.060111, -0.060540, -0.060967, -0.061309, -0.061650, -0.061992, -0.062333, -0.062675, -0.063016, -0.063236, -0.063455, -0.063673, -0.063892, -0.064110, -0.064329, -0.064479, -0.064594, -0.064708, -0.064823, -0.064937, -0.065051, -0.065166, -0.065188, -0.065199, -0.065210, -0.065221, -0.065232, -0.065243, -0.065254, -0.065196, -0.065105, -0.065014, -0.064923, -0.064833, -0.064742, -0.064651, -0.064560, -0.064371, -0.064181, -0.063992, -0.063802, -0.063612, -0.063423, -0.063233, -0.063043, -0.062789, -0.062520, -0.062250, -0.061981, -0.061712, -0.061442, -0.061173, -0.060903, -0.060629, -0.060277, -0.059925, -0.059573, -0.059221, -0.058870, -0.058518, -0.058166, -0.057814, -0.057462, -0.057064, -0.056648, -0.056232, -0.055816, -0.055400, -0.054984, -0.054568, -0.054152, -0.053736, -0.053320, -0.052863, -0.052392, -0.051922, -0.051451, -0.050980, -0.050509, -0.050038, -0.049568, -0.049097, -0.048626, -0.048148, -0.047635, -0.047122, -0.046608, -0.046095, -0.045582, -0.045068, -0.044555, -0.044042, -0.043529, -0.043015, -0.042489, -0.041953, -0.041418, -0.040882, -0.040346, -0.039810, -0.039274, -0.038738, -0.038202, -0.037666, -0.037130, -0.036584, -0.036039, -0.035494, -0.034948, -0.034403, -0.033858, -0.033312, -0.032767, -0.032222, -0.031676, -0.031135, -0.030594, -0.030053, -0.029512, -0.028972, -0.028431, -0.027890, -0.027349, -0.026809, -0.026268, -0.025741, -0.025218, -0.024695, -0.024173, -0.023650, -0.023127, -0.022604, -0.022082, -0.021559, -0.021038, -0.020543, -0.020047, -0.019552, -0.019057, -0.018562, -0.018066, -0.017571, -0.017076, -0.016580, -0.016117, -0.015661, -0.015206, -0.014751, -0.014296, -0.013841, -0.013386, -0.012931, -0.012476, -0.012068, -0.011661, -0.011255, -0.010848, -0.010441, -0.010035, -0.009628, -0.009222, -0.008848, -0.008491, -0.008134, -0.007776, -0.007419, -0.007062, -0.006705, -0.006348, -0.006035, -0.005729, -0.005423, -0.005116, -0.004810, -0.004503, -0.004197, -0.003931, -0.003687, -0.003444, -0.003200, -0.002957, -0.002713, -0.002469, -0.002280, -0.002092, -0.001903, -0.001714, -0.001526, -0.001337, -0.001202, -0.001067, -0.000933, -0.000798, -0.000664, -0.000555, -0.000457, -0.000359, -0.000262, -0.000174, -0.000132, -0.000090, -0.000047, -0.000023, -0.000011, 0.000000], - [0.000000, 0.003733, 0.006885, 0.009623, 0.011999, 0.013697, 0.014974, 0.015479, 0.015753, 0.015382, 0.015074, 0.015142, 0.015300, 0.015928, 0.016523, 0.017035, 0.017575, 0.018207, 0.018839, 0.019385, 0.019926, 0.020457, 0.020973, 0.021490, 0.022018, 0.022555, 0.023091, 0.023617, 0.024128, 0.024639, 0.025149, 0.025657, 0.026163, 0.026670, 0.027177, 0.027654, 0.028129, 0.028604, 0.029079, 0.029548, 0.030014, 0.030480, 0.030946, 0.031412, 0.031837, 0.032250, 0.032663, 0.033077, 0.033490, 0.033884, 0.034267, 0.034649, 0.035031, 0.035414, 0.035795, 0.036135, 0.036474, 0.036813, 0.037152, 0.037491, 0.037830, 0.038118, 0.038406, 0.038694, 0.038982, 0.039270, 0.039557, 0.039805, 0.040033, 0.040260, 0.040487, 0.040714, 0.040941, 0.041168, 0.041329, 0.041483, 0.041637, 0.041790, 0.041944, 0.042097, 0.042251, 0.042362, 0.042453, 0.042544, 0.042635, 0.042727, 0.042818, 0.042909, 0.043000, 0.043004, 0.043007, 0.043010, 0.043013, 0.043017, 0.043020, 0.043023, 0.043027, 0.042961, 0.042879, 0.042797, 0.042716, 0.042634, 0.042552, 0.042470, 0.042388, 0.042302, 0.042144, 0.041986, 0.041828, 0.041670, 0.041512, 0.041354, 0.041196, 0.041039, 0.040881, 0.040665, 0.040428, 0.040191, 0.039954, 0.039717, 0.039480, 0.039243, 0.039005, 0.038768, 0.038531, 0.038245, 0.037941, 0.037637, 0.037333, 0.037030, 0.036726, 0.036422, 0.036118, 0.035814, 0.035510, 0.035198, 0.034841, 0.034484, 0.034127, 0.033770, 0.033413, 0.033055, 0.032698, 0.032341, 0.031984, 0.031627, 0.031251, 0.030860, 0.030469, 0.030078, 0.029686, 0.029295, 0.028904, 0.028513, 0.028122, 0.027731, 0.027339, 0.026936, 0.026534, 0.026132, 0.025729, 0.025327, 0.024925, 0.024522, 0.024120, 0.023717, 0.023315, 0.022911, 0.022506, 0.022101, 0.021696, 0.021291, 0.020886, 0.020481, 0.020076, 0.019671, 0.019266, 0.018872, 0.018481, 0.018090, 0.017700, 0.017309, 0.016919, 0.016528, 0.016137, 0.015747, 0.015358, 0.014991, 0.014624, 0.014257, 0.013890, 0.013523, 0.013156, 0.012789, 0.012423, 0.012056, 0.011713, 0.011377, 0.011041, 0.010705, 0.010370, 0.010034, 0.009698, 0.009362, 0.009026, 0.008726, 0.008427, 0.008128, 0.007830, 0.007531, 0.007232, 0.006933, 0.006634, 0.006361, 0.006101, 0.005841, 0.005580, 0.005320, 0.005060, 0.004800, 0.004540, 0.004318, 0.004101, 0.003884, 0.003668, 0.003451, 0.003235, 0.003018, 0.002826, 0.002648, 0.002469, 0.002290, 0.002112, 0.001933, 0.001755, 0.001621, 0.001487, 0.001353, 0.001219, 0.001085, 0.000951, 0.000849, 0.000749, 0.000648, 0.000547, 0.000446, 0.000373, 0.000313, 0.000253, 0.000193, 0.000138, 0.000106, 0.000075, 0.000043, 0.000023, 0.000011, 0.000000], - [0.000000, 0.009208, 0.016334, 0.021551, 0.025264, 0.026740, 0.027861, 0.028333, 0.028707, 0.028808, 0.028974, 0.029541, 0.030206, 0.031393, 0.032549, 0.033632, 0.034735, 0.035905, 0.037075, 0.038197, 0.039317, 0.040428, 0.041528, 0.042628, 0.043718, 0.044802, 0.045887, 0.046964, 0.048033, 0.049102, 0.050170, 0.051216, 0.052258, 0.053300, 0.054342, 0.055360, 0.056375, 0.057391, 0.058407, 0.059397, 0.060370, 0.061342, 0.062315, 0.063287, 0.064219, 0.065139, 0.066059, 0.066979, 0.067900, 0.068793, 0.069668, 0.070544, 0.071419, 0.072295, 0.073169, 0.073942, 0.074715, 0.075488, 0.076261, 0.077035, 0.077808, 0.078506, 0.079203, 0.079900, 0.080598, 0.081295, 0.081993, 0.082610, 0.083185, 0.083760, 0.084335, 0.084910, 0.085485, 0.086060, 0.086515, 0.086956, 0.087396, 0.087836, 0.088276, 0.088717, 0.089157, 0.089497, 0.089789, 0.090081, 0.090373, 0.090665, 0.090957, 0.091249, 0.091541, 0.091651, 0.091761, 0.091871, 0.091980, 0.092090, 0.092200, 0.092310, 0.092419, 0.092373, 0.092290, 0.092206, 0.092122, 0.092039, 0.091955, 0.091872, 0.091788, 0.091693, 0.091414, 0.091134, 0.090854, 0.090575, 0.090295, 0.090016, 0.089736, 0.089456, 0.089177, 0.088761, 0.088293, 0.087825, 0.087356, 0.086888, 0.086420, 0.085952, 0.085484, 0.085016, 0.084547, 0.083951, 0.083309, 0.082666, 0.082024, 0.081382, 0.080739, 0.080097, 0.079454, 0.078812, 0.078170, 0.077506, 0.076729, 0.075953, 0.075177, 0.074400, 0.073624, 0.072847, 0.072071, 0.071295, 0.070518, 0.069742, 0.068918, 0.068057, 0.067196, 0.066335, 0.065474, 0.064612, 0.063751, 0.062890, 0.062029, 0.061168, 0.060304, 0.059402, 0.058501, 0.057600, 0.056699, 0.055798, 0.054897, 0.053995, 0.053094, 0.052193, 0.051292, 0.050390, 0.049487, 0.048584, 0.047681, 0.046779, 0.045876, 0.044973, 0.044070, 0.043167, 0.042265, 0.041387, 0.040518, 0.039649, 0.038780, 0.037910, 0.037041, 0.036172, 0.035303, 0.034433, 0.033568, 0.032758, 0.031948, 0.031139, 0.030329, 0.029519, 0.028710, 0.027900, 0.027090, 0.026280, 0.025526, 0.024786, 0.024047, 0.023308, 0.022568, 0.021829, 0.021090, 0.020350, 0.019611, 0.018953, 0.018297, 0.017641, 0.016985, 0.016330, 0.015674, 0.015018, 0.014362, 0.013769, 0.013206, 0.012644, 0.012082, 0.011520, 0.010958, 0.010396, 0.009833, 0.009349, 0.008876, 0.008402, 0.007929, 0.007455, 0.006982, 0.006509, 0.006094, 0.005712, 0.005330, 0.004948, 0.004566, 0.004184, 0.003802, 0.003509, 0.003217, 0.002925, 0.002633, 0.002341, 0.002049, 0.001834, 0.001621, 0.001407, 0.001193, 0.000980, 0.000822, 0.000691, 0.000559, 0.000427, 0.000307, 0.000234, 0.000162, 0.000090, 0.000046, 0.000023, 0.000000], - [0.000000, 0.016424, 0.027008, 0.032906, 0.036341, 0.038091, 0.039557, 0.040504, 0.041346, 0.041896, 0.042523, 0.043617, 0.044814, 0.046556, 0.048276, 0.049941, 0.051629, 0.053393, 0.055157, 0.056839, 0.058518, 0.060201, 0.061890, 0.063580, 0.065239, 0.066879, 0.068519, 0.070164, 0.071818, 0.073472, 0.075127, 0.076752, 0.078373, 0.079994, 0.081615, 0.083234, 0.084852, 0.086471, 0.088089, 0.089686, 0.091267, 0.092848, 0.094429, 0.096010, 0.097533, 0.099041, 0.100548, 0.102055, 0.103562, 0.105039, 0.106496, 0.107952, 0.109409, 0.110866, 0.112321, 0.113668, 0.115015, 0.116362, 0.117709, 0.119057, 0.120404, 0.121643, 0.122882, 0.124121, 0.125360, 0.126599, 0.127838, 0.128971, 0.130047, 0.131123, 0.132199, 0.133276, 0.134352, 0.135428, 0.136325, 0.137200, 0.138075, 0.138950, 0.139825, 0.140700, 0.141575, 0.142288, 0.142924, 0.143560, 0.144197, 0.144833, 0.145469, 0.146105, 0.146741, 0.147086, 0.147430, 0.147774, 0.148117, 0.148461, 0.148804, 0.149148, 0.149492, 0.149568, 0.149580, 0.149592, 0.149604, 0.149616, 0.149628, 0.149640, 0.149652, 0.149643, 0.149297, 0.148951, 0.148605, 0.148259, 0.147913, 0.147567, 0.147221, 0.146875, 0.146529, 0.145923, 0.145218, 0.144513, 0.143807, 0.143102, 0.142397, 0.141692, 0.140986, 0.140281, 0.139576, 0.138635, 0.137610, 0.136584, 0.135559, 0.134534, 0.133508, 0.132483, 0.131457, 0.130432, 0.129407, 0.128340, 0.127060, 0.125779, 0.124498, 0.123217, 0.121937, 0.120656, 0.119375, 0.118094, 0.116814, 0.115533, 0.114162, 0.112719, 0.111277, 0.109834, 0.108391, 0.106948, 0.105506, 0.104063, 0.102620, 0.101177, 0.099729, 0.098216, 0.096703, 0.095190, 0.093677, 0.092163, 0.090650, 0.089137, 0.087624, 0.086111, 0.084597, 0.083086, 0.081575, 0.080065, 0.078554, 0.077043, 0.075532, 0.074022, 0.072511, 0.071000, 0.069490, 0.068024, 0.066574, 0.065123, 0.063672, 0.062222, 0.060771, 0.059321, 0.057870, 0.056419, 0.054975, 0.053631, 0.052286, 0.050941, 0.049597, 0.048252, 0.046907, 0.045563, 0.044218, 0.042874, 0.041628, 0.040410, 0.039193, 0.037975, 0.036757, 0.035540, 0.034322, 0.033104, 0.031886, 0.030809, 0.029736, 0.028662, 0.027589, 0.026516, 0.025443, 0.024369, 0.023296, 0.022324, 0.021403, 0.020482, 0.019561, 0.018641, 0.017720, 0.016799, 0.015878, 0.015091, 0.014324, 0.013556, 0.012788, 0.012020, 0.011252, 0.010485, 0.009816, 0.009200, 0.008585, 0.007970, 0.007355, 0.006740, 0.006125, 0.005652, 0.005180, 0.004708, 0.004236, 0.003764, 0.003292, 0.002949, 0.002607, 0.002265, 0.001924, 0.001582, 0.001330, 0.001118, 0.000907, 0.000695, 0.000500, 0.000380, 0.000260, 0.000140, 0.000069, 0.000034, 0.000000], - [0.000000, 0.025013, 0.036949, 0.042838, 0.046717, 0.049017, 0.051023, 0.052492, 0.053831, 0.054810, 0.055876, 0.057465, 0.059174, 0.061515, 0.063827, 0.066068, 0.068332, 0.070669, 0.073007, 0.075282, 0.077555, 0.079832, 0.082114, 0.084397, 0.086660, 0.088911, 0.091163, 0.093429, 0.095718, 0.098006, 0.100295, 0.102560, 0.104823, 0.107085, 0.109347, 0.111619, 0.113892, 0.116165, 0.118438, 0.120705, 0.122967, 0.125229, 0.127492, 0.129754, 0.131964, 0.134161, 0.136358, 0.138554, 0.140751, 0.142934, 0.145107, 0.147280, 0.149453, 0.151626, 0.153799, 0.155865, 0.157932, 0.159999, 0.162066, 0.164132, 0.166199, 0.168152, 0.170103, 0.172055, 0.174007, 0.175958, 0.177910, 0.179744, 0.181516, 0.183287, 0.185059, 0.186831, 0.188603, 0.190374, 0.191918, 0.193433, 0.194948, 0.196463, 0.197978, 0.199494, 0.201009, 0.202300, 0.203485, 0.204670, 0.205854, 0.207039, 0.208224, 0.209409, 0.210593, 0.211345, 0.212094, 0.212843, 0.213593, 0.214342, 0.215091, 0.215841, 0.216590, 0.216921, 0.217152, 0.217382, 0.217613, 0.217844, 0.218075, 0.218306, 0.218537, 0.218734, 0.218389, 0.218045, 0.217700, 0.217355, 0.217011, 0.216666, 0.216321, 0.215977, 0.215632, 0.214856, 0.213914, 0.212973, 0.212031, 0.211090, 0.210148, 0.209207, 0.208266, 0.207324, 0.206383, 0.205037, 0.203546, 0.202055, 0.200563, 0.199072, 0.197581, 0.196090, 0.194598, 0.193107, 0.191616, 0.190057, 0.188143, 0.186229, 0.184315, 0.182401, 0.180487, 0.178573, 0.176659, 0.174745, 0.172831, 0.170917, 0.168855, 0.166676, 0.164496, 0.162316, 0.160136, 0.157956, 0.155777, 0.153597, 0.151417, 0.149237, 0.147049, 0.144765, 0.142480, 0.140195, 0.137910, 0.135626, 0.133341, 0.131056, 0.128772, 0.126487, 0.124202, 0.121930, 0.119662, 0.117393, 0.115125, 0.112856, 0.110588, 0.108319, 0.106051, 0.103783, 0.101514, 0.099329, 0.097170, 0.095011, 0.092852, 0.090693, 0.088534, 0.086375, 0.084216, 0.082057, 0.079908, 0.077921, 0.075933, 0.073945, 0.071958, 0.069970, 0.067983, 0.065995, 0.064008, 0.062020, 0.060192, 0.058408, 0.056624, 0.054840, 0.053056, 0.051272, 0.049488, 0.047705, 0.045921, 0.044355, 0.042796, 0.041237, 0.039678, 0.038119, 0.036559, 0.035000, 0.033441, 0.032034, 0.030704, 0.029375, 0.028045, 0.026715, 0.025386, 0.024056, 0.022726, 0.021598, 0.020498, 0.019398, 0.018299, 0.017199, 0.016099, 0.014999, 0.014039, 0.013155, 0.012271, 0.011388, 0.010504, 0.009620, 0.008736, 0.008061, 0.007386, 0.006711, 0.006037, 0.005362, 0.004687, 0.004199, 0.003713, 0.003226, 0.002740, 0.002253, 0.001892, 0.001589, 0.001285, 0.000981, 0.000702, 0.000532, 0.000362, 0.000191, 0.000092, 0.000046, 0.000000], - ], - [ - [0.000000, -0.000071, -0.000200, -0.000235, -0.000293, -0.000455, -0.000599, -0.000710, -0.000810, -0.000879, -0.000962, -0.001118, -0.001254, -0.001285, -0.001372, -0.001597, -0.001824, -0.002054, -0.002285, -0.002534, -0.002783, -0.003057, -0.003360, -0.003664, -0.004024, -0.004422, -0.004821, -0.005246, -0.005710, -0.006174, -0.006637, -0.007191, -0.007758, -0.008324, -0.008890, -0.009557, -0.010232, -0.010907, -0.011581, -0.012338, -0.013153, -0.013968, -0.014783, -0.015598, -0.016560, -0.017562, -0.018564, -0.019566, -0.020568, -0.021673, -0.022846, -0.024019, -0.025192, -0.026365, -0.027540, -0.028933, -0.030326, -0.031720, -0.033113, -0.034507, -0.035900, -0.037518, -0.039138, -0.040758, -0.042378, -0.043997, -0.045617, -0.047383, -0.049224, -0.051066, -0.052908, -0.054750, -0.056592, -0.058434, -0.060469, -0.062528, -0.064588, -0.066647, -0.068706, -0.070765, -0.072825, -0.074998, -0.077226, -0.079454, -0.081682, -0.083910, -0.086138, -0.088366, -0.090593, -0.092945, -0.095297, -0.097649, -0.100002, -0.102354, -0.104706, -0.107058, -0.109410, -0.111792, -0.114181, -0.116570, -0.118959, -0.121348, -0.123737, -0.126127, -0.128516, -0.130900, -0.133205, -0.135510, -0.137815, -0.140121, -0.142426, -0.144731, -0.147036, -0.149341, -0.151646, -0.153810, -0.155920, -0.158030, -0.160140, -0.162250, -0.164360, -0.166470, -0.168580, -0.170690, -0.172800, -0.174685, -0.176489, -0.178293, -0.180097, -0.181901, -0.183705, -0.185509, -0.187312, -0.189116, -0.190920, -0.192661, -0.194070, -0.195480, -0.196889, -0.198298, -0.199708, -0.201117, -0.202526, -0.203936, -0.205345, -0.206754, -0.207929, -0.208916, -0.209902, -0.210889, -0.211875, -0.212862, -0.213849, -0.214835, -0.215822, -0.216809, -0.217761, -0.218302, -0.218843, -0.219385, -0.219926, -0.220468, -0.221009, -0.221550, -0.222092, -0.222633, -0.223175, -0.223373, -0.223477, -0.223581, -0.223685, -0.223790, -0.223894, -0.223998, -0.224102, -0.224206, -0.224311, -0.224079, -0.223739, -0.223399, -0.223059, -0.222719, -0.222379, -0.222039, -0.221699, -0.221359, -0.220991, -0.220197, -0.219404, -0.218610, -0.217817, -0.217023, -0.216229, -0.215436, -0.214642, -0.213849, -0.212686, -0.211419, -0.210153, -0.208886, -0.207620, -0.206353, -0.205087, -0.203820, -0.202554, -0.200796, -0.199022, -0.197249, -0.195476, -0.193703, -0.191929, -0.190156, -0.188383, -0.186241, -0.183909, -0.181578, -0.179246, -0.176915, -0.174583, -0.172252, -0.169920, -0.167052, -0.164108, -0.161163, -0.158218, -0.155273, -0.152329, -0.149384, -0.146004, -0.142384, -0.138765, -0.135145, -0.131526, -0.127906, -0.124287, -0.119928, -0.115565, -0.111202, -0.106840, -0.102477, -0.098114, -0.092973, -0.087825, -0.082676, -0.077527, -0.072378, -0.066647, -0.060652, -0.054657, -0.048662, -0.042520, -0.035744, -0.028969, -0.022193, -0.015000, -0.007499, 0.000000], - [0.000000, -0.000071, -0.000200, -0.000235, -0.000293, -0.000455, -0.000556, -0.000546, -0.000562, -0.000649, -0.000735, -0.000816, -0.000892, -0.000944, -0.001027, -0.001188, -0.001343, -0.001475, -0.001608, -0.001785, -0.001965, -0.002163, -0.002381, -0.002600, -0.002850, -0.003120, -0.003391, -0.003676, -0.003983, -0.004291, -0.004598, -0.004989, -0.005392, -0.005795, -0.006198, -0.006651, -0.007109, -0.007566, -0.008024, -0.008549, -0.009124, -0.009698, -0.010272, -0.010847, -0.011506, -0.012189, -0.012871, -0.013554, -0.014237, -0.014997, -0.015807, -0.016617, -0.017428, -0.018238, -0.019050, -0.020006, -0.020963, -0.021920, -0.022877, -0.023833, -0.024790, -0.025892, -0.026996, -0.028099, -0.029202, -0.030305, -0.031408, -0.032613, -0.033871, -0.035128, -0.036386, -0.037644, -0.038902, -0.040160, -0.041546, -0.042949, -0.044352, -0.045755, -0.047157, -0.048560, -0.049963, -0.051442, -0.052958, -0.054474, -0.055990, -0.057506, -0.059022, -0.060538, -0.062054, -0.063673, -0.065292, -0.066911, -0.068530, -0.070149, -0.071768, -0.073387, -0.075006, -0.076653, -0.078308, -0.079962, -0.081616, -0.083271, -0.084925, -0.086579, -0.088234, -0.089887, -0.091517, -0.093148, -0.094778, -0.096408, -0.098039, -0.099669, -0.101300, -0.102930, -0.104560, -0.106122, -0.107657, -0.109192, -0.110727, -0.112262, -0.113797, -0.115332, -0.116867, -0.118402, -0.119937, -0.121342, -0.122700, -0.124058, -0.125417, -0.126775, -0.128133, -0.129492, -0.130850, -0.132208, -0.133566, -0.134886, -0.136005, -0.137123, -0.138242, -0.139361, -0.140479, -0.141598, -0.142716, -0.143835, -0.144953, -0.146072, -0.147033, -0.147870, -0.148706, -0.149542, -0.150379, -0.151215, -0.152051, -0.152888, -0.153724, -0.154560, -0.155373, -0.155900, -0.156427, -0.156954, -0.157482, -0.158009, -0.158536, -0.159063, -0.159591, -0.160118, -0.160645, -0.160913, -0.161109, -0.161306, -0.161502, -0.161698, -0.161895, -0.162091, -0.162288, -0.162484, -0.162681, -0.162615, -0.162465, -0.162315, -0.162166, -0.162016, -0.161866, -0.161716, -0.161566, -0.161416, -0.161244, -0.160734, -0.160225, -0.159715, -0.159205, -0.158696, -0.158186, -0.157676, -0.157167, -0.156657, -0.155846, -0.154951, -0.154056, -0.153161, -0.152266, -0.151371, -0.150476, -0.149581, -0.148686, -0.147397, -0.146095, -0.144794, -0.143493, -0.142192, -0.140890, -0.139589, -0.138288, -0.136696, -0.134955, -0.133214, -0.131473, -0.129731, -0.127990, -0.126249, -0.124508, -0.122358, -0.120149, -0.117940, -0.115731, -0.113523, -0.111314, -0.109105, -0.106572, -0.103860, -0.101149, -0.098438, -0.095726, -0.093015, -0.090303, -0.087065, -0.083824, -0.080584, -0.077343, -0.074102, -0.070861, -0.067083, -0.063300, -0.059516, -0.055733, -0.051949, -0.047772, -0.043416, -0.039060, -0.034704, -0.030257, -0.025414, -0.020571, -0.015729, -0.010617, -0.005308, 0.000000], - [0.000000, -0.000071, -0.000200, -0.000235, -0.000262, -0.000282, -0.000288, -0.000268, -0.000281, -0.000384, -0.000475, -0.000498, -0.000529, -0.000602, -0.000680, -0.000772, -0.000851, -0.000891, -0.000930, -0.001038, -0.001149, -0.001270, -0.001403, -0.001537, -0.001702, -0.001887, -0.002072, -0.002263, -0.002465, -0.002666, -0.002867, -0.003103, -0.003344, -0.003585, -0.003826, -0.004107, -0.004390, -0.004674, -0.004958, -0.005280, -0.005629, -0.005978, -0.006327, -0.006676, -0.007079, -0.007498, -0.007916, -0.008334, -0.008752, -0.009219, -0.009717, -0.010215, -0.010714, -0.011212, -0.011711, -0.012287, -0.012864, -0.013440, -0.014016, -0.014592, -0.015168, -0.015840, -0.016513, -0.017185, -0.017858, -0.018530, -0.019203, -0.019937, -0.020703, -0.021470, -0.022237, -0.023003, -0.023770, -0.024537, -0.025378, -0.026230, -0.027081, -0.027932, -0.028783, -0.029634, -0.030485, -0.031388, -0.032315, -0.033241, -0.034168, -0.035095, -0.036022, -0.036948, -0.037875, -0.038874, -0.039873, -0.040873, -0.041872, -0.042871, -0.043870, -0.044870, -0.045869, -0.046896, -0.047930, -0.048965, -0.049999, -0.051033, -0.052067, -0.053101, -0.054135, -0.055169, -0.056203, -0.057238, -0.058272, -0.059306, -0.060340, -0.061374, -0.062408, -0.063443, -0.064477, -0.065483, -0.066478, -0.067473, -0.068468, -0.069464, -0.070459, -0.071454, -0.072449, -0.073444, -0.074440, -0.075371, -0.076280, -0.077188, -0.078097, -0.079006, -0.079914, -0.080823, -0.081732, -0.082641, -0.083549, -0.084436, -0.085211, -0.085985, -0.086759, -0.087534, -0.088308, -0.089082, -0.089856, -0.090631, -0.091405, -0.092179, -0.092858, -0.093459, -0.094061, -0.094662, -0.095264, -0.095866, -0.096467, -0.097069, -0.097670, -0.098272, -0.098859, -0.099267, -0.099676, -0.100084, -0.100493, -0.100901, -0.101310, -0.101718, -0.102127, -0.102535, -0.102944, -0.103183, -0.103377, -0.103570, -0.103763, -0.103957, -0.104150, -0.104343, -0.104537, -0.104730, -0.104923, -0.104933, -0.104884, -0.104835, -0.104787, -0.104738, -0.104689, -0.104640, -0.104591, -0.104542, -0.104477, -0.104176, -0.103874, -0.103573, -0.103271, -0.102969, -0.102668, -0.102366, -0.102064, -0.101763, -0.101250, -0.100679, -0.100108, -0.099536, -0.098965, -0.098394, -0.097822, -0.097251, -0.096680, -0.095835, -0.094983, -0.094130, -0.093278, -0.092425, -0.091573, -0.090720, -0.089867, -0.088813, -0.087656, -0.086499, -0.085342, -0.084185, -0.083028, -0.081871, -0.080714, -0.079281, -0.077808, -0.076336, -0.074863, -0.073390, -0.071917, -0.070445, -0.068766, -0.066974, -0.065182, -0.063389, -0.061597, -0.059805, -0.058013, -0.055884, -0.053753, -0.051623, -0.049492, -0.047361, -0.045231, -0.042779, -0.040323, -0.037868, -0.035412, -0.032957, -0.030269, -0.027474, -0.024680, -0.021886, -0.019040, -0.015973, -0.012905, -0.009838, -0.006628, -0.003314, 0.000000], - [0.000000, -0.000071, -0.000067, 0.000000, -0.000034, -0.000192, -0.000245, -0.000104, -0.000027, -0.000130, -0.000226, -0.000285, -0.000334, -0.000330, -0.000338, -0.000378, -0.000407, -0.000401, -0.000395, -0.000475, -0.000559, -0.000627, -0.000675, -0.000723, -0.000795, -0.000883, -0.000971, -0.001062, -0.001157, -0.001251, -0.001346, -0.001450, -0.001555, -0.001660, -0.001765, -0.001892, -0.002021, -0.002150, -0.002278, -0.002425, -0.002584, -0.002743, -0.002902, -0.003061, -0.003250, -0.003447, -0.003645, -0.003842, -0.004039, -0.004252, -0.004475, -0.004697, -0.004920, -0.005142, -0.005366, -0.005633, -0.005901, -0.006169, -0.006437, -0.006705, -0.006973, -0.007278, -0.007583, -0.007889, -0.008194, -0.008499, -0.008805, -0.009136, -0.009481, -0.009825, -0.010170, -0.010515, -0.010860, -0.011205, -0.011595, -0.011990, -0.012386, -0.012782, -0.013177, -0.013573, -0.013969, -0.014383, -0.014807, -0.015231, -0.015654, -0.016078, -0.016502, -0.016926, -0.017349, -0.017813, -0.018278, -0.018742, -0.019206, -0.019671, -0.020135, -0.020599, -0.021063, -0.021543, -0.022027, -0.022510, -0.022994, -0.023478, -0.023961, -0.024445, -0.024928, -0.025412, -0.025906, -0.026399, -0.026892, -0.027385, -0.027879, -0.028372, -0.028865, -0.029358, -0.029852, -0.030339, -0.030823, -0.031307, -0.031792, -0.032276, -0.032760, -0.033245, -0.033729, -0.034214, -0.034698, -0.035159, -0.035611, -0.036063, -0.036516, -0.036968, -0.037420, -0.037873, -0.038325, -0.038777, -0.039230, -0.039673, -0.040067, -0.040461, -0.040856, -0.041250, -0.041644, -0.042039, -0.042433, -0.042827, -0.043222, -0.043616, -0.043968, -0.044287, -0.044605, -0.044923, -0.045241, -0.045560, -0.045878, -0.046196, -0.046515, -0.046833, -0.047144, -0.047369, -0.047595, -0.047821, -0.048046, -0.048272, -0.048497, -0.048723, -0.048948, -0.049174, -0.049399, -0.049541, -0.049658, -0.049776, -0.049894, -0.050012, -0.050130, -0.050248, -0.050366, -0.050484, -0.050602, -0.050629, -0.050627, -0.050624, -0.050622, -0.050620, -0.050618, -0.050616, -0.050614, -0.050611, -0.050601, -0.050463, -0.050325, -0.050187, -0.050049, -0.049911, -0.049774, -0.049636, -0.049498, -0.049360, -0.049114, -0.048838, -0.048561, -0.048285, -0.048009, -0.047733, -0.047457, -0.047180, -0.046904, -0.046486, -0.046064, -0.045642, -0.045220, -0.044797, -0.044375, -0.043953, -0.043530, -0.043006, -0.042430, -0.041854, -0.041278, -0.040702, -0.040125, -0.039549, -0.038973, -0.038261, -0.037530, -0.036799, -0.036068, -0.035337, -0.034606, -0.033876, -0.033046, -0.032162, -0.031278, -0.030394, -0.029510, -0.028626, -0.027742, -0.026702, -0.025662, -0.024622, -0.023582, -0.022542, -0.021501, -0.020316, -0.019129, -0.017942, -0.016754, -0.015567, -0.014280, -0.012947, -0.011614, -0.010281, -0.008927, -0.007484, -0.006041, -0.004599, -0.003095, -0.001547, 0.000000], - [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000043, 0.000166, 0.000256, 0.000255, 0.000252, 0.000231, 0.000235, 0.000373, 0.000470, 0.000463, 0.000477, 0.000559, 0.000641, 0.000711, 0.000781, 0.000858, 0.000943, 0.001029, 0.001133, 0.001250, 0.001368, 0.001484, 0.001599, 0.001714, 0.001830, 0.001979, 0.002132, 0.002286, 0.002440, 0.002629, 0.002822, 0.003014, 0.003206, 0.003414, 0.003633, 0.003851, 0.004070, 0.004289, 0.004536, 0.004792, 0.005048, 0.005304, 0.005559, 0.005847, 0.006155, 0.006463, 0.006772, 0.007080, 0.007389, 0.007748, 0.008108, 0.008467, 0.008827, 0.009187, 0.009546, 0.009966, 0.010387, 0.010808, 0.011228, 0.011649, 0.012069, 0.012530, 0.013013, 0.013496, 0.013978, 0.014461, 0.014943, 0.015426, 0.015957, 0.016494, 0.017031, 0.017569, 0.018106, 0.018643, 0.019180, 0.019766, 0.020375, 0.020984, 0.021593, 0.022202, 0.022811, 0.023420, 0.024029, 0.024692, 0.025355, 0.026018, 0.026682, 0.027345, 0.028008, 0.028671, 0.029335, 0.030037, 0.030749, 0.031461, 0.032172, 0.032884, 0.033596, 0.034307, 0.035019, 0.035733, 0.036480, 0.037228, 0.037976, 0.038723, 0.039471, 0.040218, 0.040966, 0.041713, 0.042461, 0.043221, 0.043986, 0.044752, 0.045517, 0.046282, 0.047047, 0.047813, 0.048578, 0.049343, 0.050108, 0.050863, 0.051614, 0.052364, 0.053115, 0.053866, 0.054616, 0.055367, 0.056118, 0.056869, 0.057619, 0.058361, 0.059055, 0.059749, 0.060443, 0.061138, 0.061832, 0.062526, 0.063220, 0.063915, 0.064609, 0.065303, 0.065945, 0.066545, 0.067145, 0.067745, 0.068345, 0.068945, 0.069545, 0.070145, 0.070745, 0.071345, 0.071934, 0.072388, 0.072842, 0.073295, 0.073749, 0.074203, 0.074657, 0.075111, 0.075564, 0.076018, 0.076472, 0.076782, 0.077053, 0.077324, 0.077595, 0.077866, 0.078137, 0.078408, 0.078679, 0.078950, 0.079220, 0.079325, 0.079376, 0.079426, 0.079477, 0.079528, 0.079579, 0.079630, 0.079680, 0.079731, 0.079767, 0.079572, 0.079377, 0.079181, 0.078986, 0.078791, 0.078596, 0.078401, 0.078206, 0.078010, 0.077612, 0.077157, 0.076702, 0.076247, 0.075792, 0.075336, 0.074881, 0.074426, 0.073971, 0.073262, 0.072545, 0.071828, 0.071111, 0.070394, 0.069677, 0.068960, 0.068242, 0.067354, 0.066377, 0.065401, 0.064424, 0.063448, 0.062471, 0.061495, 0.060518, 0.059328, 0.058107, 0.056887, 0.055666, 0.054446, 0.053225, 0.052004, 0.050635, 0.049183, 0.047732, 0.046281, 0.044829, 0.043378, 0.041927, 0.040273, 0.038619, 0.036964, 0.035310, 0.033655, 0.032001, 0.030165, 0.028327, 0.026490, 0.024652, 0.022814, 0.020876, 0.018893, 0.016909, 0.014926, 0.012917, 0.010800, 0.008684, 0.006567, 0.004401, 0.002200, 0.000000], - [0.000000, 0.000000, 0.000000, 0.000116, 0.000261, 0.000266, 0.000316, 0.000448, 0.000536, 0.000503, 0.000469, 0.000429, 0.000415, 0.000533, 0.000639, 0.000717, 0.000803, 0.000918, 0.001034, 0.001185, 0.001339, 0.001483, 0.001615, 0.001748, 0.001909, 0.002090, 0.002270, 0.002452, 0.002636, 0.002821, 0.003005, 0.003238, 0.003477, 0.003717, 0.003957, 0.004272, 0.004592, 0.004912, 0.005233, 0.005576, 0.005935, 0.006293, 0.006652, 0.007011, 0.007417, 0.007836, 0.008255, 0.008674, 0.009093, 0.009564, 0.010069, 0.010573, 0.011078, 0.011583, 0.012088, 0.012669, 0.013249, 0.013829, 0.014409, 0.014989, 0.015570, 0.016260, 0.016950, 0.017641, 0.018332, 0.019023, 0.019713, 0.020466, 0.021253, 0.022039, 0.022825, 0.023611, 0.024397, 0.025183, 0.026060, 0.026949, 0.027837, 0.028726, 0.029615, 0.030503, 0.031392, 0.032356, 0.033356, 0.034356, 0.035356, 0.036355, 0.037355, 0.038355, 0.039355, 0.040455, 0.041556, 0.042657, 0.043758, 0.044859, 0.045960, 0.047061, 0.048161, 0.049341, 0.050540, 0.051738, 0.052937, 0.054135, 0.055334, 0.056532, 0.057731, 0.058934, 0.060213, 0.061492, 0.062771, 0.064050, 0.065329, 0.066608, 0.067887, 0.069166, 0.070445, 0.071756, 0.073079, 0.074402, 0.075725, 0.077048, 0.078371, 0.079694, 0.081017, 0.082340, 0.083663, 0.084991, 0.086321, 0.087651, 0.088981, 0.090311, 0.091641, 0.092971, 0.094301, 0.095631, 0.096961, 0.098280, 0.099536, 0.100792, 0.102048, 0.103305, 0.104561, 0.105817, 0.107074, 0.108330, 0.109586, 0.110842, 0.112015, 0.113122, 0.114228, 0.115335, 0.116441, 0.117548, 0.118654, 0.119761, 0.120867, 0.121974, 0.123061, 0.123922, 0.124784, 0.125645, 0.126506, 0.127368, 0.128229, 0.129090, 0.129952, 0.130813, 0.131674, 0.132273, 0.132801, 0.133328, 0.133855, 0.134382, 0.134909, 0.135437, 0.135964, 0.136491, 0.137018, 0.137241, 0.137366, 0.137491, 0.137616, 0.137741, 0.137866, 0.137990, 0.138115, 0.138240, 0.138337, 0.138001, 0.137666, 0.137330, 0.136995, 0.136659, 0.136323, 0.135988, 0.135652, 0.135317, 0.134606, 0.133791, 0.132976, 0.132160, 0.131345, 0.130530, 0.129714, 0.128899, 0.128084, 0.126801, 0.125504, 0.124207, 0.122911, 0.121614, 0.120317, 0.119020, 0.117723, 0.116126, 0.114376, 0.112625, 0.110875, 0.109124, 0.107374, 0.105623, 0.103872, 0.101753, 0.099582, 0.097411, 0.095239, 0.093068, 0.090896, 0.088725, 0.086311, 0.083765, 0.081218, 0.078672, 0.076125, 0.073579, 0.071032, 0.068169, 0.065305, 0.062440, 0.059576, 0.056711, 0.053847, 0.050711, 0.047573, 0.044435, 0.041297, 0.038159, 0.034875, 0.031526, 0.028176, 0.024826, 0.021444, 0.017921, 0.014399, 0.010876, 0.007285, 0.003642, 0.000000], - [0.000000, 0.000000, 0.000000, 0.000116, 0.000261, 0.000266, 0.000359, 0.000615, 0.000826, 0.000914, 0.000981, 0.000924, 0.000898, 0.001030, 0.001153, 0.001249, 0.001375, 0.001596, 0.001816, 0.002025, 0.002233, 0.002461, 0.002715, 0.002968, 0.003250, 0.003550, 0.003850, 0.004177, 0.004542, 0.004907, 0.005272, 0.005691, 0.006117, 0.006544, 0.006970, 0.007500, 0.008037, 0.008574, 0.009111, 0.009716, 0.010370, 0.011024, 0.011678, 0.012331, 0.013073, 0.013839, 0.014604, 0.015370, 0.016135, 0.017003, 0.017939, 0.018875, 0.019810, 0.020746, 0.021683, 0.022781, 0.023878, 0.024976, 0.026074, 0.027171, 0.028269, 0.029576, 0.030884, 0.032192, 0.033500, 0.034808, 0.036116, 0.037556, 0.039064, 0.040573, 0.042082, 0.043591, 0.045099, 0.046608, 0.048311, 0.050037, 0.051764, 0.053490, 0.055217, 0.056943, 0.058670, 0.060552, 0.062507, 0.064463, 0.066419, 0.068374, 0.070330, 0.072286, 0.074241, 0.076403, 0.078566, 0.080729, 0.082892, 0.085055, 0.087218, 0.089381, 0.091544, 0.093844, 0.096176, 0.098509, 0.100841, 0.103174, 0.105506, 0.107838, 0.110171, 0.112509, 0.114945, 0.117381, 0.119816, 0.122252, 0.124687, 0.127123, 0.129558, 0.131994, 0.134429, 0.136848, 0.139261, 0.141673, 0.144086, 0.146499, 0.148911, 0.151324, 0.153736, 0.156149, 0.158561, 0.160827, 0.163040, 0.165253, 0.167466, 0.169680, 0.171893, 0.174106, 0.176319, 0.178532, 0.180745, 0.182893, 0.184697, 0.186501, 0.188305, 0.190109, 0.191913, 0.193717, 0.195521, 0.197325, 0.199129, 0.200933, 0.202403, 0.203606, 0.204810, 0.206013, 0.207216, 0.208420, 0.209623, 0.210826, 0.212030, 0.213233, 0.214380, 0.214852, 0.215324, 0.215797, 0.216269, 0.216741, 0.217214, 0.217686, 0.218158, 0.218631, 0.219103, 0.218971, 0.218672, 0.218374, 0.218075, 0.217777, 0.217479, 0.217180, 0.216882, 0.216584, 0.216285, 0.215432, 0.214400, 0.213368, 0.212336, 0.211304, 0.210272, 0.209240, 0.208208, 0.207177, 0.206105, 0.204435, 0.202765, 0.201095, 0.199424, 0.197754, 0.196084, 0.194414, 0.192744, 0.191073, 0.188989, 0.186789, 0.184589, 0.182389, 0.180188, 0.177988, 0.175788, 0.173588, 0.171388, 0.168782, 0.166163, 0.163545, 0.160927, 0.158308, 0.155690, 0.153071, 0.150453, 0.147620, 0.144677, 0.141734, 0.138791, 0.135848, 0.132905, 0.129962, 0.127019, 0.123855, 0.120660, 0.117464, 0.114269, 0.111073, 0.107878, 0.104682, 0.101365, 0.097982, 0.094599, 0.091216, 0.087832, 0.084449, 0.081066, 0.077534, 0.074001, 0.070468, 0.066935, 0.063402, 0.059869, 0.056220, 0.052570, 0.048920, 0.045269, 0.041619, 0.037910, 0.034174, 0.030439, 0.026703, 0.022954, 0.019145, 0.015337, 0.011529, 0.007697, 0.003848, 0.000000], - [0.000000, 0.000000, 0.000125, 0.000228, 0.000293, 0.000443, 0.000634, 0.000899, 0.001109, 0.001164, 0.001202, 0.001141, 0.001121, 0.001314, 0.001494, 0.001642, 0.001818, 0.002085, 0.002351, 0.002575, 0.002797, 0.003071, 0.003409, 0.003747, 0.004100, 0.004463, 0.004827, 0.005230, 0.005691, 0.006153, 0.006614, 0.007157, 0.007710, 0.008264, 0.008818, 0.009477, 0.010144, 0.010811, 0.011478, 0.012241, 0.013074, 0.013906, 0.014739, 0.015572, 0.016516, 0.017490, 0.018464, 0.019438, 0.020412, 0.021520, 0.022715, 0.023911, 0.025107, 0.026302, 0.027500, 0.028906, 0.030311, 0.031717, 0.033123, 0.034529, 0.035934, 0.037616, 0.039299, 0.040982, 0.042665, 0.044349, 0.046032, 0.047894, 0.049851, 0.051807, 0.053764, 0.055720, 0.057677, 0.059633, 0.061852, 0.064104, 0.066356, 0.068608, 0.070860, 0.073112, 0.075364, 0.077831, 0.080401, 0.082970, 0.085540, 0.088110, 0.090679, 0.093249, 0.095818, 0.098683, 0.101550, 0.104416, 0.107283, 0.110149, 0.113016, 0.115882, 0.118749, 0.121821, 0.124942, 0.128063, 0.131185, 0.134306, 0.137427, 0.140548, 0.143670, 0.146800, 0.150080, 0.153359, 0.156639, 0.159919, 0.163198, 0.166478, 0.169758, 0.173038, 0.176317, 0.179575, 0.182824, 0.186074, 0.189323, 0.192573, 0.195822, 0.199072, 0.202321, 0.205571, 0.208820, 0.211836, 0.214768, 0.217699, 0.220631, 0.223563, 0.226495, 0.229426, 0.232358, 0.235290, 0.238222, 0.241045, 0.243296, 0.245546, 0.247797, 0.250048, 0.252299, 0.254550, 0.256801, 0.259052, 0.261303, 0.263553, 0.265259, 0.266529, 0.267799, 0.269068, 0.270338, 0.271608, 0.272878, 0.274148, 0.275417, 0.276687, 0.277867, 0.277989, 0.278110, 0.278231, 0.278353, 0.278474, 0.278595, 0.278717, 0.278838, 0.278959, 0.279081, 0.278317, 0.277310, 0.276304, 0.275297, 0.274291, 0.273284, 0.272278, 0.271272, 0.270265, 0.269259, 0.267528, 0.265565, 0.263601, 0.261638, 0.259675, 0.257712, 0.255748, 0.253785, 0.251822, 0.249814, 0.247126, 0.244439, 0.241752, 0.239064, 0.236377, 0.233689, 0.231002, 0.228314, 0.225627, 0.222547, 0.219357, 0.216167, 0.212978, 0.209788, 0.206598, 0.203409, 0.200219, 0.197029, 0.193530, 0.190022, 0.186513, 0.183005, 0.179496, 0.175988, 0.172479, 0.168971, 0.165337, 0.161638, 0.157940, 0.154241, 0.150543, 0.146844, 0.143146, 0.139448, 0.135657, 0.131852, 0.128048, 0.124244, 0.120440, 0.116635, 0.112831, 0.108987, 0.105122, 0.101256, 0.097391, 0.093525, 0.089659, 0.085794, 0.081907, 0.078019, 0.074132, 0.070244, 0.066357, 0.062469, 0.058569, 0.054668, 0.050768, 0.046867, 0.042966, 0.039062, 0.035155, 0.031249, 0.027343, 0.023437, 0.019530, 0.015624, 0.011718, 0.007812, 0.003905, 0.000000], - ], - [ - [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000170, -0.000401, -0.000631, -0.000862, -0.001093, -0.001324, -0.001555, -0.001786, -0.002017, -0.002248, -0.002629, -0.003800, -0.004971, -0.006143, -0.007314, -0.008485, -0.009656, -0.010827, -0.011999, -0.013170, -0.014341, -0.015931, -0.017854, -0.019778, -0.021701, -0.023625, -0.025548, -0.027472, -0.029395, -0.031319, -0.033242, -0.035202, -0.037590, -0.039978, -0.042366, -0.044754, -0.047142, -0.049530, -0.051918, -0.054306, -0.056694, -0.059082, -0.061595, -0.064142, -0.066690, -0.069237, -0.071784, -0.074332, -0.076879, -0.079426, -0.081974, -0.084521, -0.086958, -0.089360, -0.091762, -0.094164, -0.096566, -0.098968, -0.101370, -0.103772, -0.106174, -0.108550, -0.110533, -0.112515, -0.114498, -0.116481, -0.118464, -0.120447, -0.122430, -0.124413, -0.126396, -0.127877, -0.129218, -0.130559, -0.131900, -0.133241, -0.134582, -0.135923, -0.137264, -0.138605, -0.139159, -0.139689, -0.140219, -0.140748, -0.141278, -0.141807, -0.142337, -0.142867, -0.142785, -0.142391, -0.141997, -0.141603, -0.141208, -0.140814, -0.140420, -0.140026, -0.138758, -0.137365, -0.135972, -0.134580, -0.133187, -0.131794, -0.130401, -0.128338, -0.125908, -0.123477, -0.121047, -0.118616, -0.116186, -0.113755, -0.110258, -0.106756, -0.103253, -0.099751, -0.096248, -0.092746, -0.088181, -0.083606, -0.079030, -0.074455, -0.069879, -0.064569, -0.058924, -0.053280, -0.047636, -0.041810, -0.035207, -0.028604, -0.022001, -0.014908, -0.007453, 0.000000], - [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000119, -0.000282, -0.000445, -0.000607, -0.000770, -0.000932, -0.001095, -0.001257, -0.001420, -0.001582, -0.001850, -0.002671, -0.003492, -0.004313, -0.005134, -0.005955, -0.006776, -0.007597, -0.008418, -0.009239, -0.010060, -0.011173, -0.012519, -0.013866, -0.015212, -0.016559, -0.017905, -0.019252, -0.020598, -0.021945, -0.023291, -0.024663, -0.026331, -0.027999, -0.029667, -0.031336, -0.033004, -0.034672, -0.036340, -0.038008, -0.039677, -0.041345, -0.043102, -0.044885, -0.046667, -0.048449, -0.050231, -0.052013, -0.053795, -0.055577, -0.057359, -0.059141, -0.060847, -0.062528, -0.064209, -0.065890, -0.067571, -0.069252, -0.070933, -0.072614, -0.074295, -0.075959, -0.077358, -0.078758, -0.080157, -0.081557, -0.082956, -0.084356, -0.085755, -0.087155, -0.088555, -0.089611, -0.090571, -0.091531, -0.092492, -0.093452, -0.094412, -0.095373, -0.096333, -0.097293, -0.097711, -0.098112, -0.098512, -0.098913, -0.099314, -0.099714, -0.100115, -0.100515, -0.100489, -0.100243, -0.099998, -0.099752, -0.099507, -0.099261, -0.099016, -0.098770, -0.097900, -0.096940, -0.095980, -0.095020, -0.094060, -0.093100, -0.092141, -0.090700, -0.088994, -0.087289, -0.085584, -0.083879, -0.082174, -0.080469, -0.077998, -0.075524, -0.073051, -0.070577, -0.068103, -0.065629, -0.062390, -0.059143, -0.055896, -0.052649, -0.049403, -0.045639, -0.041641, -0.037642, -0.033643, -0.029518, -0.024848, -0.020178, -0.015508, -0.010503, -0.005251, 0.000000], - [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000074, -0.000175, -0.000275, -0.000376, -0.000477, -0.000577, -0.000678, -0.000779, -0.000879, -0.000980, -0.001147, -0.001660, -0.002173, -0.002687, -0.003200, -0.003713, -0.004227, -0.004740, -0.005253, -0.005767, -0.006280, -0.006971, -0.007803, -0.008636, -0.009468, -0.010301, -0.011133, -0.011966, -0.012798, -0.013631, -0.014463, -0.015311, -0.016344, -0.017377, -0.018410, -0.019442, -0.020475, -0.021508, -0.022540, -0.023573, -0.024606, -0.025639, -0.026726, -0.027829, -0.028932, -0.030035, -0.031137, -0.032240, -0.033343, -0.034446, -0.035548, -0.036651, -0.037711, -0.038756, -0.039802, -0.040847, -0.041893, -0.042939, -0.043984, -0.045030, -0.046076, -0.047111, -0.047989, -0.048867, -0.049745, -0.050623, -0.051501, -0.052379, -0.053257, -0.054135, -0.055012, -0.055682, -0.056292, -0.056903, -0.057514, -0.058125, -0.058735, -0.059346, -0.059957, -0.060568, -0.060842, -0.061107, -0.061371, -0.061635, -0.061899, -0.062163, -0.062427, -0.062691, -0.062689, -0.062551, -0.062412, -0.062273, -0.062135, -0.061996, -0.061857, -0.061719, -0.061187, -0.060599, -0.060011, -0.059423, -0.058834, -0.058246, -0.057658, -0.056765, -0.055704, -0.054643, -0.053582, -0.052521, -0.051460, -0.050399, -0.048848, -0.047296, -0.045743, -0.044190, -0.042637, -0.041084, -0.039057, -0.037025, -0.034993, -0.032961, -0.030929, -0.028563, -0.026045, -0.023528, -0.021010, -0.018416, -0.015497, -0.012577, -0.009657, -0.006537, -0.003268, 0.000000], - [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000035, -0.000082, -0.000130, -0.000178, -0.000225, -0.000273, -0.000320, -0.000368, -0.000415, -0.000463, -0.000541, -0.000777, -0.001013, -0.001249, -0.001485, -0.001722, -0.001958, -0.002194, -0.002430, -0.002666, -0.002903, -0.003222, -0.003608, -0.003994, -0.004381, -0.004767, -0.005153, -0.005539, -0.005925, -0.006311, -0.006697, -0.007090, -0.007569, -0.008048, -0.008526, -0.009005, -0.009483, -0.009962, -0.010441, -0.010919, -0.011398, -0.011877, -0.012381, -0.012892, -0.013404, -0.013915, -0.014426, -0.014938, -0.015449, -0.015960, -0.016472, -0.016983, -0.017477, -0.017964, -0.018452, -0.018940, -0.019427, -0.019915, -0.020403, -0.020890, -0.021378, -0.021861, -0.022268, -0.022676, -0.023084, -0.023492, -0.023899, -0.024307, -0.024715, -0.025123, -0.025531, -0.025846, -0.026137, -0.026427, -0.026717, -0.027007, -0.027297, -0.027588, -0.027878, -0.028168, -0.028302, -0.028431, -0.028559, -0.028688, -0.028817, -0.028946, -0.029074, -0.029203, -0.029209, -0.029151, -0.029093, -0.029035, -0.028977, -0.028919, -0.028861, -0.028803, -0.028558, -0.028287, -0.028016, -0.027745, -0.027474, -0.027203, -0.026931, -0.026515, -0.026020, -0.025524, -0.025029, -0.024533, -0.024038, -0.023542, -0.022817, -0.022090, -0.021364, -0.020638, -0.019911, -0.019185, -0.018235, -0.017283, -0.016331, -0.015379, -0.014426, -0.013321, -0.012146, -0.010971, -0.009796, -0.008586, -0.007226, -0.005865, -0.004505, -0.003049, -0.001525, 0.000000], - [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000050, 0.000117, 0.000184, 0.000252, 0.000319, 0.000387, 0.000454, 0.000522, 0.000589, 0.000656, 0.000766, 0.001096, 0.001427, 0.001757, 0.002087, 0.002417, 0.002748, 0.003078, 0.003408, 0.003739, 0.004069, 0.004518, 0.005061, 0.005605, 0.006148, 0.006691, 0.007235, 0.007778, 0.008322, 0.008865, 0.009408, 0.009962, 0.010631, 0.011301, 0.011971, 0.012641, 0.013310, 0.013980, 0.014650, 0.015320, 0.015989, 0.016659, 0.017370, 0.018091, 0.018813, 0.019535, 0.020256, 0.020978, 0.021700, 0.022421, 0.023143, 0.023865, 0.024567, 0.025263, 0.025959, 0.026656, 0.027352, 0.028048, 0.028744, 0.029440, 0.030137, 0.030827, 0.031423, 0.032019, 0.032615, 0.033211, 0.033807, 0.034403, 0.034999, 0.035595, 0.036191, 0.036657, 0.037087, 0.037517, 0.037946, 0.038376, 0.038806, 0.039235, 0.039665, 0.040095, 0.040305, 0.040509, 0.040713, 0.040916, 0.041120, 0.041323, 0.041527, 0.041731, 0.041753, 0.041683, 0.041613, 0.041543, 0.041473, 0.041402, 0.041332, 0.041262, 0.040922, 0.040544, 0.040166, 0.039787, 0.039409, 0.039031, 0.038653, 0.038058, 0.037345, 0.036632, 0.035920, 0.035207, 0.034494, 0.033781, 0.032735, 0.031687, 0.030640, 0.029592, 0.028545, 0.027497, 0.026120, 0.024740, 0.023359, 0.021979, 0.020598, 0.019008, 0.017322, 0.015636, 0.013950, 0.012215, 0.010269, 0.008323, 0.006376, 0.004310, 0.002155, 0.000000], - [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000080, 0.000189, 0.000299, 0.000408, 0.000517, 0.000626, 0.000735, 0.000844, 0.000953, 0.001063, 0.001242, 0.001787, 0.002333, 0.002879, 0.003425, 0.003971, 0.004517, 0.005063, 0.005609, 0.006154, 0.006700, 0.007438, 0.008329, 0.009220, 0.010111, 0.011002, 0.011893, 0.012784, 0.013675, 0.014566, 0.015457, 0.016365, 0.017469, 0.018573, 0.019676, 0.020780, 0.021884, 0.022988, 0.024092, 0.025195, 0.026299, 0.027403, 0.028573, 0.029761, 0.030948, 0.032136, 0.033324, 0.034512, 0.035700, 0.036888, 0.038076, 0.039263, 0.040424, 0.041575, 0.042727, 0.043878, 0.045030, 0.046181, 0.047333, 0.048484, 0.049636, 0.050778, 0.051774, 0.052771, 0.053767, 0.054764, 0.055761, 0.056757, 0.057754, 0.058750, 0.059747, 0.060528, 0.061250, 0.061971, 0.062693, 0.063414, 0.064136, 0.064857, 0.065579, 0.066300, 0.066662, 0.067012, 0.067362, 0.067712, 0.068062, 0.068412, 0.068762, 0.069112, 0.069160, 0.069053, 0.068946, 0.068839, 0.068732, 0.068625, 0.068518, 0.068411, 0.067854, 0.067232, 0.066611, 0.065990, 0.065368, 0.064747, 0.064125, 0.063141, 0.061957, 0.060774, 0.059590, 0.058406, 0.057223, 0.056039, 0.054292, 0.052542, 0.050792, 0.049041, 0.047291, 0.045541, 0.043250, 0.040953, 0.038657, 0.036360, 0.034063, 0.031426, 0.028634, 0.025842, 0.023050, 0.020178, 0.016957, 0.013737, 0.010517, 0.007105, 0.003552, 0.000000], - [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000141, 0.000333, 0.000525, 0.000718, 0.000910, 0.001102, 0.001294, 0.001486, 0.001678, 0.001870, 0.002192, 0.003198, 0.004204, 0.005210, 0.006216, 0.007222, 0.008228, 0.009234, 0.010240, 0.011246, 0.012252, 0.013647, 0.015354, 0.017061, 0.018768, 0.020474, 0.022181, 0.023888, 0.025595, 0.027302, 0.029009, 0.030749, 0.032879, 0.035009, 0.037140, 0.039270, 0.041400, 0.043531, 0.045661, 0.047791, 0.049922, 0.052052, 0.054258, 0.056485, 0.058711, 0.060938, 0.063165, 0.065392, 0.067619, 0.069845, 0.072072, 0.074299, 0.076337, 0.078313, 0.080290, 0.082267, 0.084244, 0.086221, 0.088198, 0.090174, 0.092151, 0.094094, 0.095519, 0.096944, 0.098369, 0.099794, 0.101219, 0.102644, 0.104069, 0.105494, 0.106919, 0.107739, 0.108391, 0.109042, 0.109694, 0.110345, 0.110997, 0.111648, 0.112299, 0.112951, 0.112758, 0.112539, 0.112320, 0.112101, 0.111883, 0.111664, 0.111445, 0.111226, 0.110443, 0.109371, 0.108299, 0.107227, 0.106156, 0.105084, 0.104012, 0.102940, 0.101213, 0.099393, 0.097572, 0.095752, 0.093931, 0.092111, 0.090290, 0.088075, 0.085643, 0.083211, 0.080779, 0.078347, 0.075915, 0.073483, 0.070586, 0.067687, 0.064788, 0.061889, 0.058989, 0.056090, 0.052849, 0.049604, 0.046360, 0.043115, 0.039870, 0.036455, 0.032962, 0.029468, 0.025975, 0.022446, 0.018760, 0.015074, 0.011388, 0.007628, 0.003814, 0.000000], - [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000178, 0.000421, 0.000664, 0.000906, 0.001149, 0.001392, 0.001634, 0.001877, 0.002120, 0.002362, 0.002773, 0.004064, 0.005355, 0.006646, 0.007937, 0.009228, 0.010519, 0.011810, 0.013101, 0.014392, 0.015683, 0.017484, 0.019691, 0.021898, 0.024106, 0.026313, 0.028521, 0.030728, 0.032935, 0.035143, 0.037350, 0.039601, 0.042371, 0.045140, 0.047909, 0.050679, 0.053448, 0.056218, 0.058987, 0.061756, 0.064526, 0.067295, 0.070147, 0.073022, 0.075896, 0.078771, 0.081645, 0.084520, 0.087394, 0.090269, 0.093143, 0.096018, 0.098611, 0.101113, 0.103616, 0.106118, 0.108621, 0.111123, 0.113625, 0.116128, 0.118630, 0.121083, 0.122773, 0.124462, 0.126152, 0.127842, 0.129532, 0.131221, 0.132911, 0.134601, 0.136291, 0.137119, 0.137708, 0.138296, 0.138884, 0.139472, 0.140060, 0.140649, 0.141237, 0.141825, 0.141254, 0.140648, 0.140041, 0.139434, 0.138827, 0.138220, 0.137613, 0.137007, 0.135669, 0.133956, 0.132244, 0.130531, 0.128819, 0.127106, 0.125393, 0.123681, 0.121195, 0.118600, 0.116004, 0.113408, 0.110812, 0.108217, 0.105621, 0.102623, 0.099405, 0.096186, 0.092968, 0.089749, 0.086531, 0.083312, 0.079721, 0.076129, 0.072536, 0.068944, 0.065351, 0.061758, 0.057965, 0.054171, 0.050376, 0.046581, 0.042786, 0.038937, 0.035063, 0.031190, 0.027316, 0.023437, 0.019530, 0.015624, 0.011718, 0.007812, 0.003905, 0.000000], - ], -]; diff --git a/crates/pipeline/src/finish.rs b/crates/pipeline/src/finish.rs index f736e519858..0a595c61758 100644 --- a/crates/pipeline/src/finish.rs +++ b/crates/pipeline/src/finish.rs @@ -415,8 +415,7 @@ pub fn base_tone(s: &DevelopSettings, info: &SourceInfo, peak: f32) -> ToneMap { 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), }, - // V7, with Whites moved out of the tone map: the curve stage applies Whites as measured against - // Lightroom (`crate::curve_stage`) + // V7, with Whites moved out of the tone map: the curve stage applies Whites (`crate::curve_stage`) Process::V9 => match info.camera_tone.as_ref().filter(|_| info.raw) { Some(curve) => ToneMap::camera_rolloff_hdr(curve, 0.0, 0.0, 0.0, peak), None if info.raw => ToneMap::rolloff_hdr(l.contrast, 0.0, l.blacks, peak), @@ -568,7 +567,7 @@ pub(crate) fn finish_with( // --- process V4: calibrated Contrast, Blacks (ProPhoto with the sRGB transfer) d = apply_light(d, light.as_ref(), preview_light.as_ref(), exact, srgb); - // --- process V9: Whites and the tone curves, as Lightroom applies them + // --- process V9: Whites and the tone curves, hue-preserving d = fp.curve_stage.as_ref().map_or(d, |stage| stage.apply(d)); // --- colour diff --git a/crates/pipeline/src/lib.rs b/crates/pipeline/src/lib.rs index 89c2e9f2d4e..a7a4152f01e 100644 --- a/crates/pipeline/src/lib.rs +++ b/crates/pipeline/src/lib.rs @@ -32,7 +32,7 @@ pub mod cull; pub mod curve; pub mod curve_stage; #[rustfmt::skip] -mod curve_stage_tables; +mod curve_stage_model; pub mod dust; pub mod finish; pub mod geometry; diff --git a/crates/ui-egui/src/panels/edit/curve.rs b/crates/ui-egui/src/panels/edit/curve.rs index a7ea96bc5c5..1711a8db54e 100644 --- a/crates/ui-egui/src/panels/edit/curve.rs +++ b/crates/ui-egui/src/panels/edit/curve.rs @@ -238,7 +238,7 @@ pub(super) fn curve_editor(app: &mut LightcraftApp, ui: &mut egui::Ui, id: Photo let from_screen = |q: Pos2| (((q.x - r.left()) / r.width()).clamp(0.0, 1.0) as f64, ((r.bottom() - q.y) / r.height()).clamp(0.0, 1.0) as f64); if ch == "parametric" { // The Effective curve: the one the renderer builds from the four region sliders for this - // process (the measured regions under V9 at the default splits), sampled here and rebuilt every + // process (the fitted regions under V9 at the default splits), sampled here and rebuilt every // frame. The graph holds no state of its own, so a slider moved by hand, a Reset or an Undo // redraws it from the settings in the same frame it changes. let model = ParametricGraph::new(d); diff --git a/crates/ui-egui/src/tests/curve.rs b/crates/ui-egui/src/tests/curve.rs index f3618611460..7c7a0e2162f 100644 --- a/crates/ui-egui/src/tests/curve.rs +++ b/crates/ui-egui/src/tests/curve.rs @@ -36,7 +36,7 @@ fn exec(h: &mut Headless, command: &str, params: serde_json::Value) -> serde_jso r["result"].clone() } -/// The parametric graph the panel draws for the selected photo's settings (its process decides measured or analytic). +/// The parametric graph the panel draws for the selected photo's settings (its process decides fitted or analytic). fn graph(h: &Headless) -> ParametricGraph { ParametricGraph::new(&develop(h)) } @@ -280,7 +280,7 @@ fn the_parametric_graph_paints_the_model_the_renderer_uses() { let model = graph(&h); let rect = curve_graph_rect(&mut h); let painted = painted_param_curve(&h, rect); - assert!(model.is_measured(), "the demo photo is on the latest process, which renders the measured regions"); + assert!(model.is_fitted(), "the demo photo is on the latest process, which renders the fitted regions"); let mut checked = 0; for i in 0..=24 { let x = i as f64 / 24.0; diff --git a/docs/curve-stage.md b/docs/curve-stage.md index 2fe3bde85eb..fea592dfb99 100644 --- a/docs/curve-stage.md +++ b/docs/curve-stage.md @@ -2,10 +2,10 @@ > **Changes:** [revision history](#revision-history) -Process V9 renders Whites, the parametric curve and the point curves the way Lightroom does, from measurements of -Camera Raw's output. V1 to V8 are unchanged (`docs/process-versions.md`). The code is -`crates/pipeline/src/curve_stage.rs`, its measured tables `crates/pipeline/src/curve_stage_tables.rs`, and the GPU -kernel's `curve_stage` in `crates/gpu/src/wgsl/finish.wgsl`. +Process V9 renders Whites, the parametric curve and the point curves the way Lightroom does, with LightCraft's own +model fitted to measurements of Camera Raw's output. V1 to V8 are unchanged (`docs/process-versions.md`). The code is +`crates/pipeline/src/curve_stage.rs`, the model's fitted constants `crates/pipeline/src/curve_stage_model.rs`, and the +GPU kernel's `curve_stage` in `crates/gpu/src/wgsl/finish.wgsl`. ## What was wrong @@ -26,11 +26,10 @@ After the tone map and V4's calibrated Contrast and Blacks, before the colour st 1. Convert linear Rec.2020 to linear ProPhoto RGB (D50, Bradford) and encode with the sRGB curve, as the V4 operators do (`light_v3::prophoto_matrices`). -2. Build the base table: Whites, then the parametric curve, then the master point curve. Whites and the four regions - are Camera Raw's measured output minus input (257 inputs each). Whites is measured at ±25, ±50 and ±100, the - regions at ±25, ±50, ±75 and ±100, and amounts in between are interpolated linearly, towards 0 below 25. The - tables hold for Lightroom's default splits (25, 50, 75). With other splits the parametric curve is the analytic - model of the earlier processes. The table is kept non-decreasing. +2. Build the base table: Whites, then the parametric curve, then the master point curve. Whites and each of the four + regions add a fitted response to the diagonal (below). The regions are fitted for Lightroom's default splits + (25, 50, 75). With other splits the parametric curve is the analytic model of the earlier processes. The table is + kept non-decreasing. 3. Apply the base table to the largest and smallest channel. The middle channel keeps its relative position between them in linear light. 4. Apply the red, green and blue point curves to each channel. @@ -42,11 +41,24 @@ The tone map no longer applies Whites under V9 (`finish::base_tone`), and the V8 (`FinishParams::curves` is `None`). With Whites, the parametric curve and the point curves all neutral, the curve stage does not run. +## The model + +Each slider direction (negative and positive) of Whites and of each region has its own response, output minus input +on sRGB-encoded values: the sum of two smooth bumps. With `t` = |amount| / 100, + + response(x) = Σ (a1 t + a2 t² + a3 t³) · bump(x, e^(p0 + p1 t), e^(q0 + q1 t)) + bump(x, p, q) = (x / m)^p · ((1 − x) / (1 − m))^q, m = p / (p + q) + +A bump is 0 at black and white and 1 at its peak `m`. The gain grows faster than linearly with the amount, and the +bump's position and width move with the amount, as Lightroom's regions widen and move when pushed harder. That is 7 +constants per bump, 14 per slider direction and 140 in all. The fit keeps every response growing with the amount at +every input and never acting against the slider, so dragging the graph moves the slider steadily. + ## The Edit panel's graph -The parametric graph draws the curve the photo renders, from `curve_stage::ParametricGraph`: the measured regions +The parametric graph draws the curve the photo renders, from `curve_stage::ParametricGraph`: the fitted regions under V9 at the default splits, else the analytic model. Dragging the line moves the region under the pointer by -the amount that puts the drawn curve where the pointer is. The measured tables are not linear in the amount, so the +the amount that puts the drawn curve where the pointer is. The fitted regions are not linear in the amount, so the amount is searched for, on the side of the starting value the drag moves to, on the curve as drawn (kept monotone, so where opposite regions fold it back the line is held flat by the peak to its left). A level out of the region's reach saturates at ±100. A region that cannot move the line by half an 8-bit level in that direction keeps its value. @@ -58,18 +70,31 @@ Whites is not part of the graph, as in Lightroom. patches, with the settings in the DNG's XMP. It writes one neutral chart, Whites at each measured amount, and each parametric region at each measured amount. The charts are original test data. Every chart was rendered through Camera Raw to a 16-bit Adobe RGB (1998) TIFF. Only that output is measured, and nothing of Adobe's is copied or -shipped. `tools/lr_tone_charts.py tables RENDER_DIR OUT_RS` reads the grey steps of each render as sRGB-encoded -linear ProPhoto values and writes `curve_stage_tables.rs`. It needs numpy and tifffile -(`tools/requirements-lr-tone-charts.txt`). Running the tool again reproduces the committed charts and the committed -tables byte for byte. +shipped, and no measurement is committed. `tools/lr_tone_charts.py fit RENDER_DIR OUT_RS` reads the grey steps of +each render as sRGB-encoded linear ProPhoto values, fits the model to them and writes only its constants, +`curve_stage_model.rs`. It needs numpy, scipy and tifffile (`tools/requirements-lr-tone-charts.txt`). Running the +tool again reproduces the committed charts byte for byte, and the constants with the pinned packages. + +How close the model is to the measured response, as the stage renders it (both clamped to 0..1), over 257 inputs and +every measured amount, in 8-bit levels of the sRGB-encoded output: + +| Setting | negative: RMS | max | positive: RMS | max | +|---|---|---|---|---| +| Whites | 0.15 | 0.88 | 0.27 | 1.62 | +| Shadows | 0.39 | 2.18 | 0.34 | 1.37 | +| Darks | 0.33 | 1.73 | 0.19 | 1.32 | +| Lights | 0.05 | 0.17 | 0.37 | 1.04 | +| Highlights | 0.15 | 0.64 | 0.52 | 2.29 | + +Every largest error but one (Darks +50, at black) is at ±75 or ±100. -The grey-step tables leave out how colour is treated. To check that, the colour patches of the same renders were +The grey steps leave out how colour is treated. To check that, the colour patches of the same renders were predicted from the grey-step curves under the hue-preserving rule in step 3. The prediction is within 0.03 to 0.16 (OkLab × 100) of Camera Raw's patches, against 0.3 to 3.4 for V8's per-channel curves. ## Limits -- The tables are measured with Lightroom's default splits. Moved splits use the earlier analytic model. +- The regions are fitted with Lightroom's default splits. Moved splits use the earlier analytic model. - The point curves' shape between the points is LightCraft's spline, not measured. What is measured for them is how they apply: hue preserving, then the red, green and blue curves per channel. - Local (mask) Whites keeps the earlier processes' operator. @@ -81,3 +106,4 @@ predicted from the grey-step curves under the hue-preserving rule in step 3. The |---|---|---| | 2026-11-10 | minor | Process V9: measured Whites and parametric curve, hue-preserving master curve | | 2026-11-11 | minor | The Edit panel's parametric graph draws and drags the measured regions under V9 | +| 2026-11-24 | minor | Whites and the regions are a fitted model instead of measured tables | diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index d115d21e547..da4aedf1646 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -185,7 +185,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | From process V2, the same base as Highlights: dark areas keep their local contrast when lifted (#632); from process V8, the gaps in dark lettering on a bright panel are not lifted into bright blocks. Alt/Option-drag shows shadow clipping (white, clipped channels in colour) | | LR-EDIT-LIGHT-WHITES | Whites | P0 | 🟡 | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | From process V9 Whites is measured against Camera Raw renders of synthetic grey steps and reaches into the midtones as Lightroom's does ([curve-stage.md](curve-stage.md)); not yet compared on photos per camera. V4 to V8 preserve V2 Whites for both signs; measured V2 check response error is 0.075 stops on the Sony test photos (`docs/light-v3.md`). Alt/Option-drag shows highlight clipping (black, clipped channels in colour) | | LR-EDIT-LIGHT-BLACKS | Blacks | P0 | 🟡 | `ctl:light.blacks`, `crates/pipeline/src/visualize.rs` | From process V4, global Blacks on the camera-look path uses a fitted per-channel/luminance mix. Check response error 0.424 to 0.077 stops on six held-out Sony photos; deepest tones still differ. Other sources and local adjustments retain V2 (`docs/light-v3.md`). Alt/Option-drag shows shadow clipping (white, clipped channels in colour) | -| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | from process V9 the regions are Camera Raw's measured response at the default splits, broad and additive ([curve-stage.md](curve-stage.md)); the graph draws the curve the photo renders (`ParametricGraph`: the measured regions under V9 at the default splits, else the analytic model); dragging the line moves the region under the pointer (one undo step) | +| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | from process V9 the regions are LightCraft's model fitted to Camera Raw's measured response at the default splits, broad and additive ([curve-stage.md](curve-stage.md)); the graph draws the curve the photo renders (`ParametricGraph`: the fitted regions under V9 at the default splits, else the analytic model); dragging the line moves the region under the pointer (one undo step) | | LR-EDIT-LIGHT-CURVE-POINT | Point curve | P0 | ✅ | `cmd:develop.curve`, `cmd:curve.reset`, `cmd:curve.presets`, `cmd:curve.applyPreset`, `cmd:curve.savePreset`, `cmd:curve.deletePreset`, `cmd:curve.importPresets`, `cmd:curve.exportPresets`, `cmd:file.importCurvePresets`, `cmd:file.exportCurvePresets`, `crates/engine/src/cmd/curves.rs`, `crates/ui-egui/src/panels/edit.rs` | click to add a point; drag a point in both axes (between its neighbours, input / output readout, one undo step per drag; ⌥-drag moves it a tenth as far for fine adjustment, issue #1363); drag empty space to add and drag; double-click removes; reset: double-click a channel selector (that channel), the Reset button under the graph (every curve incl. parametric) or right-click the graph (channel / all); Point Curve preset dropdown: own Linear / Medium Contrast / Strong Contrast, user presets (save the current point curves, delete by right-click; saved with the library), import / export as `.lccurve` JSON; from process V9 the master curve keeps hue as Lightroom's does (largest and smallest channel through the curve, the middle one in proportion), and the red, green and blue curves follow it per channel ([curve-stage.md](curve-stage.md)) | | LR-EDIT-LIGHT-CURVE-RGB | Per-channel curves | P0 | ✅ | `cmd:develop.curve` (`channel`) | | | LR-EDIT-LIGHT-CURVE-REFINESAT | Curve saturation compensation | P1 | ✅ | `ctl:curve.refineSaturation` | | diff --git a/docs/process-versions.md b/docs/process-versions.md index 3993fd7be04..4e2b73b3fdf 100644 --- a/docs/process-versions.md +++ b/docs/process-versions.md @@ -17,7 +17,7 @@ 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: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map and, with the parametric curve at Lightroom's default splits, comes from measured tables (Whites reaches into the midtones; the regions are broad and add; moved splits keep the analytic model of V1 to V8); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V8 keep Whites in the tone map and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the tables. With Whites, the parametric curve and the point curves neutral the curve stage does not run. | +| **V9** (the latest) | V8 plus: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map and, with the parametric curve at Lightroom's default splits, comes from LightCraft's model fitted to those measurements (Whites reaches into the midtones; the regions are broad and add; moved splits keep the analytic model of V1 to V8); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V8 keep Whites in the tone map and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the curve tables built from the model. With Whites, the parametric curve and the point curves neutral the curve stage does not run. | ## The rule diff --git a/docs/whats-new.md b/docs/whats-new.md index 0d61768f01e..20f50a4bcc0 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -2,13 +2,12 @@ ## Unreleased -### Whites and the tone curves behave as in Lightroom (process V9) -- Whites now reaches into the upper midtones as Lightroom's does, and the Highlights, Lights, Darks and Shadows - regions of the parametric curve are as broad as Lightroom's and add up the same way: both follow Lightroom's - measured response. A contrast curve no longer turns orange towards red: the point curve keeps colours' hue, and - the red, green and blue curves act on their channel after it. This is rendering process 9: new photos (and Reset) - get it, photos you already edited keep their look until you choose Photo ▸ Update to Current Process. See - [Whites and the tone curves](curve-stage.md). +### Broader Whites and parametric curve, hue-preserving tone curves (process 9) +- Whites now reaches into the upper midtones, and the Highlights, Lights, Darks and Shadows regions of the + parametric curve are broader, overlap and add up when several are set. A contrast curve no longer turns orange + towards red: the point curve keeps colours' hue, and the red, green and blue curves act on their channel after it. + This is rendering process 9: new photos (and Reset) get it, photos you already edited keep their look until you + choose Photo ▸ Update to Current Process. See [Whites and the tone curves](curve-stage.md). ### Flatpak updates - Help ▸ Check for Updates can now reach the release service and update standalone Flatpak bundles. diff --git a/tools/lr_tone_charts.py b/tools/lr_tone_charts.py index 5aaf67d17da..3fb4fbf7716 100644 --- a/tools/lr_tone_charts.py +++ b/tools/lr_tone_charts.py @@ -5,11 +5,12 @@ Writes linear DNG charts (48 grey steps plus colour patches) with the settings embedded as XMP: one neutral chart, Whites at +-25/50/100 and each parametric region at +-25/50/75/100 (default splits). (render every DNG through Camera Raw to a 16-bit Adobe RGB (1998) TIFF with the same file name) - python3 tools/lr_tone_charts.py tables RENDER_DIR OUT_RS - Reads the renders and writes the Rust tables of `lightcraft_pipeline::curve_stage`. + python3 tools/lr_tone_charts.py fit RENDER_DIR OUT_RS + Reads the renders, fits LightCraft's model of each setting to them and writes the model's constants + (`lightcraft_pipeline::curve_stage_model`). The measurements themselves are not written out. The charts are original test data generated here; nothing in them comes from Adobe. Only Camera Raw's output is -measured. Requires numpy and tifffile (tools/requirements-lr-tone-charts.txt). +measured. Requires numpy, scipy and tifffile (tools/requirements-lr-tone-charts.txt). """ import json import os @@ -119,7 +120,7 @@ def variants(): return v -# ---- tables ------------------------------------------------------------------------------------------------- +# ---- measuring ---------------------------------------------------------------------------------------------- ADOBE_TO_XYZ = np.array([[0.5767309, 0.1855540, 0.1881852], [0.2973769, 0.6273491, 0.0752741], [0.0270343, 0.0706872, 0.9911085]]) # XYZ (D65) -> linear ProPhoto RGB (D50, Bradford), as `RgbSpace::to_space` @@ -138,7 +139,7 @@ def srgb_encode(v): def read_render(path): - """A Camera Raw render as RGB 0..1, after checking it is the 16-bit Adobe RGB (1998) TIFF the tables assume. + """A Camera Raw render as RGB 0..1, after checking it is the 16-bit Adobe RGB (1998) TIFF the fit assumes. Another export setting would still give plausible numbers, but wrong ones, so it is refused. """ @@ -181,33 +182,102 @@ def delta_table(neutral, edited): return d -def tables(render_dir, out_rs): - """Measure the Camera Raw renders in `render_dir` and write the Rust tables to `out_rs`.""" +# ---- fit ---------------------------------------------------------------------------------------------------- +# +# LightCraft's own model of each setting, fitted to the measured grey steps. Nothing measured is written out: only +# the model's constants. Per slider direction (negative, positive) the response (output minus input) is the sum of +# two bumps, each with a gain over the amount and a shape whose position and width change with the amount: +# +# t = |amount| / 100 +# response(x) = sum over the two bumps of (a1 t + a2 t^2 + a3 t^3) * bump(x, e^(p0 + p1 t), e^(q0 + q1 t)) +# bump(x, p, q) = (x / m)^p ((1 - x) / (1 - m))^q with m = p / (p + q): 0 at black and white, 1 at its peak m +# +# The fit keeps every response growing with the amount at every input, and never acting against the slider. + +FIT_SEED = 7 +FIT_STARTS = 16 +FIT_AMOUNTS = np.linspace(0, 1, 21) +GRID = np.linspace(0, 1, 257) + + +def bump(x, p, q): + """A bump of peak 1 at p / (p + q), 0 at black and white.""" + m = p / (p + q) + return np.exp(p * np.log(np.clip(x, 1e-12, 1) / m) + q * np.log(np.clip(1 - x, 1e-12, 1) / (1 - m))) + + +def response(params, t, x=GRID): + """The model's response of one slider direction at amount `t` (0..1) for inputs `x`.""" + out = 0.0 + for a1, a2, a3, p0, p1, q0, q1 in np.reshape(params, (2, 7)): + out = out + (a1 * t + a2 * t * t + a3 * t ** 3) * bump(x, np.exp(p0 + p1 * t), np.exp(q0 + q1 * t)) + return out + + +def fit_direction(amounts, deltas, sign): + """Fit one slider direction to its measured deltas (257 inputs each); returns the constants and the error.""" + from scipy.optimize import least_squares + rows = [(abs(a) / 100, d) for a, d in zip(amounts, deltas) if np.sign(a) == sign] + + def err(params): + """Error of the rendered curve in 8-bit levels, both sides clamped to 0..1 as the stage clamps.""" + return np.concatenate([(np.clip(GRID + response(params, t), 0, 1) - np.clip(GRID + d, 0, 1)) * 255 for t, d in rows]) + + def residual(params): + grow = np.array([sign * response(params, t) for t in FIT_AMOUNTS]) + return np.concatenate([err(params), 30 * 255 * np.minimum(np.diff(grow, axis=0), 0).ravel(), + 30 * 255 * np.minimum(grow, 0).ravel()]) + + rng = np.random.default_rng(FIT_SEED) + starts = [np.ravel([[sign * rng.uniform(0, 0.3), 0, 0, rng.uniform(-1.5, 2.5), 0, rng.uniform(-1.5, 2.5), 0] + for _ in range(2)]) for _ in range(FIT_STARTS)] + best = min((least_squares(residual, s, max_nfev=3000) for s in starts), key=lambda r: r.cost) + e = err(best.x) + return best.x, float(np.sqrt((e ** 2).mean())), float(np.abs(e).max()) + + +def fit(render_dir, out_rs): + """Fit the model to the Camera Raw renders in `render_dir` and write its constants to `out_rs`.""" patches = json.load(open(os.path.join(render_dir, "manifest.json")))["patches"] tif = lambda n: os.path.join(render_dir, f"curve__{n}.tif") n0 = grey_levels(tif("neutral"), patches) rows = lambda names: [delta_table(n0, grey_levels(tif(n), patches)) for n in names] - whites = rows([f"whites{a:+d}" for a in WHITES]) - regions = [rows([f"par_{r.lower()}{a:+d}" for a in REGION_AMOUNTS]) for r in REGIONS] - fmt = lambda t: "[" + ", ".join(f"{v:.6f}" for v in t) + "]" - s = ["// @generated by tools/lr_tone_charts.py from Camera Raw renders of its synthetic grey steps (docs/curve-stage.md).", - "// Output minus input of each setting on sRGB-encoded linear ProPhoto values, 257 evenly spaced inputs from 0 to 1.", + sets = [("Whites", WHITES, rows([f"whites{a:+d}" for a in WHITES]))] + sets += [(r, REGION_AMOUNTS, rows([f"par_{r.lower()}{a:+d}" for a in REGION_AMOUNTS])) for r in REGIONS] + from concurrent.futures import ProcessPoolExecutor + jobs = [(name, sign, amounts, deltas) for name, amounts, deltas in sets for sign in (-1, 1)] + with ProcessPoolExecutor() as pool: + done = list(pool.map(fit_direction, *zip(*[(a, d, s) for _, s, a, d in jobs]))) + fitted = {} + for (name, sign, _, _), (params, rms, worst) in zip(jobs, done): + fitted[name, sign] = params + print(f"{name:10s} {'+' if sign > 0 else '-'} rms {rms:.2f} max {worst:.2f} (8-bit levels)") + num = lambda v: f"{v:.6e}" + resp = lambda name, sign: "[" + ", ".join("[" + ", ".join(num(v) for v in b) + "]" for b in np.reshape(fitted[name, sign], (2, 7))) + "]" + pair = lambda name: f"[{resp(name, -1)}, {resp(name, 1)}]" + s = ["// Written by `tools/lr_tone_charts.py fit`: LightCraft's model of Whites and the parametric regions, fitted to the", + "// tool's grey-step charts (provenance in docs/curve-stage.md). Constants of the model only.", + "", + "/// One bump of a response: `[a1, a2, a3, p0, p1, q0, q1]`, gain `a1 t + a2 t² + a3 t³` (t = |amount| / 100), shape", + "/// exponents `e^(p0 + p1 t)` and `e^(q0 + q1 t)` ([`crate::curve_stage`]).", + "pub type Bump = [f64; 7];", + "/// A slider direction's response: two bumps, added.", + "pub type Response = [Bump; 2];", "", - f"pub const WHITES_AMOUNTS: [f32; {len(WHITES)}] = [{', '.join(f'{a}.0' for a in WHITES)}];", - f"pub static WHITES: [[f32; 257]; {len(WHITES)}] = [", *[f" {fmt(t)}," for t in whites], "];", + "/// Whites: negative, positive.", + f"pub const WHITES: [Response; 2] = {pair('Whites')};", "", - "/// Shadows, Darks, Lights, Highlights at the default splits (25, 50, 75).", - f"pub const REGION_AMOUNTS: [f32; {len(REGION_AMOUNTS)}] = [{', '.join(f'{a}.0' for a in REGION_AMOUNTS)}];", - f"pub static REGIONS: [[[f32; 257]; {len(REGION_AMOUNTS)}]; 4] = ["] - for r in regions: - s += [" ["] + [f" {fmt(t)}," for t in r] + [" ],"] - s += ["];", ""] + "/// Shadows, Darks, Lights, Highlights at the default splits (25, 50, 75): negative, positive.", + "pub const REGIONS: [[Response; 2]; 4] = [", + *[f" {pair(r)}," for r in REGIONS], + "];", + ""] with open(out_rs, "w") as f: f.write("\n".join(s)) def main(): - """Command line: `charts OUT_DIR` or `tables RENDER_DIR OUT_RS`.""" + """Command line: `charts OUT_DIR` or `fit RENDER_DIR OUT_RS`.""" if len(sys.argv) == 3 and sys.argv[1] == "charts": out = sys.argv[2] os.makedirs(out, exist_ok=True) @@ -215,8 +285,8 @@ def main(): json.dump(dict(patches=patches), open(os.path.join(out, "manifest.json"), "w")) for name, settings in variants().items(): write_dng(os.path.join(out, f"curve__{name}.dng"), img, xmp(**settings)) - elif len(sys.argv) == 4 and sys.argv[1] == "tables": - tables(sys.argv[2], sys.argv[3]) + elif len(sys.argv) == 4 and sys.argv[1] == "fit": + fit(sys.argv[2], sys.argv[3]) else: sys.exit(__doc__) diff --git a/tools/requirements-lr-tone-charts.txt b/tools/requirements-lr-tone-charts.txt index 3763d03c1d7..8391b1cd899 100644 --- a/tools/requirements-lr-tone-charts.txt +++ b/tools/requirements-lr-tone-charts.txt @@ -1,5 +1,6 @@ -# Python packages for tools/lr_tone_charts.py (crates/pipeline/src/curve_stage_tables.rs, docs/curve-stage.md). +# Python packages for tools/lr_tone_charts.py (crates/pipeline/src/curve_stage_model.rs, docs/curve-stage.md). # Needs Python 3.12 or newer (numpy 2.5); use a matching interpreter, e.g. python3.12 -m venv. # python3.12 -m venv .venv-lr-tone && .venv-lr-tone/bin/pip install -r tools/requirements-lr-tone-charts.txt numpy==2.5.4 +scipy==1.18.1 tifffile==2026.11.8 From 1f5347593552c6b53abdcb1d05a47aa3ddfb1f2f Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Thu, 3 Dec 2026 15:22:46 +0100 Subject: [PATCH 13/20] test(curve): the drag test allows the framework's drag threshold, not a fixed step count (#523) After the Craft UI port the threshold swallows a different number of the drag's 8 steps. The test now checks that the line moves no further than the hand and no less than the hand minus the 6-point threshold. --- crates/ui-egui/src/tests/curve.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/tests/curve.rs b/crates/ui-egui/src/tests/curve.rs index 76a629acadb..a9819e99819 100644 --- a/crates/ui-egui/src/tests/curve.rs +++ b/crates/ui-egui/src/tests/curve.rs @@ -439,10 +439,11 @@ fn dragging_the_curve_moves_the_region_slider() { let painted = painted_param_curve(&h, graph)(0.625); let before_level = g.at(0.625); assert!(painted < before_level - 0.02, "the painted line followed the drag down: {painted} vs before {before_level}"); - // and lands where the hand is: 0.08 lower, less the steps of the 8 that egui's drag threshold (6 points) swallows - let step = 0.08 * r[3] as f64 / 8.0; - let moved = 0.08 - (6.0 / step).floor() * step / r[3] as f64; - assert!((before_level - painted - moved).abs() < 0.006, "the line moved {} for a hand motion of {moved}", before_level - painted); + // and lands where the hand is: at most 0.08 lower, and at least that less the drag threshold (6 points), which + // swallows the hand's first steps (how many depends on how the framework starts a drag) + let moved = before_level - painted; + let threshold = 6.0 / r[3] as f64; + assert!(moved < 0.08 + 0.006 && moved > 0.08 - threshold - 0.006, "the line moved {moved} for a hand motion of 0.08"); // and Undo takes the whole gesture back to where it started exec(&mut h, "edit.undo", json!({})); assert_eq!(develop(&h).curve, c, "undo restores the value the drag started from"); From a85845dff4e0375cc5dc393a8d46b557c8267595 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Thu, 3 Dec 2026 15:58:55 +0100 Subject: [PATCH 14/20] test(proraw): V18's curve stage leaves Whites to the ProRAW chain; V17 asserts allow a later default (#523) --- crates/pipeline/src/proraw.rs | 4 +++- crates/pipeline/src/tests_proraw.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/pipeline/src/proraw.rs b/crates/pipeline/src/proraw.rs index ae7c2e848e5..07e34015565 100644 --- a/crates/pipeline/src/proraw.rs +++ b/crates/pipeline/src/proraw.rs @@ -919,7 +919,9 @@ mod tests { let tone = std::sync::Arc::new(curve(PRORAW_TONE_KNOTS, |x| x.powf(0.6))); let info = SourceInfo { raw: true, proraw: Some(tone), ..Default::default() }; let mut s = DevelopSettings::default(); - assert_eq!(s.process.process(), Process::V17); + assert!(s.process.process() >= Process::V17); + assert!(active(&s, &info).is_some(), "the latest process activates ProRAW"); + s.process = Process::V17.version(); assert!(active(&s, &info).is_some(), "V17 activates ProRAW"); s.process = Process::V16.version(); assert!(active(&s, &info).is_none(), "V16 keeps the camera-curve path"); diff --git a/crates/pipeline/src/tests_proraw.rs b/crates/pipeline/src/tests_proraw.rs index 31a57ad7c45..410d4fd543e 100644 --- a/crates/pipeline/src/tests_proraw.rs +++ b/crates/pipeline/src/tests_proraw.rs @@ -75,6 +75,18 @@ fn v17_renders_everything_else_as_v16() { } } +/// V18's curve stage leaves Whites to the ProRAW chain, which applies it itself: Whites alone renders a ProRAW +/// photo as on V17, where a second Whites would brighten it again. +#[test] +fn v18_leaves_proraw_whites_to_the_chain() { + let info = proraw_info(); + let mut s = DevelopSettings::for_raw(5200.0, 4.0); + controls::set(&mut s, "light.whites", 40.0); + let at = |p: Process| deep(&info, &DevelopSettings { process: p.version(), ..s.clone() }); + assert!(at(Process::V18) == at(Process::V17), "Whites applies once"); + assert!(at(Process::V17) != deep(&info, &DevelopSettings { process: Process::V17.version(), ..DevelopSettings::for_raw(5200.0, 4.0) })); +} + #[test] fn v17_keeps_checked_white_balance_and_v9_fallback() { let info = SourceInfo { as_shot_temp: 5500.0, as_shot_tint: 0.0, proraw: None, ..proraw_info() }; From 2722f9793831d6fd20223948b3aa3b59f718787d Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Thu, 3 Dec 2026 16:03:22 +0100 Subject: [PATCH 15/20] fix(curve_stage): Refine Saturation restores the colour after Whites (#523) With Whites alone Refine Saturation did nothing, but with a curve it pulled saturation back to the colour before Whites, so the same Whites setting gave different saturation. Lightroom's Refine Saturation belongs to the tone curve, after Whites, so the stage now keeps a Whites-only table when Refine Saturation is below 100 and restores towards the colour after it, on the CPU and the GPU. Test: refine_saturation_keeps_what_whites_did; curve_stage_matches covers the GPU path. --- crates/gpu/src/params.rs | 5 ++- crates/gpu/src/wgsl/finish.wgsl | 39 ++++++++++++++------- crates/pipeline/src/curve_stage.rs | 56 ++++++++++++++++++++++++------ docs/curve-stage.md | 7 ++-- 4 files changed, 82 insertions(+), 25 deletions(-) diff --git a/crates/gpu/src/params.rs b/crates/gpu/src/params.rs index fbc7eae413f..2b9db6179b4 100644 --- a/crates/gpu/src/params.rs +++ b/crates/gpu/src/params.rs @@ -26,6 +26,7 @@ const FIELDS: &[(&str, usize)] = &[ ("STAGE", 1), ("STAGE_OFF", 1), ("STAGE_REFINE", 1), + ("STAGE_WHITES", 1), ("GAIN", 1), ("EV", 1), ("AIR", 1), @@ -301,7 +302,8 @@ pub fn finish_block(fp: &FinishParams, masks: &[[f32; MASK_TERMS]], present: &Pr let curve_off = aux.len(); let stage_off = curve_off + fp.curves.as_ref().map_or(0, |c| c.len() * CURVE_N as usize); // process V18's stage (red, green, blue, then the base table) or the earlier processes' curves - let tables = fp.curves.iter().flatten().chain(fp.curve_stage.iter().flat_map(|c| c.chan.iter().chain([&c.base]))); + // (and Whites alone after the base table, when Refine Saturation needs it) + let tables = fp.curves.iter().flatten().chain(fp.curve_stage.iter().flat_map(|c| c.chan.iter().chain([&c.base]).chain(c.whites.iter()))); for l in tables { if l.v.len() != CURVE_N as usize { // a wrong-length curve would shift every later aux offset (CURVE_OFF, MASK_OFF and @@ -365,6 +367,7 @@ pub fn finish_block(fp: &FinishParams, masks: &[[f32; MASK_TERMS]], present: &Pr p.b("STAGE", fp.curve_stage.is_some()); p.u("STAGE_OFF", stage_off as u32); p.f("STAGE_REFINE", fp.curve_stage.as_ref().map_or(1.0, |c| c.refine)); + p.b("STAGE_WHITES", fp.curve_stage.as_ref().is_some_and(|c| c.whites.is_some())); p.f("REFINE_SAT", fp.refine_sat); p.f("GAIN", fp.gain); p.f("EV", fp.ev); diff --git a/crates/gpu/src/wgsl/finish.wgsl b/crates/gpu/src/wgsl/finish.wgsl index f42486b12c4..1798b11d355 100644 --- a/crates/gpu/src/wgsl/finish.wgsl +++ b/crates/gpu/src/wgsl/finish.wgsl @@ -137,6 +137,24 @@ fn stage_lut(o: u32, x: f32) -> f32 { // `CurveStage::apply`: the base table on the largest and smallest channel of sRGB-encoded linear ProPhoto, the // middle one keeping its place between them in linear light, then the red, green and blue curves per channel. +// `curve_stage::hue_preserving`: the table at `o` on the largest and smallest channel of `e`, the middle one keeping +// its place between them in linear light (`pc`). Linear, in [0, 1]. +fn stage_hue_preserving(o: u32, e: vec3, pc: vec3, hi: u32, lo: u32) -> vec3 { + let la = srgb_linear(stage_lut(o, e[hi])); + let lb = srgb_linear(stage_lut(o, e[lo])); + let pa = pc[hi]; + let pb = pc[lo]; + var out = vec3(0.0); + for (var k = 0u; k < 3u; k++) { + var t = 1.0; + if (pa > pb) { + t = (pc[k] - pb) / (pa - pb); + } + out[k] = clamp(lb + (la - lb) * t, 0.0, 1.0); + } + return out; +} + fn curve_stage(d: vec3) -> vec3 { let p = mul3(PRO_FROM_2020, d); var pc = clamp(p, vec3(0.0), vec3(1.0)); @@ -152,18 +170,10 @@ fn curve_stage(d: vec3) -> vec3 { } } let off = pu(F_STAGE_OFF); - let base = off + 3u * CURVE_N; - let la = srgb_linear(stage_lut(base, e[hi])); - let lb = srgb_linear(stage_lut(base, e[lo])); - let pa = pc[hi]; - let pb = pc[lo]; + let base = stage_hue_preserving(off + 3u * CURVE_N, e, pc, hi, lo); var curved = vec3(0.0); for (var k = 0u; k < 3u; k++) { - var t = 1.0; - if (pa > pb) { - t = (pc[k] - pb) / (pa - pb); - } - curved[k] = stage_lut(off + k * CURVE_N, srgb_exact(clamp(lb + (la - lb) * t, 0.0, 1.0))); + curved[k] = stage_lut(off + k * CURVE_N, srgb_exact(base[k])); } var q = vec3(0.0); for (var k = 0u; k < 3u; k++) { @@ -171,8 +181,13 @@ fn curve_stage(d: vec3) -> vec3 { } let rs = pf(F_STAGE_REFINE); if (rs < 1.0) { - // the saturation back towards the input's, at the curves' luminance - let rr = refine_saturation(e, curved, rs); + // the saturation back towards the input's after Whites, at the curves' luminance + var reference = e; + if (pu(F_STAGE_WHITES) != 0u) { + let w = stage_hue_preserving(off + 4u * CURVE_N, e, pc, hi, lo); + reference = vec3(srgb_exact(w.x), srgb_exact(w.y), srgb_exact(w.z)); + } + let rr = refine_saturation(reference, curved, rs); var r = vec3(0.0); for (var k = 0u; k < 3u; k++) { r[k] = srgb_linear(clamp(rr[k], 0.0, 1.0)); diff --git a/crates/pipeline/src/curve_stage.rs b/crates/pipeline/src/curve_stage.rs index e7de40c3450..44d983e3eb2 100644 --- a/crates/pipeline/src/curve_stage.rs +++ b/crates/pipeline/src/curve_stage.rs @@ -39,6 +39,9 @@ pub struct CurveStage { pub base: Lut1, /// Refine Saturation, 0..1, on what the curves did (1 when only Whites is set). pub refine: f32, + /// Whites alone, when Refine Saturation is below 1: the saturation it restores is the colour's after Whites, as + /// Lightroom's Refine Saturation belongs to the tone curve and Whites comes before it. + pub whites: Option, } /// A bump of peak 1 at `p / (p + q)`, 0 at black and white and outside them. @@ -250,7 +253,8 @@ impl CurveStage { }); let curves_on = parametric_on || master || chans.iter().any(|b| *b); let refine = if curves_on { (c.refine_saturation / 100.0).clamp(0.0, 1.0) as f32 } else { 1.0 }; - Some(CurveStage { chan, base, refine }) + let whites = w.filter(|_| refine < 1.0); + Some(CurveStage { chan, base, refine, whites }) } /// Linear Rec.2020 in and out (display referred, after the tone map). @@ -272,18 +276,17 @@ impl CurveStage { lo = k; } } - // the base curve on the largest and smallest channel; the middle one keeps its place in linear light - let (la, lb) = (srgb_to_linear(self.base.eval(e[hi])), srgb_to_linear(self.base.eval(e[lo]))); - let (pa, pb) = (pc[hi], pc[lo]); - let curved: [f32; 3] = std::array::from_fn(|k| { - let t = if pa > pb { (pc[k] - pb) / (pa - pb) } else { 1.0 }; - self.chan[k].eval(linear_to_srgb((lb + (la - lb) * t).clamp(0.0, 1.0))) - }); + let base = hue_preserving(&self.base, e, pc, hi, lo); + let curved: [f32; 3] = std::array::from_fn(|k| self.chan[k].eval(linear_to_srgb(base[k]))); let lin = |v: [f32; 3]| v.map(|x| srgb_to_linear(x.clamp(0.0, 1.0))); let mut q = lin(curved); if self.refine < 1.0 { - // the saturation back towards the input's, at the curves' luminance - let r = lin(crate::finish::refine_saturation(e, curved, self.refine)); + // the saturation back towards the input's after Whites, at the curves' luminance + let reference = match &self.whites { + Some(w) => hue_preserving(w, e, pc, hi, lo).map(linear_to_srgb), + None => e, + }; + let r = lin(crate::finish::refine_saturation(reference, curved, self.refine)); let y = |v: [f32; 3]| PRO_Y[0] * v[0] + PRO_Y[1] * v[1] + PRO_Y[2] * v[2]; let (yq, yr) = (y(q), y(r)); q = if yr > 1e-6 { r.map(|v| v * yq / yr) } else { r }; @@ -297,6 +300,17 @@ impl CurveStage { } } +/// `table` on the largest and smallest channel of the encoded colour `e` (`pc` in linear light, `hi` and `lo` its +/// largest and smallest channel); the middle one keeps its place between them in linear light. Linear, in [0, 1]. +fn hue_preserving(table: &Lut1, e: [f32; 3], pc: [f32; 3], hi: usize, lo: usize) -> [f32; 3] { + let (la, lb) = (srgb_to_linear(table.eval(e[hi])), srgb_to_linear(table.eval(e[lo]))); + let (pa, pb) = (pc[hi], pc[lo]); + std::array::from_fn(|k| { + let t = if pa > pb { (pc[k] - pb) / (pa - pb) } else { 1.0 }; + (lb + (la - lb) * t).clamp(0.0, 1.0) + }) +} + /// Linear Rec.2020 to linear ProPhoto and back, built once. fn matrices() -> &'static ([[f32; 3]; 3], [[f32; 3]; 3]) { static M: std::sync::OnceLock<([[f32; 3]; 3], [[f32; 3]; 3])> = std::sync::OnceLock::new(); @@ -441,6 +455,28 @@ mod tests { assert!(!ParametricGraph::new(&v17).is_fitted()); } + /// Refine Saturation restores the colour after Whites, not before it: at 0, a curve on top of Whites leaves the + /// saturation Whites gives a colour, as Whites alone does (review on #4099). + #[test] + fn refine_saturation_keeps_what_whites_did() { + let sat = |d: [f32; 3]| { + let p = mul3(&matrices().0, d); + let (hi, lo) = (p[0].max(p[1]).max(p[2]), p[0].min(p[1]).min(p[2])); + (hi - lo) / hi + }; + let colour = mul3(&matrices().1, [0.9, 0.6, 0.3]); + let mut s = v18(); + s.light.whites = 80.0; + let alone = CurveStage::new(&s).expect("Whites").apply(colour); + s.curve.master = vec![Point { x: 0.0, y: 0.0 }, Point { x: 0.5, y: 0.56 }, Point { x: 1.0, y: 1.0 }]; + s.curve.refine_saturation = 0.0; + let refined = CurveStage::new(&s).expect("Whites and a curve").apply(colour); + let whites_did = (sat(alone) - sat(colour)).abs(); + assert!(whites_did > 0.05, "Whites changes the saturation: {} vs {}", sat(alone), sat(colour)); + // close to Whites alone, not pulled back towards the colour before Whites + assert!((sat(refined) - sat(alone)).abs() < 0.3 * whites_did, "refined {} vs Whites alone {}", sat(refined), sat(alone)); + } + /// In every region, the amount a drag picks moves the drawn curve by the drag's motion. #[test] fn a_graph_drag_puts_the_fitted_curve_where_the_hand_is() { diff --git a/docs/curve-stage.md b/docs/curve-stage.md index 0fa6cdd39a3..bae39227000 100644 --- a/docs/curve-stage.md +++ b/docs/curve-stage.md @@ -33,8 +33,10 @@ After the tone map and V4's calibrated Contrast and Blacks, before the colour st 3. Apply the base table to the largest and smallest channel. The middle channel keeps its relative position between them in linear light. 4. Apply the red, green and blue point curves to each channel. -5. Refine Saturation (below 100) moves saturation back towards the input's, as in V17, and then rescales to the - curves' linear luminance, so the tone change stays. +5. Refine Saturation (below 100) moves saturation back towards the colour after Whites, and then rescales to the + curves' linear luminance, so the tone change stays. In Lightroom it belongs to the tone curve, and Whites comes + before it, so Whites keeps its saturation change whether a curve is set or not (V17 and earlier refine on encoded + output, where there is no Whites). 6. Values above SDR white (an HDR render) continue with slope 1. The tone map no longer applies Whites under V18 (`finish::base_tone`), and the V17 output-curve tables are not built @@ -111,3 +113,4 @@ predicted from the grey-step curves under the hue-preserving rule in step 3. The | 2026-12-02 | patch | Renumbered from V9 to V17, on top of V16: main retired 9 | | 2026-11-24 | minor | Whites and the regions are a fitted model instead of measured tables | | 2026-12-03 | patch | Renumbered from V17 to V18, on top of V17: main took 17 for Apple ProRAW (#4196) | +| 2026-12-03 | patch | Refine Saturation restores the colour after Whites, so Whites alone and Whites with a curve agree (review on #4099) | From 5a58233158f51ca335b495e86b6ecf38b5900d7c Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Thu, 3 Dec 2026 16:13:51 +0100 Subject: [PATCH 16/20] fix(curve_input): under V18 sample where the curve stage reads (#523) The V18 curves act on sRGB-encoded linear ProPhoto right after the tone map, but the curve editor's input histogram was taken after the colour tools, gamut mapping and output encoding. Under V18 the sample is now taken right after the stage built from the curve's predecessors, in its domain, with headroom kept above 1. The output-domain tests name V17, where that domain still holds. Test: v18_samples_where_the_curve_stage_reads_not_after_the_colour_tools. --- crates/pipeline/src/curve_input.rs | 5 ++++- crates/pipeline/src/curve_input_tests.rs | 25 +++++++++++++++++++++--- crates/pipeline/src/finish.rs | 11 +++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/crates/pipeline/src/curve_input.rs b/crates/pipeline/src/curve_input.rs index 400740d9014..a846f184b2a 100644 --- a/crates/pipeline/src/curve_input.rs +++ b/crates/pipeline/src/curve_input.rs @@ -111,6 +111,8 @@ pub(crate) fn finish( let predecessors = DevelopSettings { curve: input.predecessors(&settings.curve), ..settings.clone() }; fp.curves = if settings.process.process() < Process::V18 { crate::finish::curve_luts(&predecessors.curve) } else { None }; fp.curve_stage = crate::curve_stage::CurveStage::new(&predecessors); + // V18's curves read sRGB-encoded linear ProPhoto after the tone map: sample there, not after the colour tools + fp.sample_at_curve_stage = settings.process.process() >= Process::V18; fp.refine_sat = 1.0; // the samples, and the 8-bit pixels as `finish` dithers them at the same place in the output let samples = crate::finish::finish_with(p, &fp, false, true, |x, y, e| { @@ -118,7 +120,8 @@ pub(crate) fn finish( (e, [crate::finish::enc(e[0], d), crate::finish::enc(e[1], d), crate::finish::enc(e[2], d), 255]) }); let (samples, data): (Vec<[f32; 3]>, Vec<[u8; 4]>) = samples.into_iter().unzip(); - let histogram = of_encoded(&samples, fp.out_luma); + let weights = if fp.sample_at_curve_stage { crate::light_v3::PRO_Y } else { fp.out_luma }; + let histogram = of_encoded(&samples, weights); let image = Rgba8 { width: w, height: h, data }; Rendered { image, histogram, deep: None } } diff --git a/crates/pipeline/src/curve_input_tests.rs b/crates/pipeline/src/curve_input_tests.rs index 5426374ccf1..5b50dbb923e 100644 --- a/crates/pipeline/src/curve_input_tests.rs +++ b/crates/pipeline/src/curve_input_tests.rs @@ -55,9 +55,11 @@ fn input_follows_exposure_but_not_its_own_curve_or_later_curves() { assert_ne!(a.image, b.image); } +/// Up to V17 the curves act on the encoded output, so a curve's input is the output of its predecessors. (V18: +/// `v18_samples_where_the_curve_stage_reads_not_after_the_colour_tools`.) #[test] fn each_curve_sees_exactly_its_predecessors_including_profile_contributions() { - let mut s = DevelopSettings::default(); + let mut s = DevelopSettings { process: lightcraft_develop::Process::V17.version(), ..DevelopSettings::default() }; s.profile.id = "lc.film.golden-hour".into(); s.curve.shadows = 45.0; s.curve.master = bent(); @@ -171,7 +173,8 @@ fn diagnostic_and_normal_renders_share_spatial_cache_without_changing_pixels() { fn input_uses_the_display_primaries_and_effective_edit() { let src = source(); let info = SourceInfo::default(); - let mut s = DevelopSettings::default(); + // up to V17 the curves act on the encoded output, in the display's primaries (V18's read ProPhoto) + let mut s = DevelopSettings { process: lightcraft_develop::Process::V17.version(), ..DevelopSettings::default() }; s.light.exposure = 1.0; s.curve.lights = 55.0; s.curve.master = bent(); @@ -181,7 +184,7 @@ fn input_uses_the_display_primaries_and_effective_edit() { let mut effective = s.effective().into_owned(); effective.curve = CurveInput::Red.predecessors(&effective.curve); assert_eq!(disabled.image, crate::render(&src, &info, &effective, &req).image); - let mut previous = DevelopSettings::default(); + let mut previous = DevelopSettings { process: lightcraft_develop::Process::V17.version(), ..DevelopSettings::default() }; previous.curve.lights = 45.0; let srgb = render(&src, &info, &previous, &req, None, CurveInput::Red).unwrap(); for space in [OutputSpace::DisplayP3, OutputSpace::Rec2020] { @@ -220,3 +223,19 @@ fn an_over_budget_brush_mask_fails_the_sample_instead_of_dropping_strokes() { s.masks.push(brush(vec![stroke(0.2, 0.6)])); assert!(render(&source(), &SourceInfo::default(), &s, &full_size, None, CurveInput::Master).is_ok()); } + +/// Under V18 the curves read the colour where the curve stage runs, after the tone map and before the colour tools: +/// Saturation, which comes after them, leaves every curve's input alone; on V17 it is part of it (review on #4076). +#[test] +fn v18_samples_where_the_curve_stage_reads_not_after_the_colour_tools() { + use lightcraft_develop::Process; + for ch in [CurveInput::Parametric, CurveInput::Master, CurveInput::Red] { + let on = |p: Process, saturation: f64| { + let mut s = DevelopSettings { process: p.version(), ..DevelopSettings::default() }; + s.color.saturation = saturation; + sample(&s, ch).histogram + }; + assert_eq!(on(Process::V18, -100.0), on(Process::V18, 0.0), "V18 {ch:?}: Saturation is after the curves"); + assert_ne!(on(Process::V17, -100.0), on(Process::V17, 0.0), "V17 {ch:?}: the curves read the encoded output"); + } +} diff --git a/crates/pipeline/src/finish.rs b/crates/pipeline/src/finish.rs index fc43dcb741e..3491a41e19f 100644 --- a/crates/pipeline/src/finish.rs +++ b/crates/pipeline/src/finish.rs @@ -275,6 +275,9 @@ pub struct FinishParams { pub curves: Option<[Lut1; 3]>, /// Process V18's Whites and tone curves (they replace `curves`, which stays `None` from V18 on). pub curve_stage: Option, + /// A curve-input sample ([`crate::curve_input`]) under V18 is taken where the curve stage reads: right after it, as + /// sRGB-encoded linear ProPhoto, before the colour tools and the output. + pub sample_at_curve_stage: bool, /// Refine Saturation as 0..1 (1 = the curves' own saturation). pub refine_sat: f32, pub vig: Option, @@ -368,6 +371,7 @@ impl FinishParams { ops: ColorOps::new(s), curves: if s.process.process() < Process::V18 { curve_luts(&s.curve) } else { None }, // Apple ProRAW's chain applies Whites itself (`crate::proraw`), so its curve stage keeps only the curves + sample_at_curve_stage: false, curve_stage: match &proraw { Some(_) => { let mut no_whites = s.clone(); @@ -608,6 +612,7 @@ pub(crate) fn finish_with( let preview_light = if exact { None } else { light.as_ref().and_then(|lo| crate::light_v3::PreviewOps::new(lo, &|v| encode_srgb(srgb, v))) }; let peak = fp.peak; let hdr = peak > 1.0; + let to_pro = crate::light_v3::prophoto_matrices().0; let mut out = vec![T::default(); w * h]; // the vignette splits into a column term and a row term, so each is computed once let vig_fall = vig.as_ref().map(|v| VigFalloff::new(v, aspect)); @@ -653,6 +658,12 @@ pub(crate) fn finish_with( // --- process V18: Whites and the tone curves, hue-preserving d = fp.curve_stage.as_ref().map_or(d, |stage| stage.apply(d)); + if stop_after_curves && fp.sample_at_curve_stage { + let pro = mul3(&to_pro, d); + // (above SDR white stays above 1, beyond the curve's axes, as on the output path) + *px = store(vx_u + x, vy_u + y, pro.map(|v| linear_to_srgb(v.max(0.0)))); + continue; + } // --- colour d = fp.ops.apply(d, l_sat, l_hue); From de0c5a8dc332d53073530fed7e180e7b7ed52e71 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Thu, 3 Dec 2026 16:14:18 +0100 Subject: [PATCH 17/20] fix(tools): the tone charts' manifest carries the tool's prefix and fit can read it from the chart folder (#523) fit read manifest.json from RENDER_DIR while charts wrote it to OUT_DIR, and a second chart tool in the same folder overwrote it. charts now writes curve__manifest.json, as its DNGs are named, and fit takes an optional CHART_DIR. --- docs/curve-stage.md | 3 ++- tools/lr_tone_charts.py | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/curve-stage.md b/docs/curve-stage.md index bae39227000..4f679b508c9 100644 --- a/docs/curve-stage.md +++ b/docs/curve-stage.md @@ -72,7 +72,8 @@ Whites is not part of the graph, as in Lightroom. patches, with the settings in the DNG's XMP. It writes one neutral chart, Whites at each measured amount, and each parametric region at each measured amount. The charts are original test data. Every chart was rendered through Camera Raw to a 16-bit Adobe RGB (1998) TIFF. Only that output is measured, and nothing of Adobe's is copied or -shipped, and no measurement is committed. `tools/lr_tone_charts.py fit RENDER_DIR OUT_RS` reads the grey steps of +shipped, and no measurement is committed. `tools/lr_tone_charts.py fit RENDER_DIR OUT_RS [CHART_DIR]` takes the charts' `curve__manifest.json` from CHART_DIR +(RENDER_DIR when the renders sit beside the charts), reads the grey steps of each render as sRGB-encoded linear ProPhoto values, fits the model to them and writes only its constants, `curve_stage_model.rs`. It needs numpy, scipy and tifffile (`tools/requirements-lr-tone-charts.txt`). Running the tool again reproduces the committed charts byte for byte, and the constants with the pinned packages. diff --git a/tools/lr_tone_charts.py b/tools/lr_tone_charts.py index 3fb4fbf7716..4526334ba1e 100644 --- a/tools/lr_tone_charts.py +++ b/tools/lr_tone_charts.py @@ -1,12 +1,12 @@ #!/usr/bin/env python3 -"""Measure Lightroom's Whites and parametric curve on synthetic grey steps (process V9, docs/curve-stage.md). +"""Measure Lightroom's Whites and parametric curve on synthetic grey steps (process V18, docs/curve-stage.md). python3 tools/lr_tone_charts.py charts OUT_DIR Writes linear DNG charts (48 grey steps plus colour patches) with the settings embedded as XMP: one neutral chart, Whites at +-25/50/100 and each parametric region at +-25/50/75/100 (default splits). (render every DNG through Camera Raw to a 16-bit Adobe RGB (1998) TIFF with the same file name) - python3 tools/lr_tone_charts.py fit RENDER_DIR OUT_RS - Reads the renders, fits LightCraft's model of each setting to them and writes the model's constants + python3 tools/lr_tone_charts.py fit RENDER_DIR OUT_RS [CHART_DIR] + Reads the renders (and the charts' `curve__manifest.json` from CHART_DIR, by default RENDER_DIR), fits LightCraft's model of each setting to them and writes the model's constants (`lightcraft_pipeline::curve_stage_model`). The measurements themselves are not written out. The charts are original test data generated here; nothing in them comes from Adobe. Only Camera Raw's output is @@ -236,9 +236,10 @@ def residual(params): return best.x, float(np.sqrt((e ** 2).mean())), float(np.abs(e).max()) -def fit(render_dir, out_rs): +def fit(render_dir, out_rs, chart_dir=None): """Fit the model to the Camera Raw renders in `render_dir` and write its constants to `out_rs`.""" - patches = json.load(open(os.path.join(render_dir, "manifest.json")))["patches"] + # the manifest carries the tool's prefix, as its charts do, so another chart tool's in the same folder is left alone + patches = json.load(open(os.path.join(chart_dir or render_dir, "curve__manifest.json")))["patches"] tif = lambda n: os.path.join(render_dir, f"curve__{n}.tif") n0 = grey_levels(tif("neutral"), patches) rows = lambda names: [delta_table(n0, grey_levels(tif(n), patches)) for n in names] @@ -277,16 +278,16 @@ def fit(render_dir, out_rs): def main(): - """Command line: `charts OUT_DIR` or `fit RENDER_DIR OUT_RS`.""" + """Command line: `charts OUT_DIR` or `fit RENDER_DIR OUT_RS [CHART_DIR]`.""" if len(sys.argv) == 3 and sys.argv[1] == "charts": out = sys.argv[2] os.makedirs(out, exist_ok=True) img, patches = chart() - json.dump(dict(patches=patches), open(os.path.join(out, "manifest.json"), "w")) + json.dump(dict(patches=patches), open(os.path.join(out, "curve__manifest.json"), "w")) for name, settings in variants().items(): write_dng(os.path.join(out, f"curve__{name}.dng"), img, xmp(**settings)) - elif len(sys.argv) == 4 and sys.argv[1] == "fit": - fit(sys.argv[2], sys.argv[3]) + elif len(sys.argv) in (4, 5) and sys.argv[1] == "fit": + fit(*sys.argv[2:]) else: sys.exit(__doc__) From 023c93c0e03f4a77eaa41d6c54c05195ded8ad63 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Thu, 3 Dec 2026 16:46:11 +0100 Subject: [PATCH 18/20] test(gpu): the curve-input prefix test names V17, where the sample is the predecessors' output (#523) --- crates/gpu/tests/it/equivalence.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/gpu/tests/it/equivalence.rs b/crates/gpu/tests/it/equivalence.rs index 4ae1b6a2883..2aade0e3e05 100644 --- a/crates/gpu/tests/it/equivalence.rs +++ b/crates/gpu/tests/it/equivalence.rs @@ -233,7 +233,9 @@ fn curve_input_matches_the_gpu_prefix_and_keeps_later_operations_out() { let v = 0.01 + x as f32 / 500.0; [v, v * (0.25 + y as f32 / 100.0), v * 0.4] })); - let mut s = DevelopSettings::default(); + // up to V17 the curves act on the encoded output, so a curve's input is the output of its predecessors; V18 samples + // where its curve stage reads (`lightcraft_pipeline` `v18_samples_where_the_curve_stage_reads_not_after_the_colour_tools`) + let mut s = DevelopSettings { process: Process::V17.version(), ..DevelopSettings::default() }; s.light.exposure = 0.5; s.curve.shadows = 45.0; s.curve.master = vec![Point::new(0.0, 0.04), Point::new(0.25, 0.65), Point::new(1.0, 0.95)]; From a8872ab7242dc1df10d9b385d8a759afebfd3ad0 Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Thu, 3 Dec 2026 17:49:00 +0100 Subject: [PATCH 19/20] fix(curve_input): on ProRAW the sample's curve stage leaves Whites to the chain, as the render's does; docs say V4 to V17 keep V2 Whites (#523) curve_input rebuilt the curve stage from the predecessors with Whites in it, so on Apple ProRAW under V18 the editor's input histogram applied Whites twice. Both now build it with finish::curve_stage_for. Test: proraw_curve_input_applies_whites_once. Gaps, parity-checklist and process-versions no longer call Whites a pending follow-up and name the ProRAW exception (review on #4076). --- crates/pipeline/src/curve_input.rs | 2 +- crates/pipeline/src/curve_input_tests.rs | 17 +++++++++++++++++ crates/pipeline/src/finish.rs | 23 ++++++++++++++--------- docs/gaps.md | 2 +- docs/parity-checklist.md | 4 ++-- docs/process-versions.md | 2 +- 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/crates/pipeline/src/curve_input.rs b/crates/pipeline/src/curve_input.rs index a846f184b2a..134184a7c46 100644 --- a/crates/pipeline/src/curve_input.rs +++ b/crates/pipeline/src/curve_input.rs @@ -110,7 +110,7 @@ pub(crate) fn finish( // only the predecessors, wherever the process applies its curves (encoded output, or V18's curve stage) let predecessors = DevelopSettings { curve: input.predecessors(&settings.curve), ..settings.clone() }; fp.curves = if settings.process.process() < Process::V18 { crate::finish::curve_luts(&predecessors.curve) } else { None }; - fp.curve_stage = crate::curve_stage::CurveStage::new(&predecessors); + fp.curve_stage = crate::finish::curve_stage_for(&predecessors, fp.proraw.is_some()); // V18's curves read sRGB-encoded linear ProPhoto after the tone map: sample there, not after the colour tools fp.sample_at_curve_stage = settings.process.process() >= Process::V18; fp.refine_sat = 1.0; diff --git a/crates/pipeline/src/curve_input_tests.rs b/crates/pipeline/src/curve_input_tests.rs index 5b50dbb923e..f0c1caba7a0 100644 --- a/crates/pipeline/src/curve_input_tests.rs +++ b/crates/pipeline/src/curve_input_tests.rs @@ -239,3 +239,20 @@ fn v18_samples_where_the_curve_stage_reads_not_after_the_colour_tools() { assert_ne!(on(Process::V17, -100.0), on(Process::V17, 0.0), "V17 {ch:?}: the curves read the encoded output"); } } + +/// On Apple ProRAW the chain applies Whites, so the curve stage the sample is built with leaves it out, as the render's +/// does: Whites alone gives no stage, a curve a stage of its own (review on #4076). +#[test] +fn proraw_curve_input_applies_whites_once() { + use lightcraft_develop::Process; + let mut s = DevelopSettings { process: Process::V18.version(), ..DevelopSettings::default() }; + s.light.whites = 40.0; + assert!(crate::finish::curve_stage_for(&s, false).is_some(), "elsewhere the stage applies Whites"); + assert!(crate::finish::curve_stage_for(&s, true).is_none(), "on ProRAW the chain does"); + s.curve.master = bent(); + let with_curve = crate::finish::curve_stage_for(&s, true).expect("the curve"); + let mut alone = s.clone(); + alone.light.whites = 0.0; + let curve_only = crate::finish::curve_stage_for(&alone, false).expect("the curve"); + assert_eq!(with_curve.base.v, curve_only.base.v, "the ProRAW stage is the curve without Whites"); +} diff --git a/crates/pipeline/src/finish.rs b/crates/pipeline/src/finish.rs index 3491a41e19f..dca1fdf0d2c 100644 --- a/crates/pipeline/src/finish.rs +++ b/crates/pipeline/src/finish.rs @@ -370,16 +370,8 @@ impl FinishParams { lut: crate::lut::get(&s.profile.id).map(|l| (l, (s.profile.amount / 100.0).clamp(0.0, 2.0) as f32)), ops: ColorOps::new(s), curves: if s.process.process() < Process::V18 { curve_luts(&s.curve) } else { None }, - // Apple ProRAW's chain applies Whites itself (`crate::proraw`), so its curve stage keeps only the curves sample_at_curve_stage: false, - curve_stage: match &proraw { - Some(_) => { - let mut no_whites = s.clone(); - no_whites.light.whites = 0.0; - crate::curve_stage::CurveStage::new(&no_whites) - } - None => crate::curve_stage::CurveStage::new(s), - }, + curve_stage: curve_stage_for(s, proraw.is_some()), refine_sat: (s.curve.refine_saturation / 100.0).clamp(0.0, 1.0) as f32, vig: if effects { vignette(s) } else { None }, to_out: space.from_working(), @@ -515,6 +507,19 @@ pub fn base_tone(s: &DevelopSettings, info: &SourceInfo, peak: f32) -> ToneMap { } } +/// The curve stage of `s` ([`crate::curve_stage`]). Apple ProRAW's chain applies Whites itself (`crate::proraw`), so +/// on ProRAW (`proraw`) the stage keeps only the curves. The render and the curve editor's input sample +/// ([`crate::curve_input`]) both build it here, so Whites applies once in each. +pub(crate) fn curve_stage_for(s: &DevelopSettings, proraw: bool) -> Option { + if proraw && s.light.whites != 0.0 { + let mut no_whites = s.clone(); + no_whites.light.whites = 0.0; + crate::curve_stage::CurveStage::new(&no_whites) + } else { + crate::curve_stage::CurveStage::new(s) + } +} + /// Finish the prepared pipeline stages into an 8-bit RGBA image in `space` (or `display`). pub(crate) fn finish(p: &Prepared, s: &DevelopSettings, frame: &Frame, info: &SourceInfo, req: &crate::RenderRequest) -> Rgba8 { let (space, display, proof) = (req.space, req.display.as_ref(), req.proof); diff --git a/docs/gaps.md b/docs/gaps.md index e66efd85c1b..4691d3e25a9 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -17,7 +17,7 @@ Hours are Opus 5.5 agent wall-clock hours (see [target-app-parity.md](target-app |---:|---|---|---|---:|---| | 1 B | **Camera colour is estimated, not measured** (LR-PROF-CAMERACOLOR). Raws start from a per-file fit to the camera JPEG, 10 bundled profiles, 52 spectral matrices (plus same-sensor bodies, e.g. the X-T30 through the X-T3) or chart-measured matrices (the EOS D60); others use a neutral matrix (a black-and-white camera JPEG gives its tone curve only, #577; dark JPEG tones also guide the toe, #1307) | ΔE vs camera JPEG 2.9–10 after fitting (raw-parity.md); 1 chart-calibrated model (EOS D60: its Kelvin scale and fallback colour, the look stays the JPEG fit) vs 1,500 Adobe Standard profiles | every raw shooter sees colour that is close but not Lightroom's; some get neutral-matrix colour | 50–90 | [raw-parity](raw-parity.md#colour) | | 2 B | **CR3 variants no public file uses** (LR-IMP-FORMATS): `crx.rs` refuses vertical-tile C-RAW, partial-subband and other plane coding, multi-tile 0x200 and adaptive low-frequency gains, and those files fall back to the preview. All 110 CC0 CR3s on raw.pixls.us (31 folders) decode from sensor data, so none of these variants has a public sample; 26 CR3 bodies are verified (M50 / R100 / R8 exact, R5 Mark II pinned, 22 more pinned on one CC0 file each and checked against the camera JPEG, [cr3.md](cr3.md#further-bodies-one-cc0-file-each)). HEIF stills are `.HIF` files, not CR3; no CR3 sRAW / mRAW sample exists | measured: Canon's share whose camera fully works 73% → 94% (raw-parity.md); 18 of 22 popular Canon bodies write CR3, all 18 now verified | +0.3 points of photographers; the variants surface only as user files that open as a preview | 10–25 | [raw-parity](raw-parity.md#remaining-work-ranked-by-photographers-unlocked-per-hour) | -| 3 B | **Render fidelity partial** (LR-BEHAV-RENDER-FIDELITY): calibrated camera-look Contrast and Blacks; other operators need measurement; from process V5 raw tone curves roll off into white in stops, so Exposure keeps recorded highlights (#1632); from process V17 Apple ProRAW takes Lightroom's fitted tone chain; from V18 Whites and the parametric curve at its default splits are measured against Camera Raw, and the point curves (still LightCraft's spline) apply hue preserving as Lightroom's do ([curve-stage.md](curve-stage.md)) | process V3 reduces held-out response error from 0.136 to 0.038 stops for Contrast and 0.424 to 0.077 for Blacks on one Sony camera; Whites remains V2 pending a follow-up | imported Lightroom edits still differ, especially on uncalibrated operators and cameras | 30–60 | [calibrated Light operators](light-v3.md), [process versions](process-versions.md) | +| 3 B | **Render fidelity partial** (LR-BEHAV-RENDER-FIDELITY): calibrated camera-look Contrast and Blacks; other operators need measurement; from process V5 raw tone curves roll off into white in stops, so Exposure keeps recorded highlights (#1632); from process V17 Apple ProRAW takes Lightroom's fitted tone chain; from V18 Whites and the parametric curve at its default splits are measured against Camera Raw, and the point curves (still LightCraft's spline) apply hue preserving as Lightroom's do ([curve-stage.md](curve-stage.md)) | process V3 reduces held-out response error from 0.136 to 0.038 stops for Contrast and 0.424 to 0.077 for Blacks on one Sony camera; V4 to V17 keep V2 Whites; V18's Whites is fitted to Camera Raw's grey-step charts, not yet checked on photos per camera | imported Lightroom edits still differ, especially on uncalibrated operators and cameras | 30–60 | [calibrated Light operators](light-v3.md), [process versions](process-versions.md) | | 4 | ~~Original-pixel detail at 100%~~ (LR-VIEW-ZOOM): closed 2026-10-12, see Closed recently | checklist row ✅ | — | 0 | [ui-parity](ui-parity.md) | | 5 B | **AI masks: Subject, Sky, People, Background, Landscape** are heuristics; Object / Describe run SAM 3 but its download has no mirror configured | `crates/segment`; ai-masks.md; MASK rows 67% | masking is how most Lightroom users edit today | 40–70 + model decision | [target-app-parity](target-app-parity.md#ai) | | 6 | **Compressed ORF** (support withdrawn) | #3775 decoder removed pending provenance review; uncompressed support remains | compressed files use embedded JPEG previews when available, not sensor data | pending review | [orf-compression](orf-compression.md) | diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index ceac64a8484..579f433283d 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -188,7 +188,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-EDIT-LIGHT-CONTRAST | Contrast | P0 | 🟡 | `ctl:light.contrast` | From process V4, global Contrast on the camera-look path is fitted per channel in ProPhoto with the sRGB transfer. Check response error 0.136 to 0.038 stops on six held-out Sony photos. Other sources and local adjustments retain V2; broader parity remains unverified (`docs/light-v3.md`). | | LR-EDIT-LIGHT-HIGHLIGHTS | Highlights | P0 | ✅ | `ctl:light.highlights`, `crates/raw/src/highlight.rs` | sensor-clipped highlights stay neutral when Highlights (or Exposure, Whites) darkens them: fully clipped content is rebuilt to the neutral of the colour model applied after it, partly clipped content takes its colour from reliable unclipped content nearby (not from dark objects, lens fringes or another surface beside it) and white where there is none, and pale partly clipped content (a white sky) turns white on its way to clipping (#523); binned previews and thumbnails decide clipping per sample before averaging (`develop_binned_masked`, `highlight::reconstruct_masked`), so a block with one clipped specular sample keeps its mean instead of jumping to the clip level, which reconstruction turned into green speckles at 500 px (#548) From process V2 the Highlights/Shadows base is the edge-aware filter of the 0.15 %-of-long-edge median of log luminance: twigs and fine texture take their surroundings' shift, so bright areas keep their local contrast as with Exposure (V1's base kept ~0.6 of it at −100, #632); region edges stay sharp; from process V8 (`local::detail_free`: clamped between the median at that radius and one 3× wider) lettering keeps clean gaps (the median alone turned them into blocks of the letters' tone). Alt/Option-drag shows highlight clipping | | LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | From process V2, the same base as Highlights: dark areas keep their local contrast when lifted (#632); from process V8, the gaps in dark lettering on a bright panel are not lifted into bright blocks. Alt/Option-drag shows shadow clipping (white, clipped channels in colour). From process V13 the global amount eases off as it grows: the operator's strength is `a / (1 + 1.33·abs(a))` for `a` = slider / 100 (0.43 at +100, against 1 up to V10), fitted to Lightroom exports (#523). | -| LR-EDIT-LIGHT-WHITES | Whites | P0 | 🟡 | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | From process V18 Whites is measured against Camera Raw renders of synthetic grey steps and reaches into the midtones as Lightroom's does ([curve-stage.md](curve-stage.md)); not yet compared on photos per camera. V4 to V17 preserve V2 Whites for both signs; measured V2 check response error is 0.075 stops on the Sony test photos (`docs/light-v3.md`). Alt/Option-drag shows highlight clipping (black, clipped channels in colour) | +| LR-EDIT-LIGHT-WHITES | Whites | P0 | 🟡 | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | From process V18 Whites is measured against Camera Raw renders of synthetic grey steps and reaches into the midtones as Lightroom's does ([curve-stage.md](curve-stage.md)); not yet compared on photos per camera. V4 to V17 preserve V2 Whites for both signs, and Apple ProRAW keeps Whites in V17's chain under V18 too; measured V2 check response error is 0.075 stops on the Sony test photos (`docs/light-v3.md`). Alt/Option-drag shows highlight clipping (black, clipped channels in colour) | | LR-EDIT-LIGHT-BLACKS | Blacks | P0 | 🟡 | `ctl:light.blacks`, `crates/pipeline/src/visualize.rs` | From process V4, global Blacks on the camera-look path uses a fitted per-channel/luminance mix. Check response error 0.424 to 0.077 stops on six held-out Sony photos; deepest tones still differ. Other sources and local adjustments retain V2 (`docs/light-v3.md`). Alt/Option-drag shows shadow clipping (white, clipped channels in colour) | | LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | from process V18 the regions are LightCraft's model fitted to Camera Raw's measured response at the default splits, broad and additive ([curve-stage.md](curve-stage.md)); the graph draws the curve the photo renders (`ParametricGraph`: the fitted regions under V18 at the default splits, else the analytic model); dragging the line moves the region under the pointer (one undo step); sampled selected-curve input backdrop (#987); [stage and sampling limits](tone-curve-input.md) | | LR-EDIT-LIGHT-CURVE-POINT | Point curve | P0 | ✅ | `cmd:develop.curve`, `cmd:curve.reset`, `cmd:curve.presets`, `cmd:curve.applyPreset`, `cmd:curve.savePreset`, `cmd:curve.deletePreset`, `cmd:curve.importPresets`, `cmd:curve.exportPresets`, `cmd:file.importCurvePresets`, `cmd:file.exportCurvePresets`, `crates/engine/src/cmd/curves.rs`, `crates/ui-egui/src/panels/edit.rs` | click to add a point; drag a point in both axes (between its neighbours, input / output readout, one undo step per drag; ⌥-drag moves it a tenth as far for fine adjustment, issue #1363); drag empty space to add and drag; double-click removes; reset: double-click a channel selector (that channel), the Reset button under the graph (every curve incl. parametric) or right-click the graph (channel / all); Point Curve preset dropdown: own Linear / Medium Contrast / Strong Contrast, user presets (save the current point curves, delete by right-click; saved with the library), import / export as `.lccurve` JSON; from process V18 the master curve keeps hue as Lightroom's does (largest and smallest channel through the curve, the middle one in proportion), and the red, green and blue curves follow it per channel ([curve-stage.md](curve-stage.md)); sampled input after Parametric, independent of this curve (#987); [stage and sampling limits](tone-curve-input.md) | @@ -472,7 +472,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-BEHAV-OFFLINE | Offline editing | P1 | ✅ | | local-first: everything works offline | | LR-BEHAV-WEB-SAFETY | Library safety in the browser build | P1 | 🟡 | `cmd:file.backupLibrary`, `cmd:file.restoreLibrary`, `apps/lightcraft-web/src/safety.rs`, `apps/lightcraft-web/src/backup.rs`, `apps/lightcraft-web/src/files.rs` | web only (experimental): Back Up Library (zip of the catalog and every stored original) and a non-destructive Restore; failed saves show as unsaved and are retried; a photo that can't be stored isn't added; one tab per library (Web Locks); notices for storage that isn't persistent and for a library that can't open; `?reset` asks first; a panic shows a message. Missing: `?safe` start, deleting originals of removed photos, zip64 (backups > 4 GB) | | LR-BEHAV-GPU | GPU acceleration | P0 | ✅ | `crates/gpu/src/render.rs`, `cmd:app.gpu`, `docs/gpu-pipeline.md`, `crates/ui-egui/src/panels/notices.rs` | CPU fallback per render on device limits, out of memory, device errors / loss, incomplete or black results (`perf.gpuReason`, `perf.gpuFallback`; each render reports its own reason — `lightcraft_gpu::try_render`, `gpuFallback` per exported file — issue #675); short submissions for slow iGPUs; backend choice (DX12 only on Windows, `LIGHTCRAFT_GPU_BACKEND` / `WGPU_BACKEND`), device created after the window opens, crash sentinel (issue #136); a GPU lost while LightCraft runs (driver reset) stops it with that message and turns GPU rendering off for the next start, which says why (issue #1337; the window's renderer can't survive the lost device); quitting waits (up to 2 s) for renders in flight and starts no new GPU work, so none is inside the driver when the process exits (`crates/gpu/src/exit.rs`, issue #620; seen crashing only on Linux + NVIDIA, other drivers unverified); with GPU rendering on and no adapter found at all (e.g. no Vulkan loader on NixOS outside `nix develop`), the desktop app says once per session that it renders on the CPU and points to Help ▸ System Info (`gpu_notice`; not when the GPU is turned off or only a software adapter exists); no tiling beyond the buffer limit (CPU) | -| LR-BEHAV-RENDER-FIDELITY | Rendering matches Lightroom | P1 | 🟡 | `crates/pipeline/src/lib.rs`, `crates/pipeline/src/tone.rs`, `crates/pipeline/src/proraw.rs` | Process V4 calibrates global camera-look Contrast and Blacks against black-box Lightroom exports of Sony ILCE-7CR photos. Held-out response errors are 0.038 and 0.077 stops; V1/V2 keep their rendering. Whites retains V2 and awaits a follow-up. Exposure, Highlights/Shadows, other operators and broader camera coverage remain open (`docs/light-v3.md`). From process V18 Whites, the parametric curve (at the default splits; moved splits keep the analytic model) and the point curves follow Camera Raw's measured response on synthetic grey steps, the master curve hue-preserving ([curve-stage.md](curve-stage.md)). From process V5 a raw's tone curve rolls off into white in stops (past a camera curve's last fitted knot, or from half a stop below the generic curve's white point instead of clipping), so Exposure +1 and +2 keep the highlights the sensor recorded: on 12 CC0 corpus raws and 6 CC0 DNGs on the generic curve, unclipped pixels whose luminance renders at 254 or more fall from up to 22.5 % to 0 at +1 EV and from up to 35 % to at most 0.03 % at +2 EV, apart from one sky that is mostly at the clip (#1632). Not compared with Lightroom's output. From process V13 global Shadows eases off at large amounts (`finish::tone_slider`, +100 at 0.43 of V6), fitted to 56 Lightroom exports of real Canon portrait edits at Shadows +40 to +100; with negative Texture and the Global wheel, mean ΔE on those exports 9.5 → 9.0. Global Highlights stays linear: on those edits V6 renders the brightest tones about 5 L* too dark, but single-slider exports show Lightroom's Highlights response close to linear and dependent on the frame's content (#3923), so that coverage-dependent strength, and smaller Shadows amounts, remain open. From process V17 Apple ProRAW (Make Apple and a `ProfileToneCurve`) takes Lightroom Classic's tone chain: base operator, Highlights / Shadows on a neighbourhood of the photo, Whites, Blacks, the profile curve per channel, Contrast adapting to the image; closed-form operators fitted on one CC0 iPhone 12 Pro file against Lightroom Classic 15.6 exports, mean CIEDE2000 unedited 2.93 → 1.05 and the 12 single tone-slider renders 3.73 → 1.22 (#613). Other cameras keep the operators above | +| LR-BEHAV-RENDER-FIDELITY | Rendering matches Lightroom | P1 | 🟡 | `crates/pipeline/src/lib.rs`, `crates/pipeline/src/tone.rs`, `crates/pipeline/src/proraw.rs` | Process V4 calibrates global camera-look Contrast and Blacks against black-box Lightroom exports of Sony ILCE-7CR photos. Held-out response errors are 0.038 and 0.077 stops; V1/V2 keep their rendering. V4 to V17 keep V2 Whites (V18 measures it, below; Apple ProRAW keeps V17's chain). Exposure, Highlights/Shadows, other operators and broader camera coverage remain open (`docs/light-v3.md`). From process V18 Whites, the parametric curve (at the default splits; moved splits keep the analytic model) and the point curves follow Camera Raw's measured response on synthetic grey steps, the master curve hue-preserving ([curve-stage.md](curve-stage.md)). From process V5 a raw's tone curve rolls off into white in stops (past a camera curve's last fitted knot, or from half a stop below the generic curve's white point instead of clipping), so Exposure +1 and +2 keep the highlights the sensor recorded: on 12 CC0 corpus raws and 6 CC0 DNGs on the generic curve, unclipped pixels whose luminance renders at 254 or more fall from up to 22.5 % to 0 at +1 EV and from up to 35 % to at most 0.03 % at +2 EV, apart from one sky that is mostly at the clip (#1632). Not compared with Lightroom's output. From process V13 global Shadows eases off at large amounts (`finish::tone_slider`, +100 at 0.43 of V6), fitted to 56 Lightroom exports of real Canon portrait edits at Shadows +40 to +100; with negative Texture and the Global wheel, mean ΔE on those exports 9.5 → 9.0. Global Highlights stays linear: on those edits V6 renders the brightest tones about 5 L* too dark, but single-slider exports show Lightroom's Highlights response close to linear and dependent on the frame's content (#3923), so that coverage-dependent strength, and smaller Shadows amounts, remain open. From process V17 Apple ProRAW (Make Apple and a `ProfileToneCurve`) takes Lightroom Classic's tone chain: base operator, Highlights / Shadows on a neighbourhood of the photo, Whites, Blacks, the profile curve per channel, Contrast adapting to the image; closed-form operators fitted on one CC0 iPhone 12 Pro file against Lightroom Classic 15.6 exports, mean CIEDE2000 unedited 2.93 → 1.05 and the 12 single tone-slider renders 3.73 → 1.22 (#613). Other cameras keep the operators above | | LR-BEHAV-DRAGDROP | Drag and drop | P1 | ✅ | `crates/ui-egui/src/lib.rs`, `crates/ui-egui/src/panels/grid.rs` (`drag_feedback`), `crates/ui-egui/src/panels/left.rs` (`drop_target`, `album_drag_over`, `top_level_drop_target`, `drag_auto_scroll`), `crates/ui-egui/src/tests/drag_contract.rs`, `crates/ui-egui/src/destination.rs`, `crates/ui-egui/src/widgets.rs` (`context_menu`), `crates/ui-egui/src/widgets/text_field.rs`, `crates/ui-egui/src/tests/carried_right_click.rs`, `crates/ui-egui/src/tests/carried_text_field_menu.rs` | a right-click while photos are carried opens no context menu (every menu opened through `widgets::context_menu`: sidebar rows, grid cells, lists; a text field's own Cut / Copy / Paste menu too); files → app (a drop-target card while they hover, then the import review); grid photos → an album row (the dragged label says how many photos it adds, or that they are all there already, and a drop then does nothing, with no undo step; a drop that finds some there says so in its toast); a smart album, an album folder and the sidebar's Keywords rows refuse photos with the not-allowed cursor and a reason, on the label and in the toast; Esc gives up any drag (photos, albums, sidebar sections, keywords) and does nothing else; sidebar album / folder rows → a folder (moves it; its name follows the pointer); a drag of albums or grid photos near the top or bottom edge of the sidebar scrolls it (faster nearer the edge, only while the pointer is over the sidebar); when another folder has the same name, the dragged label, the Move question and the toast name the folder it is in (`home (/a)`); an album drop's toast does the same for an album of that name in another album folder (two in the same place have nothing to tell them apart and keep the plain name); only the primary button drags photos and drops them: a right-button drag over a grid cell neither picks photos up nor changes the selection, and a right-button release while photos are dragged neither drops them nor ends the drag | | LR-BEHAV-TOAST | Toast notifications | P1 | ✅ | `crates/ui-egui/src/panels.rs` | | | LR-BEHAV-DIALOGS | Dialogs fit the window | P1 | ✅ | `crates/ui-egui/src/dialogs.rs` (`dialog_body`, `list_height`), `crates/ui-egui/src/tests/dialog_fit.rs`, `crates/ui-egui/src/tests/dialog_copy.rs`, `crates/ui-egui/src/tests/dialogs.rs` (`a_click_outside_closes_the_dialog_when_settings_allow_it`) | a dialog taller than the window (Export on a 1366×768 screen, issue #781) never runs off it: its options scroll while the title bar and the Cancel / confirm row stay on screen (the confirm button names its action: Create, Rename, Create Stacks, Export 3 Photos…, with "OK" kept only for a one-field prompt opened with a command that has no verb, `crates/ui-egui/src/tests/dialog_copy.rs`); lists that scroll on their own (What's New, All Metadata, shortcuts, smart-album rules, credits) get shorter first; dialogs that fit look as before; Import keeps its own resizable, scrolling window; Settings → Dialogs → Close a dialog by clicking outside it (off by default, so a stray click never throws away a dialog's choices): a click pressed and released on the dimmed backdrop closes the dialog like Esc and doesn't reach the panels below, while a drag that ends outside (a slider pulled past the edge) or a click that closes a dropdown keeps it; the import review never closes this way (`clicked_backdrop`); a one-line prompt (Rename Folder, New Folder on Disk, the preset and version names, New Library when its name can't be used, Auto-Tag from Tracklog) the engine refuses stays open with its text and shows the reason in a toast, so the name can be corrected, where it used to close without a word; a New Folder on Disk that works says so (“Created folder “Selects” in “2026/Shoot””, naming the parent by its last two folders as dialogs do) | diff --git a/docs/process-versions.md b/docs/process-versions.md index 208d6d565b9..40ac7579e79 100644 --- a/docs/process-versions.md +++ b/docs/process-versions.md @@ -25,7 +25,7 @@ stronger Light sliders, issue #196) without changing a single photo someone has | **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** | 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. | | **V17** | V16 plus: Apple ProRAW (Make `Apple` and a DNG `ProfileToneCurve`) renders its Light sliders through Lightroom Classic's fitted tone chain (`crates/pipeline/src/proraw.rs`, #613): base operator (BaselineExposure + Exposure), Highlights / Shadows on a Gaussian neighbourhood at 6.4 % of the long edge, Whites, Blacks, the 128-knot profile tone curve per channel (hue-preserving in linear ProPhoto), then Contrast adapting to the image's key. HDR keeps the chain through the midtones and lifts highlights past white (`camera_hdr_lift`). V1 to V16 keep the 32-knot camera curve on luminance; non-ProRAW photos and older offline smart previews without the curve render identically to V16. CPU and GPU share the stage tables and Highlights / Shadows curves. | -| **V18** (the latest) | V17 plus: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map and, with the parametric curve at Lightroom's default splits, comes from LightCraft's model fitted to those measurements (Whites reaches into the midtones; the regions are broad and add; moved splits keep the analytic model of V1 to V17); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V17 keep Whites in the tone map and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the curve tables built from the model. With Whites, the parametric curve and the point curves neutral the curve stage does not run. | +| **V18** (the latest) | V17 plus: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map (Apple ProRAW keeps Whites in V17's chain, and the stage then applies only the curves) and, with the parametric curve at Lightroom's default splits, comes from LightCraft's model fitted to those measurements (Whites reaches into the midtones; the regions are broad and add; moved splits keep the analytic model of V1 to V17); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V17 keep Whites in the tone map and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the curve tables built from the model. With Whites, the parametric curve and the point curves neutral the curve stage does not run. | ## The rule From 587ed534debc7c3366069bdaff955e04b93d5d4c Mon Sep 17 00:00:00 2001 From: smi-leonivkovic Date: Thu, 3 Dec 2026 18:17:24 +0100 Subject: [PATCH 20/20] docs: V17's Apple ProRAW uses its chain's fitted Whites, not V2 Whites (review on #4076) --- docs/gaps.md | 2 +- docs/parity-checklist.md | 4 ++-- docs/process-versions.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/gaps.md b/docs/gaps.md index 4691d3e25a9..d16d5c7fb9a 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -17,7 +17,7 @@ Hours are Opus 5.5 agent wall-clock hours (see [target-app-parity.md](target-app |---:|---|---|---|---:|---| | 1 B | **Camera colour is estimated, not measured** (LR-PROF-CAMERACOLOR). Raws start from a per-file fit to the camera JPEG, 10 bundled profiles, 52 spectral matrices (plus same-sensor bodies, e.g. the X-T30 through the X-T3) or chart-measured matrices (the EOS D60); others use a neutral matrix (a black-and-white camera JPEG gives its tone curve only, #577; dark JPEG tones also guide the toe, #1307) | ΔE vs camera JPEG 2.9–10 after fitting (raw-parity.md); 1 chart-calibrated model (EOS D60: its Kelvin scale and fallback colour, the look stays the JPEG fit) vs 1,500 Adobe Standard profiles | every raw shooter sees colour that is close but not Lightroom's; some get neutral-matrix colour | 50–90 | [raw-parity](raw-parity.md#colour) | | 2 B | **CR3 variants no public file uses** (LR-IMP-FORMATS): `crx.rs` refuses vertical-tile C-RAW, partial-subband and other plane coding, multi-tile 0x200 and adaptive low-frequency gains, and those files fall back to the preview. All 110 CC0 CR3s on raw.pixls.us (31 folders) decode from sensor data, so none of these variants has a public sample; 26 CR3 bodies are verified (M50 / R100 / R8 exact, R5 Mark II pinned, 22 more pinned on one CC0 file each and checked against the camera JPEG, [cr3.md](cr3.md#further-bodies-one-cc0-file-each)). HEIF stills are `.HIF` files, not CR3; no CR3 sRAW / mRAW sample exists | measured: Canon's share whose camera fully works 73% → 94% (raw-parity.md); 18 of 22 popular Canon bodies write CR3, all 18 now verified | +0.3 points of photographers; the variants surface only as user files that open as a preview | 10–25 | [raw-parity](raw-parity.md#remaining-work-ranked-by-photographers-unlocked-per-hour) | -| 3 B | **Render fidelity partial** (LR-BEHAV-RENDER-FIDELITY): calibrated camera-look Contrast and Blacks; other operators need measurement; from process V5 raw tone curves roll off into white in stops, so Exposure keeps recorded highlights (#1632); from process V17 Apple ProRAW takes Lightroom's fitted tone chain; from V18 Whites and the parametric curve at its default splits are measured against Camera Raw, and the point curves (still LightCraft's spline) apply hue preserving as Lightroom's do ([curve-stage.md](curve-stage.md)) | process V3 reduces held-out response error from 0.136 to 0.038 stops for Contrast and 0.424 to 0.077 for Blacks on one Sony camera; V4 to V17 keep V2 Whites; V18's Whites is fitted to Camera Raw's grey-step charts, not yet checked on photos per camera | imported Lightroom edits still differ, especially on uncalibrated operators and cameras | 30–60 | [calibrated Light operators](light-v3.md), [process versions](process-versions.md) | +| 3 B | **Render fidelity partial** (LR-BEHAV-RENDER-FIDELITY): calibrated camera-look Contrast and Blacks; other operators need measurement; from process V5 raw tone curves roll off into white in stops, so Exposure keeps recorded highlights (#1632); from process V17 Apple ProRAW takes Lightroom's fitted tone chain; from V18 Whites and the parametric curve at its default splits are measured against Camera Raw, and the point curves (still LightCraft's spline) apply hue preserving as Lightroom's do ([curve-stage.md](curve-stage.md)) | process V3 reduces held-out response error from 0.136 to 0.038 stops for Contrast and 0.424 to 0.077 for Blacks on one Sony camera; V4 to V16, and V17 except Apple ProRAW (fitted Whites in its own chain), keep V2 Whites; for other photos V18's Whites is fitted to Camera Raw's grey-step charts, not yet checked on photos per camera | imported Lightroom edits still differ, especially on uncalibrated operators and cameras | 30–60 | [calibrated Light operators](light-v3.md), [process versions](process-versions.md) | | 4 | ~~Original-pixel detail at 100%~~ (LR-VIEW-ZOOM): closed 2026-10-12, see Closed recently | checklist row ✅ | — | 0 | [ui-parity](ui-parity.md) | | 5 B | **AI masks: Subject, Sky, People, Background, Landscape** are heuristics; Object / Describe run SAM 3 but its download has no mirror configured | `crates/segment`; ai-masks.md; MASK rows 67% | masking is how most Lightroom users edit today | 40–70 + model decision | [target-app-parity](target-app-parity.md#ai) | | 6 | **Compressed ORF** (support withdrawn) | #3775 decoder removed pending provenance review; uncompressed support remains | compressed files use embedded JPEG previews when available, not sensor data | pending review | [orf-compression](orf-compression.md) | diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 579f433283d..476f810c3b2 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -188,7 +188,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-EDIT-LIGHT-CONTRAST | Contrast | P0 | 🟡 | `ctl:light.contrast` | From process V4, global Contrast on the camera-look path is fitted per channel in ProPhoto with the sRGB transfer. Check response error 0.136 to 0.038 stops on six held-out Sony photos. Other sources and local adjustments retain V2; broader parity remains unverified (`docs/light-v3.md`). | | LR-EDIT-LIGHT-HIGHLIGHTS | Highlights | P0 | ✅ | `ctl:light.highlights`, `crates/raw/src/highlight.rs` | sensor-clipped highlights stay neutral when Highlights (or Exposure, Whites) darkens them: fully clipped content is rebuilt to the neutral of the colour model applied after it, partly clipped content takes its colour from reliable unclipped content nearby (not from dark objects, lens fringes or another surface beside it) and white where there is none, and pale partly clipped content (a white sky) turns white on its way to clipping (#523); binned previews and thumbnails decide clipping per sample before averaging (`develop_binned_masked`, `highlight::reconstruct_masked`), so a block with one clipped specular sample keeps its mean instead of jumping to the clip level, which reconstruction turned into green speckles at 500 px (#548) From process V2 the Highlights/Shadows base is the edge-aware filter of the 0.15 %-of-long-edge median of log luminance: twigs and fine texture take their surroundings' shift, so bright areas keep their local contrast as with Exposure (V1's base kept ~0.6 of it at −100, #632); region edges stay sharp; from process V8 (`local::detail_free`: clamped between the median at that radius and one 3× wider) lettering keeps clean gaps (the median alone turned them into blocks of the letters' tone). Alt/Option-drag shows highlight clipping | | LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | From process V2, the same base as Highlights: dark areas keep their local contrast when lifted (#632); from process V8, the gaps in dark lettering on a bright panel are not lifted into bright blocks. Alt/Option-drag shows shadow clipping (white, clipped channels in colour). From process V13 the global amount eases off as it grows: the operator's strength is `a / (1 + 1.33·abs(a))` for `a` = slider / 100 (0.43 at +100, against 1 up to V10), fitted to Lightroom exports (#523). | -| LR-EDIT-LIGHT-WHITES | Whites | P0 | 🟡 | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | From process V18 Whites is measured against Camera Raw renders of synthetic grey steps and reaches into the midtones as Lightroom's does ([curve-stage.md](curve-stage.md)); not yet compared on photos per camera. V4 to V17 preserve V2 Whites for both signs, and Apple ProRAW keeps Whites in V17's chain under V18 too; measured V2 check response error is 0.075 stops on the Sony test photos (`docs/light-v3.md`). Alt/Option-drag shows highlight clipping (black, clipped channels in colour) | +| LR-EDIT-LIGHT-WHITES | Whites | P0 | 🟡 | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | From process V18 Whites is measured against Camera Raw renders of synthetic grey steps and reaches into the midtones as Lightroom's does ([curve-stage.md](curve-stage.md)); not yet compared on photos per camera. V4 to V16, and V17 except Apple ProRAW, preserve V2 Whites for both signs; ProRAW uses its chain's fitted Whites from V17, under V18 too; measured V2 check response error is 0.075 stops on the Sony test photos (`docs/light-v3.md`). Alt/Option-drag shows highlight clipping (black, clipped channels in colour) | | LR-EDIT-LIGHT-BLACKS | Blacks | P0 | 🟡 | `ctl:light.blacks`, `crates/pipeline/src/visualize.rs` | From process V4, global Blacks on the camera-look path uses a fitted per-channel/luminance mix. Check response error 0.424 to 0.077 stops on six held-out Sony photos; deepest tones still differ. Other sources and local adjustments retain V2 (`docs/light-v3.md`). Alt/Option-drag shows shadow clipping (white, clipped channels in colour) | | LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | from process V18 the regions are LightCraft's model fitted to Camera Raw's measured response at the default splits, broad and additive ([curve-stage.md](curve-stage.md)); the graph draws the curve the photo renders (`ParametricGraph`: the fitted regions under V18 at the default splits, else the analytic model); dragging the line moves the region under the pointer (one undo step); sampled selected-curve input backdrop (#987); [stage and sampling limits](tone-curve-input.md) | | LR-EDIT-LIGHT-CURVE-POINT | Point curve | P0 | ✅ | `cmd:develop.curve`, `cmd:curve.reset`, `cmd:curve.presets`, `cmd:curve.applyPreset`, `cmd:curve.savePreset`, `cmd:curve.deletePreset`, `cmd:curve.importPresets`, `cmd:curve.exportPresets`, `cmd:file.importCurvePresets`, `cmd:file.exportCurvePresets`, `crates/engine/src/cmd/curves.rs`, `crates/ui-egui/src/panels/edit.rs` | click to add a point; drag a point in both axes (between its neighbours, input / output readout, one undo step per drag; ⌥-drag moves it a tenth as far for fine adjustment, issue #1363); drag empty space to add and drag; double-click removes; reset: double-click a channel selector (that channel), the Reset button under the graph (every curve incl. parametric) or right-click the graph (channel / all); Point Curve preset dropdown: own Linear / Medium Contrast / Strong Contrast, user presets (save the current point curves, delete by right-click; saved with the library), import / export as `.lccurve` JSON; from process V18 the master curve keeps hue as Lightroom's does (largest and smallest channel through the curve, the middle one in proportion), and the red, green and blue curves follow it per channel ([curve-stage.md](curve-stage.md)); sampled input after Parametric, independent of this curve (#987); [stage and sampling limits](tone-curve-input.md) | @@ -472,7 +472,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-BEHAV-OFFLINE | Offline editing | P1 | ✅ | | local-first: everything works offline | | LR-BEHAV-WEB-SAFETY | Library safety in the browser build | P1 | 🟡 | `cmd:file.backupLibrary`, `cmd:file.restoreLibrary`, `apps/lightcraft-web/src/safety.rs`, `apps/lightcraft-web/src/backup.rs`, `apps/lightcraft-web/src/files.rs` | web only (experimental): Back Up Library (zip of the catalog and every stored original) and a non-destructive Restore; failed saves show as unsaved and are retried; a photo that can't be stored isn't added; one tab per library (Web Locks); notices for storage that isn't persistent and for a library that can't open; `?reset` asks first; a panic shows a message. Missing: `?safe` start, deleting originals of removed photos, zip64 (backups > 4 GB) | | LR-BEHAV-GPU | GPU acceleration | P0 | ✅ | `crates/gpu/src/render.rs`, `cmd:app.gpu`, `docs/gpu-pipeline.md`, `crates/ui-egui/src/panels/notices.rs` | CPU fallback per render on device limits, out of memory, device errors / loss, incomplete or black results (`perf.gpuReason`, `perf.gpuFallback`; each render reports its own reason — `lightcraft_gpu::try_render`, `gpuFallback` per exported file — issue #675); short submissions for slow iGPUs; backend choice (DX12 only on Windows, `LIGHTCRAFT_GPU_BACKEND` / `WGPU_BACKEND`), device created after the window opens, crash sentinel (issue #136); a GPU lost while LightCraft runs (driver reset) stops it with that message and turns GPU rendering off for the next start, which says why (issue #1337; the window's renderer can't survive the lost device); quitting waits (up to 2 s) for renders in flight and starts no new GPU work, so none is inside the driver when the process exits (`crates/gpu/src/exit.rs`, issue #620; seen crashing only on Linux + NVIDIA, other drivers unverified); with GPU rendering on and no adapter found at all (e.g. no Vulkan loader on NixOS outside `nix develop`), the desktop app says once per session that it renders on the CPU and points to Help ▸ System Info (`gpu_notice`; not when the GPU is turned off or only a software adapter exists); no tiling beyond the buffer limit (CPU) | -| LR-BEHAV-RENDER-FIDELITY | Rendering matches Lightroom | P1 | 🟡 | `crates/pipeline/src/lib.rs`, `crates/pipeline/src/tone.rs`, `crates/pipeline/src/proraw.rs` | Process V4 calibrates global camera-look Contrast and Blacks against black-box Lightroom exports of Sony ILCE-7CR photos. Held-out response errors are 0.038 and 0.077 stops; V1/V2 keep their rendering. V4 to V17 keep V2 Whites (V18 measures it, below; Apple ProRAW keeps V17's chain). Exposure, Highlights/Shadows, other operators and broader camera coverage remain open (`docs/light-v3.md`). From process V18 Whites, the parametric curve (at the default splits; moved splits keep the analytic model) and the point curves follow Camera Raw's measured response on synthetic grey steps, the master curve hue-preserving ([curve-stage.md](curve-stage.md)). From process V5 a raw's tone curve rolls off into white in stops (past a camera curve's last fitted knot, or from half a stop below the generic curve's white point instead of clipping), so Exposure +1 and +2 keep the highlights the sensor recorded: on 12 CC0 corpus raws and 6 CC0 DNGs on the generic curve, unclipped pixels whose luminance renders at 254 or more fall from up to 22.5 % to 0 at +1 EV and from up to 35 % to at most 0.03 % at +2 EV, apart from one sky that is mostly at the clip (#1632). Not compared with Lightroom's output. From process V13 global Shadows eases off at large amounts (`finish::tone_slider`, +100 at 0.43 of V6), fitted to 56 Lightroom exports of real Canon portrait edits at Shadows +40 to +100; with negative Texture and the Global wheel, mean ΔE on those exports 9.5 → 9.0. Global Highlights stays linear: on those edits V6 renders the brightest tones about 5 L* too dark, but single-slider exports show Lightroom's Highlights response close to linear and dependent on the frame's content (#3923), so that coverage-dependent strength, and smaller Shadows amounts, remain open. From process V17 Apple ProRAW (Make Apple and a `ProfileToneCurve`) takes Lightroom Classic's tone chain: base operator, Highlights / Shadows on a neighbourhood of the photo, Whites, Blacks, the profile curve per channel, Contrast adapting to the image; closed-form operators fitted on one CC0 iPhone 12 Pro file against Lightroom Classic 15.6 exports, mean CIEDE2000 unedited 2.93 → 1.05 and the 12 single tone-slider renders 3.73 → 1.22 (#613). Other cameras keep the operators above | +| LR-BEHAV-RENDER-FIDELITY | Rendering matches Lightroom | P1 | 🟡 | `crates/pipeline/src/lib.rs`, `crates/pipeline/src/tone.rs`, `crates/pipeline/src/proraw.rs` | Process V4 calibrates global camera-look Contrast and Blacks against black-box Lightroom exports of Sony ILCE-7CR photos. Held-out response errors are 0.038 and 0.077 stops; V1/V2 keep their rendering. V4 to V16, and V17 except Apple ProRAW, keep V2 Whites; ProRAW uses its chain's fitted Whites from V17, and V18 measures Whites for other photos (below). Exposure, Highlights/Shadows, other operators and broader camera coverage remain open (`docs/light-v3.md`). From process V18 Whites, the parametric curve (at the default splits; moved splits keep the analytic model) and the point curves follow Camera Raw's measured response on synthetic grey steps, the master curve hue-preserving ([curve-stage.md](curve-stage.md)). From process V5 a raw's tone curve rolls off into white in stops (past a camera curve's last fitted knot, or from half a stop below the generic curve's white point instead of clipping), so Exposure +1 and +2 keep the highlights the sensor recorded: on 12 CC0 corpus raws and 6 CC0 DNGs on the generic curve, unclipped pixels whose luminance renders at 254 or more fall from up to 22.5 % to 0 at +1 EV and from up to 35 % to at most 0.03 % at +2 EV, apart from one sky that is mostly at the clip (#1632). Not compared with Lightroom's output. From process V13 global Shadows eases off at large amounts (`finish::tone_slider`, +100 at 0.43 of V6), fitted to 56 Lightroom exports of real Canon portrait edits at Shadows +40 to +100; with negative Texture and the Global wheel, mean ΔE on those exports 9.5 → 9.0. Global Highlights stays linear: on those edits V6 renders the brightest tones about 5 L* too dark, but single-slider exports show Lightroom's Highlights response close to linear and dependent on the frame's content (#3923), so that coverage-dependent strength, and smaller Shadows amounts, remain open. From process V17 Apple ProRAW (Make Apple and a `ProfileToneCurve`) takes Lightroom Classic's tone chain: base operator, Highlights / Shadows on a neighbourhood of the photo, Whites, Blacks, the profile curve per channel, Contrast adapting to the image; closed-form operators fitted on one CC0 iPhone 12 Pro file against Lightroom Classic 15.6 exports, mean CIEDE2000 unedited 2.93 → 1.05 and the 12 single tone-slider renders 3.73 → 1.22 (#613). Other cameras keep the operators above | | LR-BEHAV-DRAGDROP | Drag and drop | P1 | ✅ | `crates/ui-egui/src/lib.rs`, `crates/ui-egui/src/panels/grid.rs` (`drag_feedback`), `crates/ui-egui/src/panels/left.rs` (`drop_target`, `album_drag_over`, `top_level_drop_target`, `drag_auto_scroll`), `crates/ui-egui/src/tests/drag_contract.rs`, `crates/ui-egui/src/destination.rs`, `crates/ui-egui/src/widgets.rs` (`context_menu`), `crates/ui-egui/src/widgets/text_field.rs`, `crates/ui-egui/src/tests/carried_right_click.rs`, `crates/ui-egui/src/tests/carried_text_field_menu.rs` | a right-click while photos are carried opens no context menu (every menu opened through `widgets::context_menu`: sidebar rows, grid cells, lists; a text field's own Cut / Copy / Paste menu too); files → app (a drop-target card while they hover, then the import review); grid photos → an album row (the dragged label says how many photos it adds, or that they are all there already, and a drop then does nothing, with no undo step; a drop that finds some there says so in its toast); a smart album, an album folder and the sidebar's Keywords rows refuse photos with the not-allowed cursor and a reason, on the label and in the toast; Esc gives up any drag (photos, albums, sidebar sections, keywords) and does nothing else; sidebar album / folder rows → a folder (moves it; its name follows the pointer); a drag of albums or grid photos near the top or bottom edge of the sidebar scrolls it (faster nearer the edge, only while the pointer is over the sidebar); when another folder has the same name, the dragged label, the Move question and the toast name the folder it is in (`home (/a)`); an album drop's toast does the same for an album of that name in another album folder (two in the same place have nothing to tell them apart and keep the plain name); only the primary button drags photos and drops them: a right-button drag over a grid cell neither picks photos up nor changes the selection, and a right-button release while photos are dragged neither drops them nor ends the drag | | LR-BEHAV-TOAST | Toast notifications | P1 | ✅ | `crates/ui-egui/src/panels.rs` | | | LR-BEHAV-DIALOGS | Dialogs fit the window | P1 | ✅ | `crates/ui-egui/src/dialogs.rs` (`dialog_body`, `list_height`), `crates/ui-egui/src/tests/dialog_fit.rs`, `crates/ui-egui/src/tests/dialog_copy.rs`, `crates/ui-egui/src/tests/dialogs.rs` (`a_click_outside_closes_the_dialog_when_settings_allow_it`) | a dialog taller than the window (Export on a 1366×768 screen, issue #781) never runs off it: its options scroll while the title bar and the Cancel / confirm row stay on screen (the confirm button names its action: Create, Rename, Create Stacks, Export 3 Photos…, with "OK" kept only for a one-field prompt opened with a command that has no verb, `crates/ui-egui/src/tests/dialog_copy.rs`); lists that scroll on their own (What's New, All Metadata, shortcuts, smart-album rules, credits) get shorter first; dialogs that fit look as before; Import keeps its own resizable, scrolling window; Settings → Dialogs → Close a dialog by clicking outside it (off by default, so a stray click never throws away a dialog's choices): a click pressed and released on the dimmed backdrop closes the dialog like Esc and doesn't reach the panels below, while a drag that ends outside (a slider pulled past the edge) or a click that closes a dropdown keeps it; the import review never closes this way (`clicked_backdrop`); a one-line prompt (Rename Folder, New Folder on Disk, the preset and version names, New Library when its name can't be used, Auto-Tag from Tracklog) the engine refuses stays open with its text and shows the reason in a toast, so the name can be corrected, where it used to close without a word; a New Folder on Disk that works says so (“Created folder “Selects” in “2026/Shoot””, naming the parent by its last two folders as dialogs do) | diff --git a/docs/process-versions.md b/docs/process-versions.md index 40ac7579e79..89165f78e0a 100644 --- a/docs/process-versions.md +++ b/docs/process-versions.md @@ -25,7 +25,7 @@ stronger Light sliders, issue #196) without changing a single photo someone has | **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** | 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. | | **V17** | V16 plus: Apple ProRAW (Make `Apple` and a DNG `ProfileToneCurve`) renders its Light sliders through Lightroom Classic's fitted tone chain (`crates/pipeline/src/proraw.rs`, #613): base operator (BaselineExposure + Exposure), Highlights / Shadows on a Gaussian neighbourhood at 6.4 % of the long edge, Whites, Blacks, the 128-knot profile tone curve per channel (hue-preserving in linear ProPhoto), then Contrast adapting to the image's key. HDR keeps the chain through the midtones and lifts highlights past white (`camera_hdr_lift`). V1 to V16 keep the 32-knot camera curve on luminance; non-ProRAW photos and older offline smart previews without the curve render identically to V16. CPU and GPU share the stage tables and Highlights / Shadows curves. | -| **V18** (the latest) | V17 plus: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map (Apple ProRAW keeps Whites in V17's chain, and the stage then applies only the curves) and, with the parametric curve at Lightroom's default splits, comes from LightCraft's model fitted to those measurements (Whites reaches into the midtones; the regions are broad and add; moved splits keep the analytic model of V1 to V17); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V17 keep Whites in the tone map and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the curve tables built from the model. With Whites, the parametric curve and the point curves neutral the curve stage does not run. | +| **V18** (the latest) | V17 plus: Whites, the parametric curve and the point curves as Lightroom applies them ([curve-stage.md](curve-stage.md), `crates/pipeline/src/curve_stage.rs`), measured on Camera Raw renders of synthetic grey steps. Whites leaves the tone map (Apple ProRAW keeps Whites in V17's chain, and the stage then applies only the curves) and, with the parametric curve at Lightroom's default splits, comes from LightCraft's model fitted to those measurements (Whites reaches into the midtones; the regions are broad and add; moved splits keep the analytic model of V1 to V17); the master curve acts hue-preserving on sRGB-encoded linear ProPhoto RGB (largest and smallest channel through the curve, the middle one in proportion in linear light), then the red, green and blue curves per channel, between the calibrated Contrast and Blacks and the colour stage. V1 to V17 keep Whites in the tone map (Apple ProRAW from V17: in its own chain) and their per-channel curves on the output. CPU (`finish::finish_with`) and GPU (`finish.wgsl::curve_stage`) share the curve tables built from the model. With Whites, the parametric curve and the point curves neutral the curve stage does not run. | ## The rule