From 3916043f33ff6e9880e320276f292baf412c25f6 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Thu, 19 Mar 2020 19:49:45 +0900 Subject: [PATCH] Removed golden ratio sampling. Turns out it causes interference with the Sobol sampler. Also tweaked some other things about sampling after removing golden ratio sampling, to make things better. --- src/renderer.rs | 18 ++++-------------- sub_crates/sobol/build.rs | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/renderer.rs b/src/renderer.rs index b719846..3034df4 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -697,24 +697,14 @@ fn get_sample(dimension: u32, i: u32, pixel_co: (u32, u32), seed: u32) -> f32 { let scramble = hash_u32(pixel_co.0 ^ (pixel_co.1 << 16), seed); match dimension { - 0 => { - // Golden ratio sampling. - // NOTE: use this for the wavelength dimension, because - // due to the nature of hero wavelength sampling this ends up - // being crazily more efficient than pretty much any other sampler, - // and reduces variance by a huge amount. - let n = i.wrapping_add(scramble).wrapping_mul(2654435769); - n as f32 * (1.0 / (1u64 << 32) as f32) - } - n if (n - 1) < sobol::MAX_DIMENSION as u32 => { - let dim = n - 1; + d if d < sobol::MAX_DIMENSION as u32 => { // Sobol sampling. - sobol::sample_owen_cranley(dim, i, hash_u32(dim, scramble)) + sobol::sample_owen(d, i, hash_u32(d, scramble)) } - _ => { + d => { // Random sampling. use crate::hash::hash_u32_to_f32; - hash_u32_to_f32(dimension ^ (i << 16), scramble) + hash_u32_to_f32(d ^ (i << 16), scramble) } } } diff --git a/sub_crates/sobol/build.rs b/sub_crates/sobol/build.rs index 333e1fb..b7af9c7 100644 --- a/sub_crates/sobol/build.rs +++ b/sub_crates/sobol/build.rs @@ -7,7 +7,7 @@ use std::{env, fs::File, io::Write, path::Path}; const NUM_DIMENSIONS: usize = 1024; /// What file to generate the numbers from. -const DIRECTION_NUMBERS_TEXT: &str = include_str!("direction_numbers/joe-kuo-cessen-3.1024.txt"); +const DIRECTION_NUMBERS_TEXT: &str = include_str!("direction_numbers/joe-kuo-other-2.1024.txt"); fn main() { let out_dir = env::var("OUT_DIR").unwrap();