Fix #125750: NaN on Glossy materials with low roughness
Fix a NaN when rendering glossy materials that can appear due to a division by zero in bsdf_D when rendering materials with low roughness. Thank you to Weizhen for the fix after my incorrect first attempt. Pull Request: https://projects.blender.org/blender/blender/pulls/125756
This commit is contained in:
@@ -508,7 +508,7 @@ ccl_device_inline float bsdf_G(float alpha2, float cos_NI, float cos_NO)
|
||||
/* Normal distribution function. */
|
||||
template<MicrofacetType m_type> ccl_device_inline float bsdf_D(float alpha2, float cos_NH)
|
||||
{
|
||||
const float cos_NH2 = sqr(cos_NH);
|
||||
const float cos_NH2 = min(sqr(cos_NH), 1.0f);
|
||||
|
||||
if (m_type == MicrofacetType::BECKMANN) {
|
||||
return expf((1.0f - 1.0f / cos_NH2) / alpha2) / (M_PI_F * alpha2 * sqr(cos_NH2));
|
||||
|
||||
Reference in New Issue
Block a user