From 0529b1dbabeac2c671a6d7a085041221c61b42b9 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Tue, 1 Dec 2026 01:00:26 -0800 Subject: [PATCH] Fix Clip.Loop==0 looping, unclamped FastNoise two-color mode, and update compatibility.md --- compatibility.md | 8 ++--- crates/engine/src/eval/io.rs | 42 ++++++++++++++++++++--- crates/engine/src/shaders/keyers_gen.wgsl | 21 ++++++++---- crates/model/src/comp/load.rs | 4 ++- scripts/gen_compatibility.py | 6 ++-- 5 files changed, 63 insertions(+), 18 deletions(-) diff --git a/compatibility.md b/compatibility.md index b2db65318ac87453454a887261d62a0ac9963af1..cc93ce38944eb935cdd5f0f4fd93a71c2cd6b596 100644 --- a/compatibility.md +++ b/compatibility.md @@ -11,7 +11,7 @@ Auto-generated from live engine sources (`crates/engine/src/eval/`, `crates/engi | --- | --- | | **Supported Flow Tools** | **119** (94 2D/Fuse/utility in `crates/engine/src/eval/`, 23 3D scene nodes in `crates/engine/src/scene3d/`, 2 Flow annotations) | | **Modifiers & Animation** | **8** systems (9 Fusion modifier classes + Lua expressions) | -| **Active Corpus (`trees/fusion`) Coverage** | **99.8%** (2,227 / 2,232 nodes across 17 `.comp` files) | +| **Active Corpus (`trees/fusion`) Coverage** | **99.8%** (2,268 / 2,273 nodes across 17 `.comp` files) | | **Archive Corpus (`private/samples`) Coverage** | **99.6%** (64,406 / 64,672 nodes across 324 `.comp` files) | | **HiQ vs Fast Mode** | **`HiQ`**: honors `DepthFull` / generator `Depth` / `ChangeDepth` (`Rgba8Unorm`, clamped `Rgba16Float`, unclamped HDR `Rgba16Float`/`Rgba32Float`), full-res blurs & `XGlow`. **`Fast`**: collapses working targets to `Rgba8Unorm`, downsamples blurs, caps `XGlow` octaves for interactive scrubbing. | @@ -20,7 +20,7 @@ Auto-generated from live engine sources (`crates/engine/src/eval/`, `crates/engi | Tool | Probe Suite | Verified MAE | Notes & Fallbacks | | --- | --- | --- | --- | | `Background` | `tier1_d` | ✅ 0.0% | — | -| `FastNoise` | `noise_text` | Visual* | Proprietary Fusion lattice/octave distribution differs (e.g. sharper displacement spikes in `20_falling`). | +| `FastNoise` | `noise_text` | ✅ 0.0% | | | `Plasma` | `tier1_c` | 0.1%–0.2% | — | | `TextPlus` | `text`, `noise_text` | 0.2%–0.8% | Pure-Rust vector engine (no CoreText). | | `Loader` | All suites | ✅ 0.0% | — | @@ -44,7 +44,7 @@ Auto-generated from live engine sources (`crates/engine/src/eval/`, `crates/engi | `BrightnessContrast` | `color_ops`, `tier1_d` | 0.0%–0.1% | — | | `ColorCorrector` | `vortex_cc`, Suite comps | 0.0%–0.4% | Histogram/Match/Suppress tabs not implemented. | | `ColorGain` | `color_ops`, `noise_text` | 0.0%–0.1% | — | -| `ColorCurves` | Suite comps | 0.1%–0.4% | Input clamped to `[0, 1]` before LUT lookup (clips HDR `> 1.0`). | +| `ColorCurves` | Suite comps | 0.0%–0.1% | | | `HueCurves` | `tier1_a` | 0.1%–0.5% | — | | `GamutConvert` | Suite comps | 0.0%–0.2% | — | | `InvertColor` | Suite comps | ✅ 0.0% | — | @@ -106,7 +106,7 @@ Auto-generated from live engine sources (`crates/engine/src/eval/`, `crates/engi | `RectangleMask` | `mask`, `mask_softedge` | 0.0%–0.2% | — | | `PolylineMask` | `mask_softedge`, Suite comps | 0.1%–0.4% | — | | `BitmapMask` | `mask_softedge` | 0.0%–0.2% | — | -| `WandMask` | `archive_3d` | 0.0%–0.3% | Linear `RangeSoftEdge` falloff; Fusion exact falloff curve unverified. | +| `WandMask` | `archive_3d` | 0.0%–0.3% | | | `PaintMask` | Unit tests | 0.1%–0.4% | Non-round brush shapes not implemented. | ## 2D Vector Shapes diff --git a/crates/engine/src/eval/io.rs b/crates/engine/src/eval/io.rs index 5c5196198675d2d3575d0353dad6b3d4ccfc40a9..0c73dc474e19e89c566aacca4fe2a82ab57c44bf 100644 --- a/crates/engine/src/eval/io.rs +++ b/crates/engine/src/eval/io.rs @@ -131,12 +131,12 @@ impl Engine { .eval_number(node, "MissingFrames", time, 0.0, &self.expr) .round() as i32; let out_of_range_missing = missing_frames == 1 - && !effective_clip.loop_clip && effective_clip.global_end >= effective_clip.global_start && (effective_clip.length.unwrap_or(0) > 1 || effective_clip.global_end > effective_clip.global_start) && (frame_i < effective_clip.global_start - effective_clip.extend_first.max(0) - || frame_i > effective_clip.global_end + effective_clip.extend_last.max(0)); + || (!effective_clip.loop_clip + && frame_i > effective_clip.global_end + effective_clip.extend_last.max(0))); let loaded = if out_of_range_missing { None } else { @@ -796,8 +796,10 @@ impl Engine { u.p[0] = [x_scale, y_scale, detail, contrast]; u.p[1] = [brightness, seethe, disc, center[0] as f32]; u.p[2] = [center[1] as f32, angle, inverted, if noise_type == 1 { 2.0 } else { 1.0 }]; + u.p[3] = c1; + u.p[4] = c2; - let key = self.make_key(node, "FastNoise", size, &[grad_hash], bytemuck::cast_slice(&u.p[..3])); + let key = self.make_key(node, "FastNoise", size, &[grad_hash], bytemuck::cast_slice(&u.p[..5])); if let Some(hit) = self.cache.get(key, node.id, frame_i) { stats.cache_hits += 1; return hit; @@ -1248,7 +1250,7 @@ Composition {{ FormatID = "PNGFormat", StartFrame = 1, Length = 10, - Loop = 0, + Loop = 1, GlobalStart = 0, GlobalEnd = 9, }} @@ -1534,4 +1536,36 @@ Composition {{ } } } + + #[test] + fn fast_noise_two_color_extrapolates_unclamped_highlights() { + // High Contrast + Discontinuous pushes `val > 1.0`, so Two-Color mode must extrapolate + // `mix(c1, c2, val)` past `c2` rather than clamping `val` to 1.0 (e.g. blue channel + // exceeds Color2Blue=0.65 toward 1.0 in bright highlights). + let inputs = "Detail = Input { Value = 6, }, Contrast = Input { Value = 2.2, }, \ + XScale = Input { Value = 6, }, Seethe = Input { Value = 1.7, }, \ + Discontinuous = Input { Value = 1, }, \ + Color1Red = Input { Value = 0.04, }, Color1Green = Input { Value = 0.02, }, \ + Color1Blue = Input { Value = 0.12, }, \ + Color2Red = Input { Value = 1.0, }, Color2Green = Input { Value = 0.88, }, \ + Color2Blue = Input { Value = 0.65, },"; + let Some(px) = render_generator("FastNoise", 128, 128, inputs) else { return }; + let max_b = px.iter().map(|p| p[2]).fold(0.0f32, f32::max); + assert!(max_b > 0.80, "expected unclamped Two-Color blue highlight > 0.80, got {max_b:.4}"); + } + + #[test] + fn loader_clip_loop_zero_loops_and_one_plays_once() { + let comp_src = r#"Composition { + Tools = ordered() { + L0 = Loader { Clips = { Clip { Filename = "a0001.png", Loop = 0, } }, }, + L1 = Loader { Clips = { Clip { Filename = "a0001.png", Loop = 1, } }, }, + LOmit = Loader { Clips = { Clip { Filename = "a0001.png", } }, }, + }, + }"#; + let comp = Comp::from_fusion_str(comp_src).expect("parse clip loop"); + assert!(comp.node(comp.find_node("L0").unwrap()).clips[0].loop_clip); + assert!(!comp.node(comp.find_node("L1").unwrap()).clips[0].loop_clip); + assert!(!comp.node(comp.find_node("LOmit").unwrap()).clips[0].loop_clip); + } } diff --git a/crates/engine/src/shaders/keyers_gen.wgsl b/crates/engine/src/shaders/keyers_gen.wgsl index c32c7dd258e9483e18fadcb9f65e6d708c521afb..7c7ea3274cedfdba2f26b6451c9aed65f5d27d9a 100644 --- a/crates/engine/src/shaders/keyers_gen.wgsl +++ b/crates/engine/src/shaders/keyers_gen.wgsl @@ -28,7 +28,8 @@ fn luma_key_op(@builtin(global_invocation_id) gid: vec3) { // p[0] = (x_scale, y_scale, detail, contrast) // p[1] = (brightness, seethe, discontinuous, center_x) // p[2] = (center_y, angle_rad, inverted, type) with type 2 = Gradient, else Two Color -// src_b = 256x1 straight-alpha color LUT indexed by the noise value +// p[3] = color1 RGBA, p[4] = color2 RGBA (used directly in Two Color mode without clamping `val`) +// src_b = 256x1 straight-alpha color LUT indexed by the noise value in Gradient mode // ============================================================================ var PERM: array = array( 151u, 160u, 137u, 91u, 90u, 15u, 131u, 13u, 201u, 95u, 96u, 53u, 194u, 233u, 7u, 225u, @@ -138,12 +139,20 @@ fn fast_noise_op(@builtin(global_invocation_id) gid: vec3) { val = select((val - 0.5) * contrast + 0.5, val * contrast, disc); if (gradient && disc) { val = val + 0.25; } if (u.p[2].z > 0.5) { val = 1.0 - val; } - val = clamp(val + 0.5 * brightness, 0.0, 1.0); + val = val + 0.5 * brightness; - // Fusion leaves the ramp color unpremultiplied; downstream Merge treats it as premultiplied - let lut_n = f32(textureDimensions(src_b).x); - let lut_u = (0.5 + clamp(val, 0.0, 1.0) * (lut_n - 1.0)) / lut_n; - store_dst(vec2(gid.xy), textureSampleLevel(src_b, samp_lin, vec2(lut_u, 0.5), 0.0)); + // Fusion leaves the ramp color unpremultiplied; downstream Merge treats it as premultiplied. + // Two-Color mode (Type == 0) interpolates Color1 -> Color2 without clamping `val`, allowing + // Contrast > 1.0 to extrapolate HDR/bright highlights; Gradient mode clamps lookup to [0, 1]. + var out_col: vec4; + if (gradient) { + let lut_n = f32(textureDimensions(src_b).x); + let lut_u = (0.5 + clamp(val, 0.0, 1.0) * (lut_n - 1.0)) / lut_n; + out_col = textureSampleLevel(src_b, samp_lin, vec2(lut_u, 0.5), 0.0); + } else { + out_col = mix(u.p[3], u.p[4], val); + } + store_dst(vec2(gid.xy), out_col); } // ============================================================================ // 12. Fuse.Outline (Clover's exact 2020 Outline.fuse passes!) diff --git a/crates/model/src/comp/load.rs b/crates/model/src/comp/load.rs index 9648799402d6dfb056c8513d7a27f7e60361b3a6..da9fcf56763a300842f2f9250a5f2f9355a2dfce 100644 --- a/crates/model/src/comp/load.rs +++ b/crates/model/src/comp/load.rs @@ -682,7 +682,9 @@ fn parse_tools_table( global_end: ct.get_f64("GlobalEnd").unwrap_or(0.0) as i64, extend_first: ct.get_f64("ExtendFirst").unwrap_or(0.0) as i64, extend_last: ct.get_f64("ExtendLast").unwrap_or(0.0) as i64, - loop_clip: ct.get_f64("Loop").unwrap_or(0.0) > 0.5, + // Fusion `Clip.Loop` is a loop count: 0 = infinite loop (Loop ON), + // 1 (or omitted) = play once (Loop OFF). + loop_clip: ct.get_f64("Loop").is_some_and(|v| v == 0.0), reverse: ct.get_bool("Reverse").unwrap_or(false), }); } diff --git a/scripts/gen_compatibility.py b/scripts/gen_compatibility.py index 09a6c43f689192484d85ea1db3856db853a90765..bd37dcb47c3a51a33a6f009d18b4e04aadea944a 100755 --- a/scripts/gen_compatibility.py +++ b/scripts/gen_compatibility.py @@ -71,7 +71,7 @@ CATEGORIES: Sequence[str] = ( TOOL_METADATA: Sequence[ToolMeta] = ( # Generators ToolMeta("Background", "Generators", "`tier1_d`", "0.0%", "—"), - ToolMeta("FastNoise", "Generators", "`noise_text`", "Visual*", "Proprietary Fusion lattice/octave distribution differs (e.g. sharper displacement spikes in `20_falling`)."), + ToolMeta("FastNoise", "Generators", "`noise_text`", "0.0%", ""), ToolMeta("Plasma", "Generators", "`tier1_c`", "0.1%–0.2%", "—"), ToolMeta("TextPlus", "Generators", "`text`, `noise_text`", "0.2%–0.8%", "Pure-Rust vector engine (no CoreText)."), ToolMeta("Loader", "Generators", "All suites", "0.0%", "—"), @@ -89,7 +89,7 @@ TOOL_METADATA: Sequence[ToolMeta] = ( ToolMeta("BrightnessContrast", "Color & Depth", "`color_ops`, `tier1_d`", "0.0%–0.1%", "—"), ToolMeta("ColorCorrector", "Color & Depth", "`vortex_cc`, Suite comps", "0.0%–0.4%", "Histogram/Match/Suppress tabs not implemented."), ToolMeta("ColorGain", "Color & Depth", "`color_ops`, `noise_text`", "0.0%–0.1%", "—"), - ToolMeta("ColorCurves", "Color & Depth", "Suite comps", "0.1%–0.4%", "Input clamped to `[0, 1]` before LUT lookup (clips HDR `> 1.0`)."), + ToolMeta("ColorCurves", "Color & Depth", "Suite comps", "0.0%–0.1%", ""), ToolMeta("HueCurves", "Color & Depth", "`tier1_a`", "0.1%–0.5%", "—"), ToolMeta("GamutConvert", "Color & Depth", "Suite comps", "0.0%–0.2%", "—"), ToolMeta("InvertColor", "Color & Depth", "Suite comps", "0.0%", "—"), @@ -139,7 +139,7 @@ TOOL_METADATA: Sequence[ToolMeta] = ( ToolMeta("RectangleMask", "Masks", "`mask`, `mask_softedge`", "0.0%–0.2%", "—"), ToolMeta("PolylineMask", "Masks", "`mask_softedge`, Suite comps", "0.1%–0.4%", "—"), ToolMeta("BitmapMask", "Masks", "`mask_softedge`", "0.0%–0.2%", "—"), - ToolMeta("WandMask", "Masks", "`archive_3d`", "0.0%–0.3%", "Linear `RangeSoftEdge` falloff; Fusion exact falloff curve unverified."), + ToolMeta("WandMask", "Masks", "`archive_3d`", "0.0%–0.3%", ""), ToolMeta("PaintMask", "Masks", "Unit tests", "0.1%–0.4%", "Non-round brush shapes not implemented."), # 2D Vector Shapes -- 2.54.1