Repository navigation
LR-EDIT-EFFECTS-GRAIN: replace grid noise with signed particle grain - #2330
SourceFelony wants to merge 2 commits into
Conversation
Migrate existing grain settings to the sole particle renderer, preserve numeric edits, and explicitly fall back from GPU for active grain. Add render/export, settings, sync and undo regressions; document the intentional appearance break and approximation/performance limits. Co-authored-by: Hermes Agent <hermes@nousresearch.com>
Full cargo xtask ci passed all eight gates on the rebased implementation; record the expanded upstream workspace coverage. Optional corpus, font and model skips remain explicitly disclosed. Co-authored-by: Hermes Agent <hermes@nousresearch.com>
FredApps
left a comment
There was a problem hiding this comment.
I read the whole diff (grain.rs, the finish.rs and GPU removals, settings.rs, the three new test files and the docs). I haven't built or run it (no cargo here), and I can't judge how the grain looks, so this is by my reading. I'm leaving this as a comment and not an approval: it replaces the grain renderer for everyone, makes it slower by the PR's own numbers, and its author asks for a maintainer's decision against #1060 (open, with a review from AlexChambers). That choice isn't mine to make, and I have two smaller points on top.
What I checked (and it holds).
try_renderreturnsFallback::NotTriedwhensection_enabled("effects") && grain.amount > 0.0, the same conditionFinishParams::newuses foreffectsand the amount, andtry_renderhas one non-gpu caller on main (engine/src/media.rs:1055) which falls back to the CPU on anyErr, so the "callers render every NotTried request on the CPU" claim is true.- The removed constants (
GRAIN_HASH, theGRAIN_H*WGSL consts, the four grainFinishParamsfields) have no other user on the PR head; the leftoverparams.rsandfinish.wgslhunks are only those. Particlesis bounded: the loop coversextentof at most about 3.5σ at the base variance (a handful of 2 px cells per axis), the coordinates are range-checked, and a grain at pitch ≥ 32 returnsNonebefore any work. I found no panic path, and negative cell indices only go throughwrapping_mulonas u32.GrainProcesstakeslegacyandmediumParticlesV1and rejects other strings; storedamount,size,roughnessandseedload unchanged.
1. Decision (hold for a maintainer): one renderer, CPU only, an appearance break, against #1060.
- Every photo with grain
amount > 0leaves the GPU for the whole request, not only for the grain. The PR's own table (a private 7728 × 5152 source, one M1 Max run, forced CPU, with concurrent compilation) has the native export finishing in 5,225 ms with grain against 1,194 ms without (4.4×), 10.96 s against 6.51 s in total, and the docs say both native runs "miss the repository's ≤1s/24MP export aspiration". The author calls these observations, not benchmarks, and I agree they can't be used as a measurement either way. Rule 5 asks for a measured gain on a speed change; this is the reverse, a measured loss, and nothing says how the dragged-draft path behaves (the docs say the GPU capability heuristic is unchanged, so drafts may be slower). - Every saved edit with grain renders differently (the description and the docs say so), and older builds render their own old grain from the same file, so one catalog opened on two versions shows two looks.
- There is no selector, so a maintainer can't ship this beside #1060's renderer and compare; if the project prefers #1060's GPU approach this PR is the wrong one, and if this one is preferred #1060 should be closed. Please don't merge before that is settled in one place.
2. The Roughness default changes from 50 to 0, and not only for the new renderer. controls.rs and Grain::default both move to 0. Anything that reaches roughness through the default now differs, not only the "reset" button: the built-in preset at engine/src/presets.rs:263 sets just {"amount": 15.0}, the XMP import maps GrainFrequency to grain.roughness (crs.rs:385) and so a file with GrainAmount but no GrainFrequency lands on 0 instead of 50, and --set grain.amount=… on the CLI does too. The description says only that the Roughness reset default is 0. If 0 is needed for the particle model, keep the old default for those paths (or state what changes for them); if it isn't, leave 50 as it was.
3. Question on provenance of the constants. The docs call the work "original clean-room Rust", but BASE_VARIANCE = 0.8² + 0.65²/4 and the size mapping (0.25 + 0.016·size)/0.65 come from "the selected reference aperture" and "the Medium target" of a "Boolean disk reference" that the docs never name. Please name that reference and its licence, and say whether its source (not only the paper) was read. The "Experimental fork" and "This fork has one renderer" wording in settings.rs and the parity checklist reads oddly in this repo; please say what is meant or drop it.
No UI strings are added, so no catalogs are affected, and the parity row moving from ✅ to 🟡 matches the PR text.
Validation request (head dd7537d2af310b5caf9d34c0d8a9d974e82fbd45; after the decision above):
- os: linux and windows (the local run is macOS arm64 only, as the description says)
- commands:
cargo fmt --all -- --check;cargo clippy --workspace --all-targets --locked --offline -- -D warnings;cargo test -p lightcraft-pipeline -p lightcraft-engine -p lightcraft-gpu --locked --offline;cargo xtask ci; export the same raw at native size with grain 0 and grain 40 (LIGHTCRAFT_GPU=0for both, and once on the GPU for the no-grain case) and report the wall times; a drag in Develop with grain 40 on a 24 MP photo - expected: all pass, 0 ignored, and no unexplained availability skips for the grain tests; export times of the same order as the PR's table
- holds: the renderer decision against #1060 (point 1); the roughness default (point 2); the reference named (point 3); no receipt on Linux or Windows for this head
FredApps
left a comment
There was a problem hiding this comment.
Code-only review at dd7537d; no CI has run on this head yet.
This changes how existing edits render without a new process, which docs/process-versions.md forbids ("A change that alters how existing settings render ships as a new process. V1 is frozen."). The description says existing edits containing grain "render differently", and crates/develop/src/settings.rs:606 maps the old process (legacy, and a missing field) onto the new renderer, while crates/pipeline/src/finish.rs deletes the grid-noise path outright.
- Add the particle grain as the next Process (and keep the grid-noise grain for the earlier ones, branching in finish::base_tone's way on s.process.process()), so photos keep their look until Update to Current Process. Add the process to the cache key of any stage it changes.
- The new GrainProcess enum duplicates what ProcessVersion is for; drop it, and keep settings_saved_before_process_versions_load_as_v1 passing.
- Removing the GPU grain path (crates/gpu/src/lib.rs:470 returns NotTried for any active grain) sends the whole render to the CPU for every photo with grain. The author's own timings in the description are single runs on one machine; please keep GPU grain for the earlier process, and give a hardware log if the new one stays CPU-only.
- Roughness default 50 to 0 (crates/develop/src/controls.rs:253) is a separate change to the controls; keep it out of this PR or justify it with the process change.
Drop the "this fork" wording in the comments too.
|
For the maintainers' choice between this PR and #1060, here are the concrete differences as of today, from both descriptions and the code. Existing edits.
GPU.
Defaults and saved files.
Use. I tuned #1060's grain by hand on my own wedding work, 45 MP Canon EOS R5 C raws, since mid-October. I wanted texture I could leave visible without the softening Lightroom's grain adds, which is why I'd always kept Lightroom's grain very low. If the project prefers this PR's look, #1060 picks the grain model per process (one |
wanikhawar
left a comment
There was a problem hiding this comment.
This changes crates/gpu/Cargo.toml: please confirm any new dependency's licence is on standards/licences.md (rule 26), and record where the particle-grain approach comes from (rule 24). It conflicts with main and has no CI results; please rebase.
Summary
Replace the smooth grid/value-noise grain overlay with a small, independently authored signed-particle renderer. This is an alternative approach to the texture problem described in #801 and the existing particle-grain proposal in #1060, not a continuation of that PR.
The goal is a simpler film-inspired texture while retaining the existing Amount, Size and Roughness controls. This implementation has been visually evaluated on photographic sky and detail regions. It is an artistic approximation, not an exact Boolean-model implementation, measured film-stock simulation, or claim of Lightroom parity.
Changes
legacyandmediumParticlesV1process inputs to the sole current renderer, preserving existing numeric values. Unknown process names are rejected. Canonical serialization changes settings/cache keys to avoid reusing old-grain renders.docs/experimental-medium-grain.md.Intentional behavior change and limitations
Existing edits containing grain render differently. Numeric settings load unchanged, but the previous texture is not preserved. Older released applications do not understand the new process and should not be used to round-trip these edits.
Active grain is CPU-only and forces the entire request onto CPU, even when a GPU is available. This is a material tradeoff compared with the GPU-enabled alternative in #1060. Earlier single runs on an M1 Max with concurrent compilation took 2.05 seconds total for a 2000×1333 preview and 10.96 seconds for a 7728×5152 native export. These are qualified observations, not controlled benchmarks or performance-parity claims.
Gaussian aperture filtering, finite tail truncation and extreme-reduction fade-out are approximations. The implementation does not reproduce the Boolean reference's occupancy statistics or claim exact downsampling equivalence. GPU implementation, measured-stock calibration and further performance work are outside this PR. No personal photographs, comparison fixtures, or external reference implementation are committed.
Please evaluate the texture/complexity tradeoff and intentional appearance break against #1060 rather than treating this as an assertion that one model is universally preferable.
Verification
Rebased onto
d999e382bafbb5d5c54482fdb1d11f6a63bfdf69.cargo xtask ci: all eight gates passed on macOS arm64, Rust 1.97.1, Apple M1 Max Metal. Includes formatting, strict all-targets workspace Clippy, HEIF, tests, parity, layers, assets and 29 WASM compile checks.Maintainer review and repository CI are still required. Please do not merge solely on the local verification report.
Summary by CodeRabbit
New Features
Changes