Round the near stamp displacement at pixel centers

This commit is contained in:
chasse20 committed 2026-11-20 18:58:28 -05:00
1 parent e5852bbe18
commit 4d18bfbe38
4 files changed
+57 -5

No files matched your search

+5 -1
View File
@@ -43,7 +43,11 @@ impl PixelPlanes {
let triangle = Triangle::new(projected);
// Move each stored vertex by its snapping displacement in pattern space.
let displacements: [[f32; 2]; 2] = std::array::from_fn(|axis| {
let low_delta = (triangle.near[axis] - f64::from(projected[axis][0])) as f32 * pixel_size[axis];
// The interval from the projected half-pixel to the first sample rounds
// before its one-pixel offset is removed, including at a clipped edge.
let first_sample = triangle.near[axis] + 0.5;
let interval = (first_sample - f64::from(projected[axis][0] - 0.5)) as f32;
let low_delta = (interval - 1.0) * pixel_size[axis];
let high_delta = (triangle.far[axis] - f64::from(projected[axis][1])) as f32 * pixel_size[axis];
[low_delta - frame.radius[axis], high_delta + 3.0 * frame.radius[axis]]
});
+22
View File
@@ -383,6 +383,28 @@ fn stamp_gradients_keep_the_phase_of_extended_turns() {
}
}
#[test]
fn rotated_stamps_use_the_pixel_center_when_snapping_the_near_vertex() {
let variables = BTreeMap::from([("$tiling".into(), Value::Int(0))]);
for (dimensions, center, size, turns, shape, pixel, expected) in [
([64, 32], [0.5009855, 0.012967646], [0.024458896, 0.015625], 136.94586, 10, [31, 0], 0x3dff_4c1c),
([32, 32], [0.06045103, 0.2529377], [0.055972442, 0.03125], 152.8708, 4, [1, 8], 0x3f0e_3e7c),
([64, 64], [-0.0138504505, 0.07075971], [0.0723335, 0.0625], 189.57106, 4, [0, 5], 0x3eeb_a3c2),
([256, 256], [-0.010898113, 0.7042948], [0.02902194, 0.03125], 325.4251, 10, [0, 179], 0x3d67_8fd8),
] {
let mut graph = PatternGraph::with_root(PatternNodeKind::Quadrant);
graph.nodes[0].parameters = BTreeMap::from([
("patterntype".into(), Value::Int(shape)),
("branchoffset".into(), Value::Float2([-0.5; 2])),
("frameoffset".into(), Value::Float2(center)),
("patternsize".into(), Value::Float2(size)),
("patternrotation".into(), Value::Float(turns)),
]);
let image = cook_at_dimensions(graph, &variables, 389119, dimensions[0], dimensions[1]).unwrap().remove(0);
assert_eq!(image.get_gray(pixel[0], pixel[1], false).to_bits(), expected, "{center:?} at {dimensions:?}");
}
}
#[test]
fn quarter_turn_square_snaps_its_bounds_before_the_residual_phase_affects_sampling() {
let variables = BTreeMap::from([("$tiling".into(), Value::Int(0))]);
+26
View File
@@ -534,6 +534,32 @@ For each root’s 25 follow-up renders, the 5,120 U8, 553,728 U16, 78,336 F16 an
In a single-worker release run, four interleaved measurements of the 128² default, 256² default and 512² filled cases gave median whole-graph cook times of 46, 259 and 1,138 ms for Alveolus (previously 45, 247 and 1,068 ms). Pattern Alveolus took 45, 253 and 1,083 ms (previously 43, 238 and 1,045 ms).
### Pixel-center rounding at the near stamp vertex
BNW Spots 1 now matches 3,177,940/3,177,984 final pixels across 125 distinct settings. The earlier result was 3,177,789. Its remaining differences include deeper stages whose results change across repeated reference renders. BNW Spots 3 retains 3,159,552/3,159,552 exact final pixels across 118 settings. The same 40-setting save and reopen comparison again matched all 2,399,232 pixels in both applications. [Dimensions, settings and repeated renders](#draw-order-at-six-quadrant-subdivisions)
| Root on the original file | U8 exact · max | U16 exact · max | F16 exact · max | F32 exact · max |
|---|---:|---:|---:|---:|
| BNW Spots 1, 125 settings | 649,984/649,984 · 0 | 949,470/949,504 · 2 | 649,983/649,984 · .000244140625 | 928,503/928,512 · 2.15768814e−5 |
| BNW Spots 3, 118 settings | 647,936/647,936 · 0 | 943,360/943,360 · 0 | 647,936/647,936 · 0 | 920,320/920,320 · 0 |
| Clouds 1, 32 settings | 154,112/154,112 · 0 | 199,670/199,680 · 4 | 154,112/154,112 · 0 | 199,668/199,680 · .000110566616 |
| Clouds 2, 32 settings | 154,112/154,112 · 0 | 199,672/199,680 · 2 | 154,111/154,112 · .000244140625 | 199,677/199,680 · 2.28881836e−5 |
A cropped quadrant with one stamp isolates the change. Use black F32 grayscale, additive blending, unit gain and tint, zero roughness, no tiling, branch offset (−.5,−.5) and seed 389119. Apply the center as the frame offset. The table gives the reference F32 bits at zero-based pixel coordinates. MaterialCraft previously returned 0x3dff4c20 for the first sample.
| Dimensions | Profile | Center | Size | Rotation in turns | Pixel | F32 bits |
|---|---|---|---|---:|---|---|
| 64×32 | Linear ramp | (.5009855,.012967646) | (.024458896,.015625) | 136.94586 | (31,0) | 0x3dff4c1c |
| 32² | Paraboloid | (.06045103,.2529377) | (.055972442,.03125) | 152.8708 | (1,8) | 0x3f0e3e7c |
| 64² | Paraboloid | (−.0138504505,.07075971) | (.0723335,.0625) | 189.57106 | (0,5) | 0x3eeba3c2 |
| 256² | Linear ramp | (−.010898113,.7042948) | (.02902194,.03125) | 325.4251 | (0,179) | 0x3d678fd8 |
Each axis rounds the projected near edge minus half a pixel to F32, then rounds the interval to the snapped first sample center to F32. Subtracting one pixel gives the displacement of the near vertex. This reproduces the ramp, pyramid and paraboloid measurements on both sides of a clipped edge. The 297 translation and scale controls moved eleven measured stamps by (0,0), (1,0), (0,1), (5,−3) and (−4,4) pixels at the original size, by (0,0) and (2,3) at double size, and by (0,0) at four and eight times the size. Together they match 27,426,816/27,426,816 F32 pixels, up from 27,426,354. A further 112 geometries, each rendered with all three profiles, match 6,669,312/6,669,312 pixels, up from 6,669,285. They include 16×32 through 512×128, rotated, axis-aligned and out-of-bounds vertices. The maximum error is zero in both sets.
In BNW Spots 3's 256² U16 stage at a requested 16², disorder .15625 and seed 8866, pixel (118,0) now stores 44,702 in both apps. At (236,1) the reference stores 29,396 and MaterialCraft stores 29,397. Across eight renders the intermediate matches 524,287/524,288 pixels, maximum one U16 level. In Clouds 2 all seven pyramid stamps contributing at (19,0) of the 32×16 stage now match individually across all 3,584 F32 pixels. Larger Clouds renders still vary across reference recooks. [Root settings and variability](#draw-order-at-six-quadrant-subdivisions)
Seventeen of the 152 earlier stamp-control sets gained a combined 2,645 exact pixels. The other 135 retained their exact counts and maxima. All 98,304 pixels in the 36-render cropped-boundary set now match. Across 1,052 isolated BNW Spots 1 draws, 820,301/820,304 F32 pixels match. In the 40-root recheck BNW Spots 1 gained 97 exact pixels in its original 34-render matrix. The other 39 retained their results. Four alternating single-worker release runs had median cook times of 198 ms for BNW Spots 1 and 179 ms for BNW Spots 3, previously 202 ms and 175 ms.
### Draw order at six quadrant subdivisions
BNW Spots 3 matched every final output in 118 distinct combinations of dimensions, seed, disorder and format. The preceding 27-render comparison gained 213 exact pixels. BNW Spots 1 gained 71 exact pixels in its 34-render comparison and still has differences at higher resolutions.
+4 -4
View File
@@ -87,7 +87,7 @@ Cells 1 reached measured parity across 89 distinct settings, including 512² and
Crystal 2 now matches all 5,104,128 pixels across 99 distinct settings through 512². Six other roots gained matching pixels when subdividing pattern quadrants. [Root counts, reproducible inputs and repeat variability](parity-fixes.md#sibling-positions-in-subdivided-pattern-quadrants)
BNW Spots 3 matches all 3,159,552 final pixels across 118 distinct settings. Both apps reopened its saved graph and reproduced all 2,399,232 pixels in the 40-setting file check. Two U16 differences remain inside one pattern stage. [Draw order, root measurements and remaining differences](parity-fixes.md#draw-order-at-six-quadrant-subdivisions)
BNW Spots 3 matches all 3,159,552 final pixels across 118 distinct settings. Both apps reopened its saved graph and reproduced all 2,399,232 pixels in the 40-setting file check. One U16 difference remains inside its 256² pattern stage. BNW Spots 1 matches 3,177,940/3,177,984 final pixels across 125 settings. [Pixel-center measurements and remaining differences](parity-fixes.md#pixel-center-rounding-at-the-near-stamp-vertex)
## Complete inventory
@@ -150,8 +150,8 @@ BNW Spots 3 matches all 3,159,552 final pixels across 118 distinct settings. Bot
| [blend_switch.sbs/switch_grayscale](../assets/sbs/blend_switch.sbs) | 2 | No | [Parity: 6 cases](parity-fixes.md#verified-cases) |
| [blur_hq.sbs/blur_hq](../assets/sbs/blur_hq.sbs) | 1 | No | [Parity · 18 renders, 171,264 exact pixels across four formats](parity-fixes.md#integer-and-oblique-directional-blur) |
| [blur_hq.sbs/blur_hq_grayscale](../assets/sbs/blur_hq.sbs) | 1 | No | [Parity · 18 renders, 171,264 exact pixels across four formats](parity-fixes.md#integer-and-oblique-directional-blur) |
| [bnw_spots_1.sbs/bnw_spots_1](../assets/sbs/bnw_spots_1.sbs) | 0 | Yes | [In progress · 3,177,789/3,177,984 pixels across 125 settings](parity-fixes.md#draw-order-at-six-quadrant-subdivisions) · [64,000/64,000 downstream pixels](parity-fixes.md#isolating-the-generators-in-spots-bricks-and-cells) · [Circular stamp and opacity controls](parity-fixes.md#circular-stamp-coverage-and-zero-stamp-opacity) |
| [bnw_spots_3.sbs/bnw_spots_3](../assets/sbs/bnw_spots_3.sbs) | 0 | Yes | [Parity · 118 settings, 3,159,552/3,159,552 final pixels](parity-fixes.md#draw-order-at-six-quadrant-subdivisions) · [27,136/27,136 downstream pixels](parity-fixes.md#isolating-the-generators-in-spots-bricks-and-cells) · [Circular stamp and opacity controls](parity-fixes.md#circular-stamp-coverage-and-zero-stamp-opacity) |
| [bnw_spots_1.sbs/bnw_spots_1](../assets/sbs/bnw_spots_1.sbs) | 0 | Yes | [In progress · 3,177,940/3,177,984 pixels across 125 settings](parity-fixes.md#pixel-center-rounding-at-the-near-stamp-vertex) · [64,000/64,000 downstream pixels](parity-fixes.md#isolating-the-generators-in-spots-bricks-and-cells) · [Circular stamp and opacity controls](parity-fixes.md#circular-stamp-coverage-and-zero-stamp-opacity) |
| [bnw_spots_3.sbs/bnw_spots_3](../assets/sbs/bnw_spots_3.sbs) | 0 | Yes | [Parity · 118 settings, 3,159,552/3,159,552 final pixels](parity-fixes.md#pixel-center-rounding-at-the-near-stamp-vertex) · [27,136/27,136 downstream pixels](parity-fixes.md#isolating-the-generators-in-spots-bricks-and-cells) · [Circular stamp and opacity controls](parity-fixes.md#circular-stamp-coverage-and-zero-stamp-opacity) |
| [brick_1.sbs/brick_1](../assets/sbs/brick_1.sbs) | 0 | Yes | [Parity · 131 renders, 3,194,368/3,194,368 pixels](parity-fixes.md#fractional-stamp-vertices-and-the-last-covered-pixel) · [64,000/64,000 downstream pixels](parity-fixes.md#isolating-the-generators-in-spots-bricks-and-cells) · [Earlier generator settings](parity-fixes.md#square-and-rectangular-pattern-generators) |
| [brick_2.sbs/brick_2](../assets/sbs/brick_2.sbs) | 0 | Yes | [Parity · 124 renders, 3,175,936/3,175,936 pixels](parity-fixes.md#fractional-stamp-vertices-and-the-last-covered-pixel) · [27,136/27,136 downstream pixels](parity-fixes.md#isolating-the-generators-in-spots-bricks-and-cells) · [Earlier generator settings](parity-fixes.md#square-and-rectangular-pattern-generators) |
| [brick_3.sbs/brick_3](../assets/sbs/brick_3.sbs) | 0 | Yes | [Parity · 100 renders, 1,295,872/1,295,872 pixels](parity-fixes.md#wrapped-stamp-centers-in-brick-3) · [64,000/64,000 downstream pixels](parity-fixes.md#isolating-the-generators-in-spots-bricks-and-cells) · [Depth opacity measurements](parity-fixes.md#stored-opacity-across-pattern-depths) |
@@ -172,7 +172,7 @@ BNW Spots 3 matches all 3,159,552 final pixels across 118 distinct settings. Bot
| [clone_patch.sbs/transform_to_center](../assets/sbs/clone_patch.sbs) | 1 | Yes | [Parity: 4 cases](parity-fixes.md#verified-cases) |
| [clone_patch.sbs/transform_to_center_grayscale](../assets/sbs/clone_patch.sbs) | 1 | Yes | [Parity: 4 cases](parity-fixes.md#verified-cases) |
| [clouds_1.sbs/clouds_1](../assets/sbs/clouds_1.sbs) | 0 | Yes | [In progress · 707,562/707,584 pixels on 32 new renders, reference repeats vary](parity-fixes.md#draw-order-at-six-quadrant-subdivisions) |
| [clouds_2.sbs/clouds_2](../assets/sbs/clouds_2.sbs) | 0 | Yes | [In progress · 707,570/707,584 pixels on 32 new renders, reference repeats vary](parity-fixes.md#draw-order-at-six-quadrant-subdivisions) |
| [clouds_2.sbs/clouds_2](../assets/sbs/clouds_2.sbs) | 0 | Yes | [In progress · 707,572/707,584 pixels on 32 new renders, reference repeats vary](parity-fixes.md#pixel-center-rounding-at-the-near-stamp-vertex) |
| [color_space_conversion.sbs/acescg_to_linear_srgb](../assets/sbs/color_space_conversion.sbs) | 1 | No | [Parity · eight cases in four formats](parity-fixes.md#color-conversion-checker-and-clone) |
| [color_space_conversion.sbs/acescg_to_srgb](../assets/sbs/color_space_conversion.sbs) | 1 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) |
| [color_space_conversion.sbs/linear_srgb_to_acescg](../assets/sbs/color_space_conversion.sbs) | 1 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) |