diff --git a/crates/nodes/src/pattern/shape.rs b/crates/nodes/src/pattern/shape.rs index b9fcb2d2..c579bf61 100644 --- a/crates/nodes/src/pattern/shape.rs +++ b/crates/nodes/src/pattern/shape.rs @@ -11,17 +11,12 @@ pub(super) fn coverage(pattern: i32, x: f32, y: f32, variation: f32) -> Result radial, - 4 => { - // The expanded quartic preserves the rounding of the low-coverage skirt. - let t = radius_squared.min(1.0); - let quadratic = (t - 4.0).mul_add(t, 6.0); - quadratic.mul_add(t, -4.0).mul_add(t, 1.0).max(0.0) - } + 4 => quartic_bell(radius_squared).max(0.0), 5 => { const FALLOFF: f32 = 11.1 * std::f32::consts::LOG2_E; (crate::function::pixel_exp2(-FALLOFF * radius_squared) - 0.000_015_1).max(0.0) } - 6 => (1.0 - radius_squared.sqrt()).max(0.0).powi(4), + 6 => (1.0 - crate::function::pixel_sqrt(radius_squared)).max(0.0).powi(4), 7 => (1.0 - x.abs().max(y.abs())).max(0.0), 8 if variation <= 0.0 => 1.0, 8 => { @@ -45,27 +40,37 @@ pub(super) fn coverage(pattern: i32, x: f32, y: f32, variation: f32) -> Result radial * radial * if x >= 0.0 { 1.0 } else { 0.0 }, - 12 => (1.0 - x.abs()).max(0.0).powi(2), + 11 => quartic_bell(radius_squared) * descending_fade(x, variation), + 12 => quartic_bell(radius_squared) * (1.0 - x.abs()).powi(2), 13 => { - if radius_squared <= 1.0 && (x - variation.max(0.05)).powi(2) + y * y > 1.0 { - 1.0 - } else { - 0.0 - } + let t = radius_squared.min(1.0); + // Normalize t(1-t)² to one at t=1/3. + let ring = 6.75_f32.mul_add(t, -13.5).mul_add(t, 6.75) * t; + ring * descending_fade((x + 1.0) * 0.5, variation) } 14 => { - if (x.abs() - 0.5).max(0.0).powi(2) + y * y <= 0.25 { - 1.0 - } else { - 0.0 - } + let tip = (x.abs() - 0.77 * variation.max(0.0)).max(0.0); + let distance_squared = y.mul_add(y, tip * tip); + (-20.0_f32).mul_add(distance_squared, 1.0).max(0.0) } - 15 => (1.0 - radius_squared.sqrt()).max(0.0), - 16 => radial.sqrt(), - 17 => ((x + 1.0) * 0.5 + variation).fract(), + 15 => (1.0 - crate::function::pixel_sqrt(radius_squared)).max(0.0), + 16 => (x + 1.0) * 0.5 + variation, + 17 if radius_squared <= 1.0 => crate::function::pixel_sqrt(radial) + variation, + 17 => 0.0, _ => return Err(format!("unknown built-in pattern {pattern}")), }; Ok(value) } + +fn quartic_bell(radius_squared: f32) -> f32 { + // The expanded quartic retains the signed rounding of the low-coverage skirt. + let t = radius_squared.min(1.0); + (t - 4.0).mul_add(t, 6.0).mul_add(t, -4.0).mul_add(t, 1.0) +} + +fn descending_fade(position: f32, variation: f32) -> f32 { + let width = 1.0 - variation.max(0.0); + let t = if width == 0.0 { f32::from(position > 0.0) } else { (position * width.recip()).clamp(0.0, 1.0) }; + (t * t).mul_add(2.0_f32.mul_add(t, -3.0), 1.0) +} diff --git a/crates/nodes/src/pattern/tests.rs b/crates/nodes/src/pattern/tests.rs index fea72106..3e946bf3 100644 --- a/crates/nodes/src/pattern/tests.rs +++ b/crates/nodes/src/pattern/tests.rs @@ -45,6 +45,30 @@ fn wave_frequency_and_radial_falloff_follow_stamp_coordinates() { assert_eq!(super::shape::coverage(11, 0.0, 0.5, 0.25).unwrap(), 0.75); } +#[test] +fn stamp_profiles_follow_the_radial_and_horizontal_falloffs() { + // Two samples on the low-coverage skirt distinguish the signed quartic from a clamped falloff. + for (shape, x, y, variation, bits) in [ + (7, 0xbf0c0000, 0xbd40000f, 0.0, 0x3d29a3c2), + (12, 0xbeb80001, 0xbef80001, 0.25, 0x3e27c967), + (12, 0x3ec7fffd, 0xbec80001, 0.25, 0x3ddfc34c), + (12, 0x3f3bfffe, 0x3f2bfffe, 0.25, 0xadf38c4f), + (13, 0xbf3c0000, 0x3f2bfffe, 0.25, 0xb1cb84a4), + (13, 0x3ec7fffd, 0xbec80001, 0.25, 0x3db1415d), + (14, 0xbeb80001, 0xbef80001, 0.0, 0x3f40da6b), + (14, 0x3ec7fffd, 0xbec80001, 0.25, 0x3c774318), + (15, 0x3e4ffffb, 0x3c7fffbf, 0.0, 0x3e2e002d), + (15, 0x3e4ffffb, 0x3c7fffbf, 0.25, 0x3f7e2c09), + (16, 0xbe880001, 0xbf740000, 0.0, 0x3c2ce9c0), + (17, 0x3ec7fffd, 0xbec80001, 0.5, 0x3f990000), + (18, 0x3ec7fffd, 0xbec80001, 0.25, 0x3f8ab222), + (18, 0xbf7c0000, 0xbf7c0000, 0.25, 0x00000000), + ] { + let value = super::shape::coverage(shape, f32::from_bits(x), f32::from_bits(y), variation).unwrap(); + assert_eq!(value.to_bits(), bits, "shape {shape} at ({x:08x}, {y:08x})"); + } +} + fn cook(graph: PatternGraph) -> crate::CookResult { cook_with_variables(graph, &BTreeMap::new(), 7) } diff --git a/docs/parity-fixes.md b/docs/parity-fixes.md index 195b6989..dba02b06 100644 --- a/docs/parity-fixes.md +++ b/docs/parity-fixes.md @@ -1544,6 +1544,45 @@ For shape 11 the radial term is max(0,1−x²−y²). In eight 128² F32 unit-st The [radial profile comparisons](#radial-stamp-profiles-and-pattern-generators) give the previous placement controls. At 64² and 128², float32(2(i+.5)(1−2⁻²⁴)/N−1) predicts the unit gradient coordinates. Four of the 32 axis values at 32² still disagree. Rotated and translated coordinates remain open. +### Directional and additive stamp profiles + +Eight built-in shapes were measured in original single-stamp graphs. Across 260 renders, the complete renderer improved from 297,007 to 727,162 exact pixels out of 892,928. Color requires all four stored channels to match. Integer maxima are channel levels. + +| Shape | Renders | Previous exact | Current exact / compared | Maximum U8 / U16 | Maximum F16 / F32 | +|---|---:|---:|---:|---:|---:| +| 7 | 22 | 64,360 | 65,705/77,824 | 0 / 1 | 3.05175781e-05 / 4.76837158e-07 | +| 12 | 36 | 33,547 | 98,446/122,880 | 0 / 1 | 0.00048828125 / 1.4603138e-06 | +| 13 | 36 | 4,828 | 91,739/122,880 | 0 / 1 | 1.90734863e-06 / 8.94069672e-07 | +| 14 | 36 | 49,550 | 102,396/122,880 | 1 / 1 | 0.000122070312 / 1.08778477e-06 | +| 15 | 36 | 68,714 | 117,354/122,880 | 1 / 1 | 0.00048828125 / 4.24683094e-06 | +| 16 | 22 | 64,624 | 65,947/77,824 | 0 / 1 | 7.62939453e-06 / 1.78813934e-07 | +| 17 | 36 | 5,559 | 90,439/122,880 | 1 / 12544 | 0.00048828125 / 0.191406265 | +| 18 | 36 | 5,825 | 95,136/122,880 | 0 / 12544 | 0.00048828125 / 0.191407166 | + +Start from a single centered unit stamp with no background, unit opacity, roughness zero and blend mode 1. Declare the graph output and stamp consistently grayscale or RGBA. For variation 0, .25, .5 and 1 (index j), compare grayscale 32² F32, then 64² U8, U16, F16 and F32. Use seed 177+size+j. At .25 also compare 64² RGBA16 and RGBA32F with tint (.75,.375,1,.625). For shapes 12–15, 17 and 18, add four controls at 32² F32 and 64² U16/F32, seed 491+73j+size. Use a unit stamp at variation −.25, a (1.375,.6875) stamp at .0625 turns with offset (.109375,−.1875) and variation .3125, a (.75,1.125) stamp at .25 turns with offset (−.0625,.125) and variation .71875, then a unit stamp at offset (.0078125,.0078125) and variation 1.25. Repeat the first additional control with the same 64² color tint. + +Shapes 12 and 13 multiply a signed quartic bell by a horizontal mask. For 12 the mask is 1−3u²+2u³ with u=clamp(x/(1−max(variation,0)),0,1). At variation 1 the positive half is cut off. For 13 the mask is (1−|x|)². Shape 14 multiplies the same smooth mask, using (x+1)/2 horizontally, by the normalized ring 6.75t(1−t)², where t=min(x²+y²,1). Shape 15 uses max(0,1−20(y²+max(0,|x|−.77×max(variation,0))²)). Shapes 7 and 16 use the measured pixel square root for their conical falloff. + +In the scalar profile controls, shape 17 adds variation to (x+1)/2. Shape 18 adds it to the hemisphere height inside the disk and returns zero outside. Their floating outputs exceed one in the positive-variation controls. At the 64² unit-stamp coordinates from the [radial controls](#radial-stamp-profiles-and-pattern-generators), both scalar profiles predict all 4,096 samples at each of four variations. Absolute stamp placement, signed blending and the order of variation and color tint affect the full-render results. For shape 17 at (0,0), variation .25, the tinted reference red/green channels are .253662109375/.2518310546875 and the current channels are .120849609375/.0604248046875. + +| Inventory root | Renders | Exact / compared | Maximum U8 / U16 | Maximum F16 / F32 | +|---|---:|---:|---:|---:| +| creased.sbs/creased | 9 | 41,224/132,096 | 1 / 632 | 0.00048828125 / 0.000534534454 | +| crystal_2.sbs/crystal_2 | 9 | 102,021/132,096 | 13 / 4663 | 0.0494384766 / 0.0494220853 | +| fluid.sbs/fluid | 9 | 295/132,096 | 52 / 33520 | 0.20111084 / 0.201334268 | +| make_it_tile_patch.sbs/make_it_tile_patch | 9 | 12,322/132,096 | 196 / 47176 | 0.719848633 / 0.719859615 | +| make_it_tile_patch_grayscale.sbs/make_it_tile_patch_grayscale | 9 | 19,086/132,096 | 144 / 26181 | 0.399658203 / 0.459052384 | +| mesh_1.sbs/mesh_1 | 9 | 38,454/132,096 | 0 / 544 | 0 / 1.52587891e-05 | +| mesh_2.sbs/mesh_2 | 9 | 34,148/132,096 | 0 / 1102 | 0 / 1.52606517e-05 | +| messy_fibers_3.sbs/messy_fibers_3 | 9 | 126,928/132,096 | 1 / 3 | 0.0009765625 / 5.23328781e-05 | +| noise_creased.sbs/creased | 9 | 37,716/132,096 | 1 / 775 | 0.00048828125 / 0.000442534685 | +| noise_crystal_2.sbs/crystal_2 | 9 | 41,321/132,096 | 1 / 620 | 0.005859375 / 0.00588941574 | +| noise_directional_scratches.sbs/directional_scratches | 9 | 111,002/132,096 | 1 / 1 | 0.00048828125 / 5.30481339e-06 | +| noise_directional_scratches_v2.sbs/directional_scratches | 9 | 129,384/132,096 | 1 / 1 | 0.000122070312 / 6.22868538e-06 | +| noise_dirt_3.sbs/dirt_3 | 9 | 106,101/132,096 | 1 / 3 | 0.00048828125 / 3.20076942e-05 | + +These nine-render comparisons include the original archived defaults, seed and changed setting, the 64² four-format sweep and the independent 32² case from the [inventory measurements](#four-format-inventory-comparison). In the 32² comparison Mesh 1 improved from 0 to 1,020 exact, Mesh 2 from 48 to 992, Messy Fibers 3 from 1 to 48 and Noise Creased from 0 to 136, each out of 1,024. All thirteen roots retain measured differences. + ### Radial stamp profiles and pattern generators A single stamp in an original grayscale pattern graph isolates the local profile. For each shape, use a centered stamp of size (1,1), then a quarter-turn, then size (1.375,.6875) at .0625 turns with offset (.109375,−.1875). Render at 16² F32/seed 433, 32² F32/127, 64² in U8, U16, F16 and F32/733, and 128² F32/983. The counts compare stored pixels for all 21 renders per shape. diff --git a/docs/sbs-root-nodes.md b/docs/sbs-root-nodes.md index 580ff185..aeaa45a4 100644 --- a/docs/sbs-root-nodes.md +++ b/docs/sbs-root-nodes.md @@ -35,7 +35,7 @@ A graph may accept input pins and still be a root under the dependency criterion Statuses: **Not checked**, **In progress**, **Parity** (exact pixels or typed values for the linked measured cases), or **Too hard** (reason recorded). Function calls do not count as regular graph dependencies. -The first pass covered all **546 roots**, with **166 Parity** and **380 Too hard**. The current inventory has **342 Parity**, **55 In progress** and **149 Too hard**. The November 17 and 18 comparisons include raw counts, output formats and remaining differences. [November 17 measurements](parity-fixes.md#2026-11-17-root-comparisons) · [November 18 measurements](parity-fixes.md#2026-11-18-root-comparisons) +The first pass covered all **546 roots**, with **166 Parity** and **380 Too hard**. The current inventory has **342 Parity**, **59 In progress** and **145 Too hard**. The November 17 and 18 comparisons include raw counts, output formats and remaining differences. [November 17 measurements](parity-fixes.md#2026-11-17-root-comparisons) · [November 18 measurements](parity-fixes.md#2026-11-18-root-comparisons) [Grayscale sampler measurements](parity-fixes.md#grayscale-sampling-of-color-inputs) · [Value sampling across 240 typed comparisons](parity-fixes.md#value-processor-texture-filtering) @@ -262,8 +262,8 @@ The first pass covered all **546 roots**, with **166 Parity** and **380 Too hard | [mean_of_least_variance.sbs/mlv_grayscale_iteration](../assets/sbs/mean_of_least_variance.sbs) | 1 | Yes | [Parity · 171,264 exact pixels across 18 renders](parity-fixes.md#color-conversion-gradient-height-and-histogram-controls) | | [median_filter.sbs/median_filter_color](../assets/sbs/median_filter.sbs) | 1 | No | [Parity · 171,264 exact pixels across 18 renders](parity-fixes.md#color-conversion-gradient-height-and-histogram-controls) | | [median_filter.sbs/median_filter_grayscale](../assets/sbs/median_filter.sbs) | 1 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) | -| [mesh_1.sbs/mesh_1](../assets/sbs/mesh_1.sbs) | 0 | Yes | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | -| [mesh_2.sbs/mesh_2](../assets/sbs/mesh_2.sbs) | 0 | Yes | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | +| [mesh_1.sbs/mesh_1](../assets/sbs/mesh_1.sbs) | 0 | Yes | [In progress · 38,454/132,096 pixels across 9 renders](parity-fixes.md#directional-and-additive-stamp-profiles) | +| [mesh_2.sbs/mesh_2](../assets/sbs/mesh_2.sbs) | 0 | Yes | [In progress · 34,148/132,096 pixels across 9 renders](parity-fixes.md#directional-and-additive-stamp-profiles) | | [mesh_adaptive_base_color.sbs/base_color_2_inputs](../assets/sbs/mesh_adaptive_base_color.sbs) | 2 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) | | [mesh_adaptive_base_color.sbs/base_color_4_inputs](../assets/sbs/mesh_adaptive_base_color.sbs) | 2 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) | | [mesh_adaptive_base_color.sbs/base_color_8_inputs](../assets/sbs/mesh_adaptive_base_color.sbs) | 2 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) | @@ -273,7 +273,7 @@ The first pass covered all **546 roots**, with **166 Parity** and **380 Too hard | [mesh_data_combiner.sbs/mesh_data_combiner](../assets/sbs/mesh_data_combiner.sbs) | 11 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) | | [messy_fibers_1.sbs/messy_fibers_1](../assets/sbs/messy_fibers_1.sbs) | 0 | Yes | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | | [messy_fibers_2.sbs/messy_fibers_2](../assets/sbs/messy_fibers_2.sbs) | 0 | Yes | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | -| [messy_fibers_3.sbs/messy_fibers_3](../assets/sbs/messy_fibers_3.sbs) | 0 | Yes | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | +| [messy_fibers_3.sbs/messy_fibers_3](../assets/sbs/messy_fibers_3.sbs) | 0 | Yes | [In progress · 126,928/132,096 pixels across 9 renders](parity-fixes.md#directional-and-additive-stamp-profiles) | | [messy_fibers_4.sbs/messy_fibers_4](../assets/sbs/messy_fibers_4.sbs) | 0 | Yes | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | | [microscope_view.sbs/microscope_view](../assets/sbs/microscope_view.sbs) | 0 | Yes | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | | [min_max.sbs/min_max](../assets/sbs/min_max.sbs) | 1 | No | [Parity · both scalar outputs exact in 25 cases](parity-fixes.md#color-temperature-range-reductions-sky-parameters-and-polygon-paths) | @@ -299,7 +299,7 @@ The first pass covered all **546 roots**, with **166 Parity** and **380 Too hard | [noise_clouds_1_v2.sbs/clouds_1](../assets/sbs/noise_clouds_1_v2.sbs) | 0 | No | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | | [noise_clouds_2.sbs/clouds_2](../assets/sbs/noise_clouds_2.sbs) | 0 | Yes | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | | [noise_clouds_2_v2.sbs/clouds_2](../assets/sbs/noise_clouds_2_v2.sbs) | 0 | No | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | -| [noise_creased.sbs/creased](../assets/sbs/noise_creased.sbs) | 0 | No | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | +| [noise_creased.sbs/creased](../assets/sbs/noise_creased.sbs) | 0 | No | [In progress · 37,716/132,096 pixels across 9 renders](parity-fixes.md#directional-and-additive-stamp-profiles) | | [noise_crystal_1.sbs/crystal_1](../assets/sbs/noise_crystal_1.sbs) | 0 | No | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | | [noise_crystal_2.sbs/crystal_2](../assets/sbs/noise_crystal_2.sbs) | 0 | No | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) | | [noise_directional_noise_1.sbs/directional_noise_1](../assets/sbs/noise_directional_noise_1.sbs) | 0 | Yes | [Too hard: remaining pixel differences](parity-fixes.md#remaining-differences) |