Use a different function for giving pixels unique ids.

This commit is contained in:
Nathan Vegdahl 2020-02-22 11:59:08 +09:00
parent 4a6284be40
commit 8d16719cd2

View File

@ -699,12 +699,10 @@ fn get_sample(dimension: u32, i: u32, scramble: u32) -> f32 {
/// This is a pure, deterministic function. /// This is a pure, deterministic function.
#[inline(always)] #[inline(always)]
fn pixel_id(x: u32, y: u32) -> u32 { fn pixel_id(x: u32, y: u32) -> u32 {
// Pretend the image is 65536 x 65536 resolution, // Map from 2d coordinates to a hilbert curve index.
// and do a mapping to a 1d array. This should produce // This gives unique numbers for all pixels within a
// unique numbers for any reasonably sized image, and // 2^16 by 2^16 image, and wraps beyond that.
// even for stupid big images will produce sufficiently hilbert::xy2d(x & 0xffff, y & 0xffff)
// unique numbers for our purposes.
y * (1 << 16) + x
} }
#[derive(Debug)] #[derive(Debug)]