Closed shadeops closed 3 years ago
Changing
if (w.depth < maxDepth && mp.Le)
L += T_hat * mp.Le * mp.sigma_a /
(sigma_maj[0] * uniPathPDF.Average());
to
// also check uniPathPDF
if (w.depth < maxDepth && mp.Le && uniPathPDF)
L += T_hat * mp.Le * mp.sigma_a /
(sigma_maj[0] * uniPathPDF.Average());
This seems like a blunt fix, but not sure if this is appropriate.
Thanks for chasing this down! (To my shame, I had occasionally seen similar NaNs but never chased down the root cause.) I've pushed a fix that takes care of this as well as some similar sketchy cases.
Summary
Howdy
I've noticed some NaNs being produced in the WavefrontPathIntegrator::SampleMediumInteraction. It is fairly reproducible (with enough samples) in the scene described below.
Amateur Analysis
Tracking a sample that led to a NaN it seemed to originate from -
https://github.com/mmp/pbrt-v4/blob/130757d3c89b0b953902c5c9fd3db30091d9184f/src/pbrt/wavefront/media.cpp#L95-L97
uniPathPDF.Average()
is 0.0 due to sigma_n being 0 in a null scattering event from https://github.com/mmp/pbrt-v4/blob/130757d3c89b0b953902c5c9fd3db30091d9184f/src/pbrt/wavefront/media.cpp#L137-L143The events leading up to this were -
Medium event T_maj 0.694691 0.694691 0.694691 0.694691 sigma_a 0.250000 0.250000 0.250000 0.250000 sigma_s 10.000000 10.000000 10.000000 10.000000
Medium scattering probabilities: 0.024390 0.975610 0.000000 (not quite 0.0)
With a uMode very very close to 1.0
Example Scene