[Bf-blender-cvs] [d7f8670] soc-2016-cycles_denoising: Cycles: Fix a rare divide-by-zero in a fallback sampling code
Lukas Stockner
noreply at git.blender.org
Sat Aug 6 05:40:57 CEST 2016
Commit: d7f8670f0ec7bdd0bcf62ca9cb8e2856f540fa93
Author: Lukas Stockner
Date: Wed Jul 27 20:18:10 2016 +0200
Branches: soc-2016-cycles_denoising
https://developer.blender.org/rBd7f8670f0ec7bdd0bcf62ca9cb8e2856f540fa93
Cycles: Fix a rare divide-by-zero in a fallback sampling code
The issue only appeared when the random number happens to be exactly one
while a fallback sampling code for shallow paths was being executed.
===================================================================
M intern/cycles/kernel/closure/bsdf_microfacet_multi.h
===================================================================
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h b/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
index acb50ce..268b636 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
@@ -42,8 +42,8 @@ ccl_device_inline float D_ggx_aniso(const float3 wm, const float2 alpha)
/* Sample slope distribution (based on page 14 of the supplemental implementation). */
ccl_device_inline float2 mf_sampleP22_11(const float cosI, const float2 randU)
{
- if(cosI > 0.9999f || cosI < 1e-6f) {
- const float r = sqrtf(randU.x / (1.0f - randU.x));
+ if(cosI > 0.9999f || fabsf(cosI) < 1e-6f) {
+ const float r = sqrtf(randU.x / max(1.0f - randU.x, 1e-7f));
const float phi = M_2PI_F * randU.y;
return make_float2(r*cosf(phi), r*sinf(phi));
}
More information about the Bf-blender-cvs
mailing list