From 080484a5c8d100233d4943478487a93c61880605 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 26 May 2023 12:14:58 +0200 Subject: [PATCH] Fix #108125: Cycles generates NaN in render passes with low roughness Slightly increase threshold to avoid division by zero. --- intern/cycles/kernel/closure/bsdf_microfacet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h index 89fec29d43b..1f6395d66eb 100644 --- a/intern/cycles/kernel/closure/bsdf_microfacet.h +++ b/intern/cycles/kernel/closure/bsdf_microfacet.h @@ -398,7 +398,7 @@ ccl_device Spectrum bsdf_microfacet_eval(ccl_private const ShaderClosure *sc, * - Purely reflective closures can't have refraction. * - Purely refractive closures can't have reflection. */ - if ((cos_NI <= 0) || (alpha_x * alpha_y <= 1e-7f) || ((cos_NgO < 0.0f) != is_refraction) || + if ((cos_NI <= 0) || (alpha_x * alpha_y <= 5e-7f) || ((cos_NgO < 0.0f) != is_refraction) || (is_refraction && !m_refractive) || (!is_refraction && m_refractive && !m_glass)) { *pdf = 0.0f; @@ -482,7 +482,7 @@ ccl_device int bsdf_microfacet_sample(ccl_private const ShaderClosure *sc, const bool m_refractive = CLOSURE_IS_REFRACTIVE(bsdf->type); const float alpha_x = bsdf->alpha_x; const float alpha_y = bsdf->alpha_y; - bool m_singular = (m_type == MicrofacetType::SHARP) || (alpha_x * alpha_y <= 1e-7f); + bool m_singular = (m_type == MicrofacetType::SHARP) || (alpha_x * alpha_y <= 5e-7f); const float3 N = bsdf->N; const float cos_NI = dot(N, wi);