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.
This commit is contained in:
parent
e014df2b1a
commit
3916043f33
|
@ -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);
|
let scramble = hash_u32(pixel_co.0 ^ (pixel_co.1 << 16), seed);
|
||||||
|
|
||||||
match dimension {
|
match dimension {
|
||||||
0 => {
|
d if d < sobol::MAX_DIMENSION as u32 => {
|
||||||
// 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;
|
|
||||||
// Sobol sampling.
|
// Sobol sampling.
|
||||||
sobol::sample_owen_cranley(dim, i, hash_u32(dim, scramble))
|
sobol::sample_owen(d, i, hash_u32(d, scramble))
|
||||||
}
|
}
|
||||||
_ => {
|
d => {
|
||||||
// Random sampling.
|
// Random sampling.
|
||||||
use crate::hash::hash_u32_to_f32;
|
use crate::hash::hash_u32_to_f32;
|
||||||
hash_u32_to_f32(dimension ^ (i << 16), scramble)
|
hash_u32_to_f32(d ^ (i << 16), scramble)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::{env, fs::File, io::Write, path::Path};
|
||||||
const NUM_DIMENSIONS: usize = 1024;
|
const NUM_DIMENSIONS: usize = 1024;
|
||||||
|
|
||||||
/// What file to generate the numbers from.
|
/// 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() {
|
fn main() {
|
||||||
let out_dir = env::var("OUT_DIR").unwrap();
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user