From 8d16719cd24b6e71d573d4b880bf1a989abca3f0 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sat, 22 Feb 2020 11:59:08 +0900 Subject: [PATCH] Use a different function for giving pixels unique ids. --- src/renderer.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/renderer.rs b/src/renderer.rs index 9179a81..bbe6a40 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -699,12 +699,10 @@ fn get_sample(dimension: u32, i: u32, scramble: u32) -> f32 { /// This is a pure, deterministic function. #[inline(always)] fn pixel_id(x: u32, y: u32) -> u32 { - // Pretend the image is 65536 x 65536 resolution, - // and do a mapping to a 1d array. This should produce - // unique numbers for any reasonably sized image, and - // even for stupid big images will produce sufficiently - // unique numbers for our purposes. - y * (1 << 16) + x + // Map from 2d coordinates to a hilbert curve index. + // This gives unique numbers for all pixels within a + // 2^16 by 2^16 image, and wraps beyond that. + hilbert::xy2d(x & 0xffff, y & 0xffff) } #[derive(Debug)]