Repository navigation
LR-EDIT-EFFECTS-GRAIN: particle film grain, resolution independent #1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
57fda8e
301fe3d
31fac36
8fd70ce
274e3f0
7db70d1
200b012
724e62a
b4ffd3c
c06829d
b9cf995
c0f623a
8825009
6db9e87
d70904f
1c3fac9
b216941
d3f3ed5
88d3ddc
1ec1190
3801d3f
842d583
3881cc7
d86ee54
a0b3815
765142b
a37b75a
3dadfdf
2f262af
45e1e92
174d2ac
fa72570
a01fd3c
ecd4327
3e85980
e60c334
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -84,17 +84,22 @@ pub enum Process { | |||||
| /// Highlights and Shadows keep the local contrast of the tones they move: their edge-aware base | ||||||
| /// is taken of a fine median of log luminance (issue #632). | ||||||
| V2, | ||||||
| /// Film grain as clumps of irregular particles (a filtered Boolean model, resolution | ||||||
| /// independent) with Size Variation, Clumping, Color and Response; V1 and V2 keep their value | ||||||
| /// noise. | ||||||
| V3, | ||||||
| } | ||||||
|
|
||||||
| impl Process { | ||||||
| /// Every process, oldest first. | ||||||
| pub const ALL: [Process; 2] = [Process::V1, Process::V2]; | ||||||
| pub const LATEST: Process = Process::V2; | ||||||
| pub const ALL: [Process; 3] = [Process::V1, Process::V2, Process::V3]; | ||||||
| pub const LATEST: Process = Process::V3; | ||||||
|
|
||||||
| pub const fn version(self) -> ProcessVersion { | ||||||
| match self { | ||||||
| Process::V1 => ProcessVersion(1), | ||||||
| Process::V2 => ProcessVersion(2), | ||||||
| Process::V3 => ProcessVersion(3), | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -598,15 +603,25 @@ impl Default for Vignette { | |||||
| #[serde(default)] | ||||||
| pub struct Grain { | ||||||
| pub amount: f64, | ||||||
| /// Mean grain size, relative to the frame (0..100; ≈ 4–48 µm on a 35 mm frame). | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Correct the grain size range in the doc comment.
--- "a/crates/develop/src/settings.rs"
+++ "b/crates/develop/src/settings.rs"
@@ -603,7 +603,7 @@
#[serde(default)]
pub struct Grain {
pub amount: f64,
- /// Mean grain size, relative to the frame (0..100; ≈ 4–48 µm on a 35 mm frame).
+ /// Mean grain size, relative to the frame (0..100; ≈ 4.3–18 µm on a 35 mm frame).
pub size: f64,
/// Grain shape (Camera Raw's Roughness): 0 = round grains; 100 = elongated, irregular ones.
pub roughness: f64,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| pub size: f64, | ||||||
| /// Grain shape (Camera Raw's Roughness): 0 = round grains; 100 = elongated, irregular ones. | ||||||
| pub roughness: f64, | ||||||
| /// Seed for the procedural grain (stable per photo). | ||||||
| pub seed: u32, | ||||||
| /// Colour (chroma) grain, 0..100: independent dye-layer grain on top of the luminance grain. | ||||||
| pub color: f64, | ||||||
| /// Where grain is strongest: −100 shadows … 0 midtones … +100 highlights. | ||||||
| pub response: f64, | ||||||
| /// Spread of grain sizes, 0..100: 0 = all grains the mean size. | ||||||
| pub size_variation: f64, | ||||||
| /// Clumping, 0..100: 0 = single grains; 100 = clusters of several grains. | ||||||
| pub clumping: f64, | ||||||
|
Comment on lines
+615
to
+629
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
rg -nP -C5 '\bfn\s+hash64\b' --type=rust
rg -nP -C2 'fn\s+is_zero\b' crates/develop/srcRepository: storytold/lightcraft Length of output: 1162 Do not serialize default grain fields. When settings from before this change are written, the four default-valued grain fields change the serialized JSON and therefore the 🛠️ Suggested fix--- "a/crates/develop/src/settings.rs"
+++ "b/crates/develop/src/settings.rs"
@@ -609,14 +609,18 @@
pub roughness: f64,
/// Seed for the procedural grain (stable per photo).
pub seed: u32,
/// Colour (chroma) grain, 0..100: independent dye-layer grain on top of the luminance grain.
+ #[serde(skip_serializing_if = "is_zero")]
pub color: f64,
/// Where grain is strongest: −100 shadows … 0 midtones … +100 highlights.
+ #[serde(skip_serializing_if = "is_zero")]
pub response: f64,
/// Spread of grain sizes, 0..100: 0 = all grains the mean size.
+ #[serde(skip_serializing_if = "Grain::is_default_size_variation")]
pub size_variation: f64,
/// Clumping, 0..100: 0 = single grains; 100 = clusters of several grains.
+ #[serde(skip_serializing_if = "Grain::is_default_clumping")]
pub clumping: f64,
}
impl Default for Grain {impl Grain {
fn is_default_size_variation(v: &f64) -> bool { *v == 40.0 }
fn is_default_clumping(v: &f64) -> bool { *v == 30.0 }
}🤖 Prompt for AI Agents |
||||||
| } | ||||||
|
|
||||||
| impl Default for Grain { | ||||||
| fn default() -> Self { | ||||||
| Self { amount: 0.0, size: 25.0, roughness: 50.0, seed: 0 } | ||||||
| Self { amount: 0.0, size: 25.0, roughness: 50.0, seed: 0, color: 0.0, response: 0.0, size_variation: 40.0, clumping: 30.0 } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: storytold/lightcraft
Length of output: 1860
🏁 Script executed:
Repository: storytold/lightcraft
Length of output: 40037
🏁 Script executed:
Repository: storytold/lightcraft
Length of output: 41510
🏁 Script executed:
Repository: storytold/lightcraft
Length of output: 23767
Preserve the full persisted seed range.
Grain::seedis au32, and deserialization accepts values above99999. The control reads those values but clamps every edit to0..=99999, so editing an affected photo can change its grain pattern. Widen the control maximum unless the persistence boundary explicitly restricts seeds.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents