From e6645bf06b70835b86302dde6a80978e4e8b7360 Mon Sep 17 00:00:00 2001 From: Weizhen Huang Date: Tue, 21 Jan 2025 11:48:45 +0100 Subject: [PATCH] Fix #131240: Cycles: Negative integration range in Huang Hair It is possible that the valid range computed from `theta` and the range visible to the current pixel do not overlap. In this case the hair section has no contribution. Pull Request: https://projects.blender.org/blender/blender/pulls/133337 --- intern/cycles/kernel/closure/bsdf_principled_hair_huang.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/intern/cycles/kernel/closure/bsdf_principled_hair_huang.h b/intern/cycles/kernel/closure/bsdf_principled_hair_huang.h index 1b0bb0a4aa5..1608994edba 100644 --- a/intern/cycles/kernel/closure/bsdf_principled_hair_huang.h +++ b/intern/cycles/kernel/closure/bsdf_principled_hair_huang.h @@ -875,6 +875,12 @@ ccl_device Spectrum bsdf_hair_huang_eval(KernelGlobals kg, bsdf->extra->gamma_m_min = gamma_m_min; bsdf->extra->gamma_m_max = gamma_m_max; + if (!(bsdf->extra->gamma_m_min < bsdf->extra->gamma_m_max)) { + /* No overlap between the valid range and the visible range. Can happen at grazing `theta` + * angles. */ + return zero_spectrum(); + } + const float projected_area = cos_theta(local_I) * dh; return (bsdf_hair_huang_eval_r(kg, sc, local_I, local_O) +