diff options
author | Stan Seibert <stan@mtrr.org> | 2012-05-23 13:09:50 -0400 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2021-05-09 08:42:39 -0700 |
commit | b62149c08f835068215b48110df876ae8d481969 (patch) | |
tree | a8983cbf46ecd5aaeb263f942447283830a86118 | |
parent | 6fdd210e4850acb503de0e7dfc14127e07eac27b (diff) | |
download | chroma-b62149c08f835068215b48110df876ae8d481969.tar.gz chroma-b62149c08f835068215b48110df876ae8d481969.tar.bz2 chroma-b62149c08f835068215b48110df876ae8d481969.zip |
Diffuse reflection is lambertian, not isotropic.
-rw-r--r-- | chroma/cuda/photon.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/chroma/cuda/photon.h b/chroma/cuda/photon.h index 310f09d..00aee95 100644 --- a/chroma/cuda/photon.h +++ b/chroma/cuda/photon.h @@ -356,10 +356,15 @@ propagate_at_specular_reflector(Photon &p, State &s) __device__ int propagate_at_diffuse_reflector(Photon &p, State &s, curandState &rng) { - p.direction = uniform_sphere(&rng); - - if (dot(p.direction, s.surface_normal) < 0.0f) - p.direction = -p.direction; + float ndotv; + do { + p.direction = uniform_sphere(&rng); + ndotv = dot(p.direction, s.surface_normal); + if (ndotv < 0.0f) { + p.direction = -p.direction; + ndotv = -ndotv; + } + } while (! (curand_uniform(&rng) < ndotv) ); p.polarization = cross(uniform_sphere(&rng), p.direction); p.polarization /= norm(p.polarization); |