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:
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);
}