Skip to content

LR-EDIT-DETAIL-SHARPEN: Radius and Detail work, and sharpening acts at pixel scale (#757) - #762

Merged
FredApps merged 4 commits into
storytold:mainfrom
radialmonster:sharpen-radius-detail
Nov 5, 2026
Merged

FredApps merged 4 commits into
storytold:mainfrom
radialmonster:sharpen-radius-detail

Conversation

@radialmonster

@radialmonster radialmonster commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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.rs Clippy drop_non_drop error.

Summary by CodeRabbit

  • New Features
    • Added Process V3 with pixel-scale sharpening. Radius controls the sharpening scale, while Detail adjusts the response and reduces halos.
    • Sharpening now accounts for the original photo’s scale in previews and exports, including resized images.
  • Improvements
    • Texture adjustments and sharpening can be applied independently.
    • Processes V1 and V2 retain their previous sharpening behavior.

Copy link
Copy Markdown
Member

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 docs/process-versions.md rules out.

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

AER00 added a commit to AER00/lightcraft that referenced this pull request Oct 11, 2026
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).
AER00 added a commit to AER00/lightcraft that referenced this pull request Oct 11, 2026
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).
@THEtheChad

THEtheChad commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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 tex binding packing. Three concrete additions, from reading the diff against main @ 76b5377:

1. "Source pixels" are the pixels of the cached source level, not the sensor's

sharpen_sigma_raw divides by frame.ow.max(frame.oh), and frame_for builds the frame from src.width/height (crates/pipeline/src/lib.rs:227). In the app, src is often a downscaled source: SourceLevel::for_size (crates/engine/src/media.rs:98) serves outputs up to 520 px from the 512 px thumbnail source and outputs up to 2560 px from the 2560 px preview source. That includes the fit loupe, grid cells and downsized exports (render_weight in export.rs documents the 2048 px export rendered from the 2560 px preview). For a 6000 px raw at Radius 1:

render source passed σ this PR uses (out px) in sensor px with the native long edge
1:1 export 6000 1.0 1.0 1.0
2048 px export 2560 0.80 2.3 0.34 (faded out)
1600 px fit loupe 2560 0.63 2.3 0.27 (faded out)
256 px grid cell 512 0.50 11.7 0.04 (faded out)

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 src. The fix within the current design is one field: SourceInfo::native_long: Option<usize>, which the engine fills from the photo's width/height (it already has them, e.g. export.rs PreparedExport), and sharpen_sigma_raw uses info.native_long.unwrap_or(src_long). Test: render the same scene from a 4x-downsampled source with native_long set, and check that the sigma (or the output) matches the full-source render at the same output size. nr_params has the same bug (Plan::src_long = src.width.max(src.height), lib.rs:425), which is a large part of #960, so the field would fix both.

2. The sub-pixel rule: a response-matched floor instead of a fade

Once (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 gauss_taps (r = ceil(3σ), normalized samples):

σ_out full render, then downsample this PR (fade × taps) fixed 0.6 px floor (#944) 0.5 px floor, Amount × gain
0.10 0.05 0.00 0.66 0.05 (gain 0.11)
0.25 0.27 0.00 0.66 0.27 (gain 0.62)
0.34 0.44 0.005 0.66 0.44 (gain 1.02)
0.40 0.55 0.08 0.66 0.55 (gain 1.28)

So the suggestion is to clamp σ to 0.5 px and scale the sharpen term by gain = (1 − exp(−π²σ_raw²/2)) / (1 − H_taps(0.5; σ=0.5)), capped at 1 above σ 0.5 so 1:1 is unchanged. Previews then keep sharpening of the right strength at the right scale. At half the output's Nyquist it over-sharpens by about 2x, which is still much closer than either the fade or the fixed floor. It's one shared function, so CPU and GPU keep using the same parameters. A test: the boost at Nyquist of a 1/4-size render is within ~20 % of a 1:1 render that is then box-downsampled.

3. Process version, as @bflatastic asked

V2 (#632 / #645) shipped in v0.6.0 (git tag --contains 70103a7e), so this needs V3. The places to gate:

  • plane_sigmas: under V1/V2, sharpening still requests the texture plane.
  • FinishParams carries the mode, and finish.wgsl takes it as a param.
  • The V1/V2 arm keeps the old 1.3 * clamp(det, -0.8, 0.8) term.
  • Equivalence cases run under both processes, plus a test that a V2 raw at default sharpening is byte-identical to main.

The sharpen plane depends only on σ, so the σ-keyed plane_at is enough. It also needs a V3 row in docs/process-versions.md. Rebase notes: docs/parity.md is now docs/parity-checklist.md, RENDER_CACHE_VERSION is 61 on main, and docs/gaps.md should get the matching update.

On #944 (draft), which covers the same controls: it uses radius × ppl / 6000, a 6000 px reference frame with a 0.6 px floor, so Radius isn't in source pixels and small renders over-sharpen (column 3 above). This PR's definition is the one #757 asks for. With (1) and (2) it also holds up in the app's previews.

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.

@emmertex

Copy link
Copy Markdown
Contributor

Ported this into a downstream fork (emmertex/chromaforge#72); two things needed fixing against current main, in case they're useful here:

  • Stale sharpen plane in drafts: local::Planes::for_other_nr drops log_l and texture but not the new sharpen plane, so a draft after a noise-reduction change reused a sharpen blur of the pre-NR image (stage_cache_matches_uncached_render_through_a_slider_session and drafts_keep_wide_planes_across_a_noise_reduction_change… fail). Fix: sharpen: None there too.
  • Process versions: main now has Process (V1–V3); this PR changes how existing Amount/Masking settings render, so per docs/process-versions.md it went in as a new V4, with V1–V3 keeping the Texture-band sharpening (a sharpen_v4 flag in FinishParams/GPU params, and plane_sigmas keeps the texture plane for sharpening before V4). Also dehaze_v3 is matches!(…, V3), which needs to become >= V3 once a V4 exists.

GPU equivalence stays within 1 LSB on both branches.

emmertex referenced this pull request in emmertex/chromaforge Oct 14, 2026
LR-EDIT-DETAIL-SHARPEN: Radius and Detail work, sharpening at pixel scale (port of upstream #762)
@radialmonster

Copy link
Copy Markdown
Contributor Author

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 AlexChambers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@OneSlips

Copy link
Copy Markdown
Contributor

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

@fxdefaut

Copy link
Copy Markdown

The fix is still not implemented in the latest v0.10.0 release, I wonder why?
I don't know how can anyone use that software yet without a working sharpening tool?

OneSlips added a commit to OneSlips/lightcraft that referenced this pull request Oct 21, 2026
… 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>
OneSlips added a commit to OneSlips/lightcraft that referenced this pull request Oct 21, 2026
…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>
@radialmonster

radialmonster commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@fxdefaut This PR hasn't been merged yet, so no release includes it. Releases only ship what is merged into main, and merging is up to the maintainers. 0.11.0 changed code this PR touches, so it needs a rebase first; I'm on it and will post here when it's ready again.

@OneSlips thanks for the wedding test on 571 R5 C files, that's useful evidence for the review.

@radialmonster

Copy link
Copy Markdown
Contributor Author

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

https://claude.ai/code/session_014ti8KemZbjE2ZgHgV1q1BM

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

Process V3 adds pixel-scale sharpening with Radius and Detail controls, using original photo dimensions to scale the sharpening blur. CPU and GPU finish paths apply the separate sharpening plane. V1 and V2 retain texture-band sharpening.

Changes: Process V3 Sharpening

Layer / File(s) Summary
Process version and sharpening radius
crates/develop/src/settings.rs, crates/pipeline/src/lib.rs, crates/pipeline/src/local.rs, crates/pipeline/src/tests_tone.rs, docs/process-versions.md
Adds Process V3 as the latest process and passes the original photo’s long edge into local preparation. V3 derives sharpening radius and gain from source and output dimensions. V1 and V2 retain their prior sharpening behavior.
Gaussian sharpening plane and cache
crates/raster/src/blur.rs, crates/pipeline/src/local.rs, crates/pipeline/src/lib.rs, crates/pipeline/src/tests.rs, crates/gpu/src/ctx.rs, crates/gpu/src/wgsl/gauss.wgsl, crates/gpu/src/render.rs, crates/engine/src/media/source.rs
Adds normalized Gaussian taps and horizontal and vertical GPU blur kernels. CPU and GPU preparation generate or reuse sharpening planes. Cache accounting includes the added planes, and the render cache version increases to 71.
CPU/GPU finish behavior and validation
crates/pipeline/src/finish.rs, crates/gpu/src/params.rs, crates/gpu/src/wgsl/finish.wgsl, crates/pipeline/src/tests_sharpen.rs, crates/gpu/tests/it/equivalence.rs, crates/pipeline/src/lib.rs, docs/parity-checklist.md
The CPU and GPU finish paths separate texture clarity from sharpening. V3 uses the sharpening plane with a Detail-based limit and masking; legacy processes retain texture-based sharpening. Tests cover radius, Detail, masks, source scaling, cache behavior, and CPU/GPU equivalence.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Plan
  participant local_prepare as local::prepare
  participant GaussianBlur as gaussian_taps
  participant Finish as finish
  Plan->>local_prepare: pass native_long and output scale
  local_prepare->>GaussianBlur: blur log luminance with Gaussian taps
  GaussianBlur-->>local_prepare: return sharpen_blur
  local_prepare-->>Finish: provide prepared sharpening plane
  Finish->>Finish: apply V3 sharpening term and mask
Loading

Possibly related issues

Suggested reviewers: alexchambers

Merge Risk: Minimal · previous review 8e95e

The sharpening checklist now identifies the missing preview and marks the feature as partial. No issue in the reviewed change needs resolution before merging.

Security architecture risk: Low · up to 69ace

The change preserves existing edits, and the inspected paths show no new access or privilege bypass. Rendering cost and behavior after reverting to an older version remain limited compatibility risks.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected change affects the current photo’s rendering work and cached derived planes. Source-pointer and geometry checks constrain cache reuse; tracing did not establish a new cross-source, cross-tenant, credential, or privilege path. External consumers and deployment exposure remain outside the available coverage.

Trust Boundaries and Controls

  • observed — The inspected web command path retains parameter parsing and session command checks. Worker rendering resolves stored source data before invoking the pipeline. These caller boundaries were not changed by the PR.

Resilience and Maintainability Implications

  • inferred — The new plane follows existing cache ownership and publication rules. Recorded GPU failure clears the view’s GPU extension before CPU recovery, preventing later reuse of failed cached planes. Mutex-protected lookup/publication and identity checks support concurrent isolation, although dedicated concurrent-render stress coverage was not established.
Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: Radius and Detail support and pixel-scale sharpening in Process V3.
Linked Issues check Passed Issue [#757] is the active direct target. Process V3 uses a Gaussian sharpening plane at source-pixel scale. The implementation uses Radius, applies original-photo dimensions for reduced sources, and …
Out of Scope Changes check Passed The production changes support [#757]. Process V3, Gaussian blur support, original-photo scale handling, process-aware plane caching, and noise-reduction invalidation implement the requested sharpenin…
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Full details: Linked Issues check

Explanation

Issue [#757] is the active direct target. Process V3 uses a Gaussian sharpening plane at source-pixel scale. The implementation uses Radius, applies original-photo dimensions for reduced sources, and adds continuous subpixel response compensation. Detail controls soft clipping and halo damping. Masking gates sharpening in flat areas. V1 and V2 retain texture-band sharpening. CPU and GPU paths cover the V3 behavior, and the added tests cover Radius, Detail, Masking, scale handling, process compatibility, cache invalidation, and CPU/GPU equivalence.

Full details: Out of Scope Changes check

Explanation

The production changes support [#757]. Process V3, Gaussian blur support, original-photo scale handling, process-aware plane caching, and noise-reduction invalidation implement the requested sharpening behavior. The GPU changes provide the required CPU parity. The regression tests and documentation support the implementation and preserve V1/V2 behavior. The render-cache version update is required by the cache format change. No unrelated change is demonstrated.

Finishing Touches

🧪 Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@AlexChambers

Copy link
Copy Markdown
Contributor

Fixed at 6888f8f6: Radius 2 and 3 now produce different 200% exports.

  • The original radius_still_changes_a_two_times_enlarged_export passed: 15,364 pixels changed at 200%, with a maximum difference of 12 byte levels. The contributor's enlarged_export_keeps_radius_steps_apart passed too.
  • My independent engine test retests_encoded_two_hundred_percent_png_keeps_radius_steps_distinct exported actual 256 by 64 PNGs and compared decoded pixels. It found 15,727 changed pixels.
  • retests_enlarged_radius_steps_are_distinct_on_gpu_and_match_cpu passed on Apple M3 Max (Metal). Both radius outputs were distinct; their CPU comparisons differed by at most one byte level. Source inspection confirms both renderers use gauss_taps and its shared sigma limit of 64.

The develop, engine, GPU, pipeline and raster suites passed. Command: cargo test --locked --no-fail-fast -p lightcraft-develop -p lightcraft-engine -p lightcraft-gpu -p lightcraft-pipeline -p lightcraft-raster --features lightcraft-engine/denoise,lightcraft-engine/sam -- --nocapture.

Not tested: other adapters, native UI, Lightroom equivalence, integration with main or full CI. All images were procedural fixtures.

@radialmonster

Copy link
Copy Markdown
Contributor Author

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.

@AlexChambers

Copy link
Copy Markdown
Contributor

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.

@radialmonster

Copy link
Copy Markdown
Contributor Author

@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.

radialmonster and others added 3 commits October 31, 2026 03:36
…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
@radialmonster

Copy link
Copy Markdown
Contributor Author

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 FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@diegozuelli

diegozuelli commented Nov 2, 2026 •

Copy link
Copy Markdown

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.
The correctness and worry about "past edits on pictures" should be put aside. No alpha software shoud be concerned with breaking past behaviours.

jeremyh added a commit to jeremyh/lightcraft that referenced this pull request Nov 3, 2026
…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.
jeremyh added a commit to jeremyh/lightcraft that referenced this pull request Nov 3, 2026
…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).
jeremyh added a commit to jeremyh/lightcraft that referenced this pull request Nov 3, 2026
…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.
jeremyh added a commit to jeremyh/lightcraft that referenced this pull request Nov 3, 2026
…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.
@FredApps
FredApps merged commit d977d3e into storytold:main Nov 5, 2026
6 checks passed
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 5, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sharpening: Radius and Detail have no effect, and Sharpening works at ~11 px (the texture band), not pixel scale

9 participants