From b20a7e01d046b95a79663da1a8072358709a5a8b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 7 Jun 2013 16:06:22 +0000 Subject: Cycles: experimental correlated multi-jittered sampling pattern that can be used instead of sobol. So far one doesn't seem to be consistently better or worse than the other for the same number of samples but more testing is needed. The random number generator itself is slower than sobol for most number of samples, except 16, 64, 256, .. because they can be computed faster. This can probably be optimized, but we can do that when/if this actually turns out to be useful. Paper this implementation is based on: http://graphics.pixar.com/library/MultiJitteredSampling/ Also includes some refactoring of RNG code, fixing a Sobol correlation issue with the first BSDF and < 16 samples, skipping some unneeded RNG calls and using a simpler unit square to unit disk function. --- intern/cycles/kernel/kernel_montecarlo.h | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'intern/cycles/kernel/kernel_montecarlo.h') diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index 2ae95084162..f608429da36 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -36,36 +36,12 @@ CCL_NAMESPACE_BEGIN /// Given values x and y on [0,1], convert them in place to values on -/// [-1,1] uniformly distributed over a unit sphere. This code is -/// derived from Peter Shirley, "Realistic Ray Tracing", p. 103. +/// [-1,1] uniformly distributed over a unit sphere. __device void to_unit_disk(float *x, float *y) { - float r, phi; - float a = 2.0f * (*x) - 1.0f; - float b = 2.0f * (*y) - 1.0f; - if(a > -b) { - if(a > b) { - r = a; - phi = M_PI_4_F *(b/a); - } - else { - r = b; - phi = M_PI_4_F *(2.0f - a/b); - } - } - else { - if(a < b) { - r = -a; - phi = M_PI_4_F *(4.0f + b/a); - } - else { - r = -b; - if(b != 0.0f) - phi = M_PI_4_F *(6.0f - a/b); - else - phi = 0.0f; - } - } + float phi = 2.0f * M_PI_F * (*x); + float r = sqrtf(*y); + *x = r * cosf(phi); *y = r * sinf(phi); } -- cgit v1.2.3