mirror of
https://github.com/storytold/materialcraft.git
synced 2026-11-20 22:40:59 +01:00
Clip Gaussian stamp coverage outside its unit disc
This commit is contained in:
1 parent
4421f7a926
commit
44cc375dfe
4 files changed
+35
-2
No files matched your search
@@ -13,6 +13,7 @@ pub(super) fn profile(pattern: i32, x: f32, y: f32, variation: f32) -> Result<(f
|
||||
}
|
||||
3 => radial,
|
||||
4 => quartic_bell(radius_squared).max(0.0),
|
||||
5 if radius_squared > 1.0 => 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)
|
||||
|
||||
@@ -7,6 +7,17 @@ fn coverage(shape: i32, x: f32, y: f32, variation: f32) -> f32 {
|
||||
base + offset
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gaussian_stamps_stop_at_the_disc_boundary() {
|
||||
let x = 0.6;
|
||||
let inside = 0.79999;
|
||||
let outside = 0.80001;
|
||||
assert_eq!(coverage(3, x, inside, 0.0), 1.0);
|
||||
assert!(coverage(6, x, inside, 0.0) > 0.0);
|
||||
assert_eq!(coverage(3, x, outside, 0.0), 0.0);
|
||||
assert_eq!(coverage(6, x, outside, 0.0), 0.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn radial_stamps_keep_the_measured_center_and_skirt() {
|
||||
for (x, y, expected) in [
|
||||
|
||||
@@ -489,6 +489,27 @@ For each of the nine [boolean, signed integer and float argument controls](#unco
|
||||
|
||||
Independently name and save the eight scalar packages and the 18 single-argument typed packages through MaterialCraft. Open each saved file in the reference under its fresh identifiers and repeat the comparisons. All 6,400/6,400 LUM32F pixels and 24/24 typed values across 34 outputs match, maximum error zero. Formatting, the release suites for core, nodes, formats, engine, eval and UI, strict workspace Clippy, dependency layers and WebAssembly passed.
|
||||
|
||||
### Gaussian coverage at the disc boundary
|
||||
|
||||
The Gaussian stamp in both Alveolus roots now writes zero outside its unit disc. In the 54 F32 [render-region pairs](#pattern-coordinates-under-a-change-of-render-region), match the Gaussian to the paraboloid at the same coordinate. For each positive paraboloid sample, find the F32 squared radii that round to its observed value under max(0, 1 − r²). Across 147,664/147,664 samples at least one of those radii reproduces the reference Gaussian exactly. For 67,889 samples the paraboloid identifies a unique radius, maximum Gaussian error zero. At 61 additional pixels MaterialCraft previously produced a positive Gaussian where the paraboloid was zero. The largest such value was 7.75708031e−9. The reference Gaussian was zero at all 61 pixels.
|
||||
|
||||
Draw an unrotated, white, single stamp on black with maximum blending and no tiling. Use the four rows below. For each row move the center so the chosen pixel center samples (x,y) = direction × sqrt(1+d) in signed stamp coordinates. Render the disc, paraboloid and Gaussian separately in F32. Use d = 0 and both signs of .000001, .000005, .00001, .00002, .00005, .0001 and .0003. The seed is 164117 + 43 times the zero-based row + the position in ascending d. In a second sweep use d = k × 2⁻²⁶ for k from −32 through 32 and base seed 165311.
|
||||
|
||||
| Output size | Sample pixel | Signed stamp size | Direction |
|
||||
|---|---|---|---|
|
||||
| 16×16 | (8,8) | (.5,.5) | (.6,.8) |
|
||||
| 32×16 | (17,6) | (.75,.3125) | (−.8,.6) |
|
||||
| 16×32 | (5,19) | (−.375,.625) | (.6,−.8) |
|
||||
| 32×32 | (22,17) | (.625,−.4375) | (−.6,−.8) |
|
||||
|
||||
| Gaussian outputs | Renders | Exact pixels before | Exact pixels after | Maximum error after |
|
||||
|---|---:|---:|---:|---:|
|
||||
| Three render regions, four formats | 135 | 537,415/663,552 | 537,476/663,552 | U8 0, U16 1, F16 3.05175781e−5, F32 8.94069672e−7 |
|
||||
| First F32 sweep | 60 | 30,046/34,560 | 30,073/34,560 | 1.25169754e−6 |
|
||||
| Second F32 sweep | 260 | 130,128/149,760 | 130,223/149,760 | 5.66244125e−7 |
|
||||
|
||||
Every reference Gaussian pixel outside its paired disc was zero in both sweeps, 29,406/29,406 and 127,365/127,365. The probes leave equality at exactly r² = 1 unresolved. The implementation applies the cutoff only above one. Differences in the interior remain. On the earlier whole-root matrices, Alveolus still matches 332,280/334,336 pixels and the pattern variant 201,876/203,264. Their maximum U8/U16/F16/F32 errors are 0/1,000/0/3.05175781e−5 and 0/2/0/1.52587891e−5 respectively. The two brick-generator Tile helpers each retain 114,688/114,688 LUM16 pixels across four renders. The boundary regression failed before the fix. All 262 release node tests, formatting, strict workspace Clippy, layers and WebAssembly passed.
|
||||
|
||||
## 2026-11-19 root comparisons
|
||||
|
||||
### Texture sampling in pattern functions
|
||||
|
||||
@@ -92,7 +92,7 @@ Reduced Sharpen now matches 16,704/16,704 pixels on the held-out signed field an
|
||||
| [3d_viewer.sbs/ibl_specular_contrib_anisotropic/panoramic_lod](../assets/sbs/3d_viewer.sbs) | 1 | Yes | [Parity · 20 cases, 219,392 exact pixels](parity-fixes.md#large-transform-offsets-and-additive-blends) |
|
||||
| [3d_volume_mask.sbs/3d_volume_mask](../assets/sbs/3d_volume_mask.sbs) | 1 | No | [Parity · 116 renders, all 1,029,632 pixels exact](parity-fixes.md#pixel-quotients-and-volume-mask-interpolation) |
|
||||
| [3d_worley_noise.sbs/3D_worley_noise](../assets/sbs/3d_worley_noise.sbs) | 1 | No | [Parity · 34 renders, 312,832 exact pixels](parity-fixes.md#per-pixel-random-initialization) |
|
||||
| [alveolus.sbs/alveolus](../assets/sbs/alveolus.sbs) | 0 | Yes | [In progress · 332,280/334,336 pixels across 41 renders](parity-fixes.md#square-and-rectangular-pattern-generators) · [Single-stamp render-region comparisons](parity-fixes.md#pattern-coordinates-under-a-change-of-render-region) |
|
||||
| [alveolus.sbs/alveolus](../assets/sbs/alveolus.sbs) | 0 | Yes | [In progress · 332,280/334,336 pixels across 41 renders](parity-fixes.md#square-and-rectangular-pattern-generators) · [Single-stamp render-region comparisons](parity-fixes.md#pattern-coordinates-under-a-change-of-render-region) · [Gaussian disc-boundary sweeps](parity-fixes.md#gaussian-coverage-at-the-disc-boundary) |
|
||||
| [angle_to_vector.sbs/angle_to_vector](../assets/sbs/angle_to_vector.sbs) | 1 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) |
|
||||
| [anisotropic_blur.sbs/anisotropic_blur](../assets/sbs/anisotropic_blur.sbs) | 1 | No | [Parity · 29 renders, 200,192 exact pixels across four formats](parity-fixes.md#integer-and-oblique-directional-blur) |
|
||||
| [anisotropic_blur.sbs/anisotropic_blur_grayscale](../assets/sbs/anisotropic_blur.sbs) | 1 | No | [Parity · 29 renders, 200,192 exact pixels across four formats](parity-fixes.md#integer-and-oblique-directional-blur) |
|
||||
@@ -426,7 +426,7 @@ Reduced Sharpen now matches 16,704/16,704 pixels on the held-out signed field an
|
||||
| [paths_tools.sbs/paths_trace](../assets/sbs/paths_tools.sbs) | 2 | No | [In progress · 58,213/58,624 pixels in 19 renders](parity-fixes.md#paths-caustics-and-cell-fields-after-pattern-sampling) |
|
||||
| [paths_tools.sbs/vertex_processor](../assets/sbs/paths_tools.sbs) | 9 | No | [Parity · 18 renders, all 57,600 pixels exact](parity-fixes.md#marked-variable-reads-in-path-and-mipmap-graphs) |
|
||||
| [paths_tools.sbs/vertex_processor_simple](../assets/sbs/paths_tools.sbs) | 5 | No | [Parity · 18 renders, all 57,600 pixels exact](parity-fixes.md#marked-variable-reads-in-path-and-mipmap-graphs) |
|
||||
| [pattern_alveolus.sbs/alveolus](../assets/sbs/pattern_alveolus.sbs) | 0 | No | [In progress · 201,876/203,264 pixels across 33 renders](parity-fixes.md#square-and-rectangular-pattern-generators) · [Single-stamp render-region comparisons](parity-fixes.md#pattern-coordinates-under-a-change-of-render-region) |
|
||||
| [pattern_alveolus.sbs/alveolus](../assets/sbs/pattern_alveolus.sbs) | 0 | No | [In progress · 201,876/203,264 pixels across 33 renders](parity-fixes.md#square-and-rectangular-pattern-generators) · [Single-stamp render-region comparisons](parity-fixes.md#pattern-coordinates-under-a-change-of-render-region) · [Gaussian disc-boundary sweeps](parity-fixes.md#gaussian-coverage-at-the-disc-boundary) |
|
||||
| [pattern_arc_pavement.sbs/arc_pavement](../assets/sbs/pattern_arc_pavement.sbs) | 1 | No | [In progress · 206,911/211,200 pixels across 27 renders](parity-fixes.md#pattern-rotation-phase) |
|
||||
| [pattern_brick_1.sbs/brick_1](../assets/sbs/pattern_brick_1.sbs) | 0 | No | [In progress · 139,565/142,592 exact pixels in 19 whole renders](parity-fixes.md#paper-brick-fiber-mesh-polygon-and-shape-roots) |
|
||||
| [pattern_brick_2.sbs/brick_2](../assets/sbs/pattern_brick_2.sbs) | 0 | No | [In progress · 139,074/142,592 exact pixels in 19 whole renders](parity-fixes.md#paper-brick-fiber-mesh-polygon-and-shape-roots) |
|
||||
|
||||
Reference in new issue
Block a user