Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-06-07 20:06:22 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-06-07 20:06:22 +0400
commitb20a7e01d046b95a79663da1a8072358709a5a8b (patch)
tree7772c50756a7d5a3352fd25eadbe8d41aa776615 /intern/cycles/kernel/kernel_montecarlo.h
parentd835d2f4e65ae3bf8e22f8d3d60e7e6ea7a6b4ca (diff)
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.
Diffstat (limited to 'intern/cycles/kernel/kernel_montecarlo.h')
-rw-r--r--intern/cycles/kernel/kernel_montecarlo.h32
1 files changed, 4 insertions, 28 deletions
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);
}