Repository navigation
LR-EDIT-DETAIL-SHARPEN: Radius and Detail work, and sharpening acts at pixel scale (#757) - #762
Conversation
|
Thanks for digging into sharpening (#757). The diagnosis is right, but the change needs a process version before it can land. It changes how existing sharpening renders: a new unsharp band, Detail as a soft-clip limit and Radius at pixel scale. Raws get Amount 40 by default, so every existing raw edit would look different after an update, which Could you put the new path behind a process version? #645 (Process V2 for the Highlights/Shadows base) is landing now. Gate the new sharpening on V2, or on a V3 if V2 should stay as #645 defines it, and add the process to the sharpen plane's cache key, as #645 does for the base plane. Old edits then keep their look, and "Update to Current Process" moves them over. Generated by Claude Code |
The tone work from storytold#146/storytold#196 changes how every existing raw edit renders, so it goes behind a process version (docs/process-versions.md): V2 is the measured rendering and LATEST; V1 keeps the pre-branch rendering exactly. - Process::V2 added, LATEST; ALL is [V1, V2]. V2 is shared with the Highlights/Shadows base (storytold#645) and the sharpening (storytold#762) landing in the same batch, so a photo that updates to V2 gets the whole measured look at once. - finish::base_tone: V1's arm calls tone::ToneMap::{camera_v1, hdr_v1}, the old model restored verbatim (neutral base curve, extended-Reinhard shoulder, Blacks as the curve's toe, Whites as a display-domain lift); V2's arm is the measured model. A display-referred source uses display_hdr in both. - FinishParams::blacks is Blacks::IDENTITY for V1, and the per-photo Whites statistic is measured only for V2 (Process::is_measured_tone) -- V1 pays for neither. - RENDER_CACHE_VERSION 48 -> 49. - docs: process-versions.md describes V1/V2 and records that the V2 constants are fitted to the reference developer's observed output only (its rendered images; no bundle, profile, preset or Adobe asset); parity.md, ROADMAP.md and gpu-pipeline.md name V2 / F_PER_CHANNEL. Tests: v2_is_not_v1 pins the default curve apart; the v1_* golden tests pin the frozen model; stored_process_numbers_render_with_a_known_process now asserts the two arms render a raw differently and a rendered source alike. cargo xtask ci: all 8 steps green (fmt, clippy, heif, test, parity, layers, assets, wasm).
Takes the branch onto the 346 commits main landed since b70ae17, including its own Process::V2 (storytold#632: Highlights and Shadows keep the local contrast of the tones they move) and the progress-doc restructure (parity.md -> parity-checklist.md, "Where we stand" -> target-app-parity.md, milestones and risks -> roadmap.md). Resolutions: - Process: main's V2 and this branch's measured tone model share one V2, as agreed with the Highlights/Shadows (storytold#645) and sharpening (storytold#762) work. The Process::V2 doc comment and docs/process-versions.md say so. - finish::base_tone keeps V1 frozen (main's tone map) and gives V2 the measured model, now HDR-aware on the camera path too (ToneMap::camera_scaled_hdr), so an HDR render keeps the file's camera look. Process::is_measured_tone gates the Blacks curve and the per-photo Whites statistic; local::tone_base_detail gates storytold#632's median base. - The camera-look fitter keeps scoring its candidates with the frozen V1 tone map (ToneMap::{camera_v1, hdr_v1}). The model a fit is scored with decides which files accept a look -- the source stage, which the process version does not reach; the fit's own test (a_black_and_white_jpeg_gives_its_tone_curve) asserts the default curve is darker, which V2's measured curve is not. - crates/pipeline/src/spots.rs: chunks_exact(3) -> as_chunks::<3>() for the clippy lint rustc 1.98 added (main's new line; the local gate is -D warnings). - RENDER_CACHE_VERSION 60 -> 61 (the branch's look changes on top of main). - Docs merged: parity-checklist.md (the five Light rows, the storytold#632 note on Highlights/Shadows, LR-PROF-CAMERACOLOR and LR-BEHAV-RENDER-FIDELITY), process-versions.md (V1/V2 as one batch), roadmap.md (Look parity bullet), gaps.md (gap 3 is no longer "render fidelity unmeasured"). cargo xtask ci: all 8 steps green (fmt, clippy, heif, test, parity, layers, assets, wasm).
|
I was going to pick up #757 and found this PR, so I'm not opening a competing one. The design matches what I'd have done: a separate pixel-scale band, an exact Gaussian (the 3-box blur can't represent σ < ~0.8 px), shared CPU/GPU parameter functions, and the 1. "Source pixels" are the pixels of the cached source level, not the sensor's
So in the app, grid thumbnails are sharpened at about the old texture-band scale, and the scale-invariance test passes only because it renders both sizes from the same 2. The sub-pixel rule: a response-matched floor instead of a fadeOnce (1) is in, most previews and downsized exports fall below σ 0.5, and the fade then removes all capture sharpening from them. The quantity to preserve is the unsharp mask's boost at the output's Nyquist frequency, 1 − H(0.5 cycles/px). Rendering at full size, sharpening, then downsampling ideally gives 1 − exp(−π²σ²/2) at σ_out = Radius × out/native. I computed this with the PR's own
So the suggestion is to clamp σ to 0.5 px and scale the sharpen term by 3. Process version, as @bflatastic askedV2 (#632 / #645) shipped in v0.6.0 (
The sharpen plane depends only on σ, so the σ-keyed On #944 (draft), which covers the same controls: it uses I'll note the general split (scene-scale operations keep relative radii; sensor-scale ones, sharpening and NR, use native pixels plus a sub-pixel rule) on #960 for the maintainers. |
|
Ported this into a downstream fork (emmertex/chromaforge#72); two things needed fixing against current main, in case they're useful here:
GPU equivalence stays within 1 LSB on both branches. |
LR-EDIT-DETAIL-SHARPEN: Radius and Detail work, sharpening at pixel scale (port of upstream #762)
a9e113f to
2d17c9e
Compare
|
The requested changes are implemented on current main: sharpening is gated to new process V3, V1/V2 retain their old rendering, source-level previews use the original photo’s dimensions, and noise-reduction changes invalidate the sharpen plane even for drafts. The subpixel response is continuous around the half-pixel floor. CPU regressions and all 18 GPU equivalence tests pass. Eight paired V1/V2 exports are pixel-identical to main; the updated description records validation and baseline CI limitations. |
AlexChambers
left a comment
There was a problem hiding this comment.
I'm a fellow contributor, not a maintainer. I'm using Codex to help review PRs and checking potential findings with focused tests where possible.
Reviewed head 2d17c9e0baeeed30b43373a0e545fbcb34d56b78 against target base and actual merge base 0da998f24dfc03069d49867f8877af2bf7c51f94.
[P2] Keep Radius effective when an export is enlarged
Radius 2 through 3 produce the same 200% export. The new output-pixel clamp maps both radii to sigma 4 when output is twice the original size. The gain is 1 for both. This is a supported export with percent=200 and dontEnlarge=false, exposed by the "Don't enlarge" checkbox.
The procedural CPU case below changes 3,835 pixels at native size, by up to 12 byte levels, between Radius 2 and 3. At 256 by 64, it changes zero pixels. The exact base uses Process V2 and ignores Radius at both sizes, so this is an incomplete fix of the explicit working-Radius and source-pixel-scale contract, not a new regression. Please preserve distinct radius responses when scaling above four output pixels.
I ran 20 focused existing tests successfully. This probe fails at head and base as described. It exercises the public CPU pipeline without an encoder or full engine export; GPU use of the same sigma was source-reviewed only. I did not test Lightroom equivalence.
Portable procedural reproduction
Save this as crates/pipeline/tests/review762.rs, then run cargo test -p lightcraft-pipeline --test review762 -- --nocapture. It creates at most 16,384 pixels and needs no media, GPU, models or network.
use lightcraft_develop::DevelopSettings;
use lightcraft_pipeline::{render, RenderRequest, SourceInfo};
use lightcraft_raster::Rgb32f;
#[test]
fn radius_still_changes_a_two_times_enlarged_export() {
let src = Rgb32f::from_fn(128, 32, |x, y| {
let v = 0.18 + 0.035 * (x as f32 * 0.31).sin()
+ 0.02 * (y as f32 * 0.43).cos();
[v; 3]
});
let info = SourceInfo::default();
let mut two = DevelopSettings::default();
two.detail.sharpen_amount = 80.0;
two.detail.sharpen_radius = 2.0;
two.detail.sharpen_detail = 100.0;
let mut three = two.clone();
three.detail.sharpen_radius = 3.0;
let mut enlarged_changes = 0;
for scale in [1, 2] {
let req = RenderRequest::fit(128 * scale, 32 * scale);
let a = render(&src, &info, &two, &req).image;
let b = render(&src, &info, &three, &req).image;
let changed = a.data.iter().zip(&b.data).filter(|(p, q)| p != q).count();
let max = a.data.iter().zip(&b.data)
.flat_map(|(p, q)| (0..3).map(move |c| p[c].abs_diff(q[c])))
.max().unwrap();
println!("process {}, scale {scale}, size {}x{}, changed {changed}, max {max}",
two.process.0, a.width, a.height);
if scale == 2 { enlarged_changes = changed; }
}
assert!(enlarged_changes > 0, "Radius 2 and 3 produce identical enlarged exports");
}Head output: native 3,835 changed pixels, maximum 12; 200% output zero changed pixels. Base output: zero changed pixels at both sizes. The final assertion intentionally exposes the missing enlarged-output behavior.
|
Tested this on a real wedding: 571 delivered Canon EOS R5 C raws (45 MP CR3), judged at 100 % as part of a client delivery. I'm a professional wedding photographer. Before this PR, Sharpening behaved like extra Texture/Clarity: wide halos around heads and suits against bright skies, and gritty skin, while Radius and Detail had no visible effect. With this PR (cherry-picked onto my fork; only trivial conflicts, pipeline tests and the GPU equivalence tests pass), sharpening finally acts at pixel scale and Radius and Detail behave as expected. After testing on several portraits and group shots, my sweet spot is Sharpening 100, Radius 1.5, Detail 10, Masking 15: crisp edges, no halos, skin stays clean. It's gentler per step than Lightroom (where I kept ~20 to avoid over-sharpening), which I much prefer: it gives a lot more fine control. Really nice work, thank you. It's now part of my delivery workflow, and I'd love to see it merged. 🤖 Drafted with Claude Code |
|
The fix is still not implemented in the latest v0.10.0 release, I wonder why? |
… grain The particle grain changed how existing photos render (review of storytold#1060: legacy settings up to 16.5 levels of 255 apart), against docs/process-versions.md (V1 frozen). Process V3 is now the latest and selects the particle model (finish::GrainModel::new); V1 and V2 keep the value-noise grain exactly, on CPU (finish::ValueGrain) and GPU (F_GRAIN_MODEL 0, original hash constants). Tests: crates/pipeline/tests/grain_process.rs (the reviewer's reproduction for V1, the same for V2, and V3 / new settings render particles); GPU equivalence gains a V1 value-noise grain case and V3 in the per-process cache check. Composes with storytold#762, which also proposes V3: whichever lands second takes V4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le grain only in process V3) This build already has upstream PR storytold#762 (pixel-scale sharpening), which also introduced process V3. Here they are one process: V3 = pixel-scale sharpening + particle grain, both gated on V3; V1/V2 keep texture-band sharpening and the value-noise grain (CPU and GPU). Photos already updated to V3 for the sharpening get the particle grain too (intended). The V1/V2 value grain runs after the masks' local curves, as on the GPU. Both test suites (grain_process, tests_sharpen) pass unchanged; docs/process-versions.md documents the combined V3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@fxdefaut This PR hasn't been merged yet, so no release includes it. Releases only ship what is merged into @OneSlips thanks for the wedding test on 571 R5 C files, that's useful evidence for the review. |
2d17c9e to
f929b28
Compare
|
Rebased onto 0.11.0 main (31ee264); head is now f929b28. Pixel-scale sharpening stays gated behind Process V3 (V3 was still free on main), render cache version is 70. Retest: fmt and clippy clean; pipeline, develop and gpu tests pass (including the GPU/CPU equivalence test and the V1/V2-unchanged sharpening test). The one engine lib test failure (tests_import SR2/SRF discovery) is in code this PR does not touch. I did not do a full-library pixel diff against main for this one; V1/V2 behaviour is covered by the tests above. 🤖 Generated with Claude Code |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Merge Risk:
|
|
Fixed at
The develop, engine, GPU, pipeline and raster suites passed. Command: Not tested: other adapters, native UI, Lightroom equivalence, integration with main or full CI. All images were procedural fixtures. |
6888f8f to
69acead
Compare
|
Rebased on main (render-cache 70, latest process V2), so this PR now bumps the render cache to 71 and adds V3 as the latest process, with docs/process-versions.md updated; the sharpen path is ported into main's finish-stage helper and the description says 71. |
|
A version heads-up, since this now adds process V3: my #1383 (calibrated Contrast and Blacks) also adds a process V3, and render cache 71 is also taken by #758 and my #1463. Neither has merged, so there's nothing to change now. Whichever of these lands second should move to the next free process and cache numbers. I'll renumber mine if this lands first. |
|
@AlexChambers Thanks for the heads-up, agreed. Whichever of #762, #1383, #758 and #1463 lands second moves to the next free process and render-cache numbers, and nothing changes until one of them merges. |
…torytold#757) The sharpening blur's sigma was capped at 4 px, so a 2x export rendered Radius 2 and 3 alike (both scaled past 4 px). The cap is now the largest sigma the Gaussian taps support, GAUSS_SIGMA_MAX (64), which the CPU and GPU blurs share. Test: enlarged_export_keeps_radius_steps_apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014ti8KemZbjE2ZgHgV1q1BM
…torytold#757) Use the V3 pixel-scale blur and Masking weight for the Radius, Detail and Masking previews on both renderers. Preserve the legacy texture-band previews for V1/V2 and compute the same Gaussian when sharpening is disabled. Cover process selection, radius changes, and prepared/fresh plane equivalence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014ti8KemZbjE2ZgHgV1q1BM
8e95eca to
befa9f8
Compare
|
Rebased on main (c4fd54e). Main added Alt-drag previews for Radius, Detail and Masking after this PR was opened, so the rebase also connects them to V3: on V3 the previews now show the pixel-scale band and the V3 Masking weight, on both CPU and GPU. V1/V2 keep main's previews unchanged. A new test checks that each process picks the right band, that changing Radius changes the V3 preview, and that the cached and freshly computed planes match. RENDER_CACHE_VERSION is now 73 (main is 72). |
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the diff: Radius and Detail work in sharpening, and sharpening acts at pixel scale (#757). A new process version Process::V3 ("pixel-scale sharpening with working Radius and Detail controls") becomes LATEST, ALL has three entries, and the process maps to ProcessVersion(3), so photos edited with V1 or V2 keep their old rendering and only new edits use V3; the GPU side gets a Gaussian module (gauss.wgsl with gauss_h and gauss_v entries and a taps buffer), new uniform parameters (SHARPEN_LIMIT, SHARPEN_GAIN, SHARPEN_V3, SHP_OFF, HAS_SHP) and a sharpening blur plane. RENDER_CACHE_VERSION goes to 73. Versioning a process so existing edits do not change under the user is the right mechanism; the point to check is that the controls the old versions ignored (Radius and Detail "did not work") keep being ignored in V1 and V2 and that the UI says so. As with lightcraft#2598 the CPU and GPU paths both change, so the equivalence tests that skip without a GPU adapter (see lightcraft#3519) must be run somewhere. A shader file is added (wgsl/gauss.wgsl), which I did not read. I read about 30 lines of the Rust. I have not run it, and no exact-head CI result exists for this head, so this is a source-read comment and not an approval. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
|
Still no correct or useful sharpen as v0.18.0. Madness. This should be a top priority. Now the comparison with lightroom or even free tools is not even considerable. |
…g (process V3) Conflicts, all from storytold#762 and storytold#3407 both adding V3: - settings.rs: one V3 variant, its doc lists both changes. - finish.rs: keep storytold#3407's fade_lifted_toe and storytold#762's sharpening helpers; base_tone keeps storytold#3407's arms (V3 toe-lifted, V1/V2 without_toe), since storytold#762 doesn't change the tone map. - process-versions.md: one V3 row listing each change by PR.
…ght again storytold#2313 moves V3's Whites and Blacks out of the base tone curve into ToneMap::with_whites_blacks_v3, so the curve is built with Blacks 0 and storytold#3407's neutral toe (ToneMap::toe, set only by ToneMap::hdr) was zero on V3: a positive Blacks scaled a dark pixel's cast up again, and blacks_lift_fades_deep_shadows_to_neutral rendered magenta. with_whites_blacks_v3 now sets the toe to the light storytold#2313's Blacks curve adds where its lift is fully in (tone::blacks_lift_v3_toe; 0.08 encoded, where the curve's ease-in from black ends). finish::fade_lifted_toe and the GPU kernel already read ToneMap::toe (the TOE finish parameter), so CPU and GPU both fade it. base_tone keeps it on raws only: with storytold#2313 the curve is the same for camera looks, so they get it too; JPEGs and other display-referred sources keep their shadows' colour. V1 and V2 are unchanged (without_toe). Tests: the neutral-lift test also runs on a camera-look raw, a unit test for blacks_lift_v3_toe, and v3_renders_like_v2_without_its_sliders turns off sharpening and colour NR, which V3 also changes (storytold#762, storytold#1348).
…atch dark channel, eased response) Ported onto main's reorganised dehaze code: - finish.rs: main moved the per-pixel dehaze into adjust_scene_pixel and caps the veil estimate at the pixel's minimum channel on every process (storytold#2504). The V3 branch (dehaze_v3_pixel) goes there, after that cap. - finish.wgsl: the same, after main's cap. - local.rs / gpu render.rs: storytold#1283's min_hv / dark_plane / dark_key next to main's total_key helpers and its sharpen plane (storytold#762); PlaneSigmas has both sharpen and dark_patch. main's airlight-proxy test computes its fresh airlight through dark_plane (the default settings are V3). - tests_dehaze: V1's ground darkening is -0.21 EV on main (was below -0.4 when the PR was written), since storytold#2504 already fixed V1's black shadows; the V1 bound is now -0.15. So on main storytold#1283 mainly helps with Dehaze darkening areas that aren't hazy (V3: -0.08 EV). - docs: the V3 row lists the change.
…er (process V3) Conflicts: - finish.rs base_tone: keep the earlier merges' V3 arm (storytold#1348 doesn't change the tone map). - lib.rs Plan: main's native_long (storytold#762) and storytold#1348's noise_key / full; storytold#1348's colour_noise next to it. - tests.rs: main's zero-width-crop grain test and storytold#1348's process-change cache test, both kept. - settings.rs: one V3 variant, its doc lists every change. - docs: one V3 row; What's New entry under the bundle's dated heading.
…r V3 sharpening and V4 calibrated light (storytold#1632) Main took V3 (pixel-scale sharpening, storytold#762) and V4 (calibrated Contrast and Blacks, storytold#1383). V5 is V4 with a raw's tone curve rolling off into white in stops. The flat-segment floor of the shoulder now grows like u instead of u², so a lowered DRO-off curve stays below its fitted curve under V5, and dro_off raises the second-last knot for that bound too (the_lowered_curve_stays_below_the_fitted_one_past_its_last_knot, case 60). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #757.
Radius and Detail now affect sharpening: V3 uses an exact Gaussian at a radius measured in original-photo pixels, with Detail controlling halo damping and Masking suppressing flat areas. A reduced source retains the original photo’s dimensions for both CPU and GPU preparation. Subpixel sharpening follows the continuous Gaussian response without disappearing at a hard radius cutoff.
This is a new process, V3. Existing V1/V2 edits retain their original texture-band sharpening until explicitly updated. The sharpen plane is keyed by radius and process, and a noise-reduction change invalidates it even during a draft; the existing broad-plane cache reuse stays intact. Render-cache version is 71.
CPU pipeline/settings/raster regressions pass, covering working controls, old-process behavior, size/source-level handling, process/NR cache changes, subpixel response and hostile Gaussian inputs. All 18 GPU equivalence tests pass; the focused reduced-source/process/NR cases differ from CPU by at most one 8-bit level. Eight paired V1/V2 exports (raw and procedural sources, two output sizes) are pixel-identical to main. Radius/Detail crops were inspected. Parity, layers and assets pass. Wasm compilation passes. Full CI stops at the unchanged main
tests_export.rsClippydrop_non_droperror.Summary by CodeRabbit