From 42a6c1e9cd2d3bf87e5c01e5e9aa3735f5487e30 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sun, 15 Mar 2020 18:10:03 +0900 Subject: [PATCH] Use proper wrapping arithmetic in the golden ratio sampler. --- src/renderer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer.rs b/src/renderer.rs index 58a7adb..17f6a15 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -701,7 +701,7 @@ fn get_sample(dimension: u32, i: u32, pixel_co: (u32, u32), seed: u32) -> f32 { // being crazily more efficient than pretty much any other sampler, // and reduces variance by a huge amount. let scramble = hash_u32(pixel_id, seed); - let n = (i + scramble) * 2654435769; + let n = i.wrapping_add(scramble).wrapping_mul(2654435769); n as f32 * (1.0 / (1u64 << 32) as f32) } n if (n - 1) < sobol::NUM_DIMENSIONS as u32 => {