@@ -68,6 +68,7 @@ struct Unidirectional
6868 const typename nee_type::light_id_type lightID = matLightID.getLightID ();
6969 if (ray.shouldDoMIS () && matLightID.isLight ())
7070 {
71+ emissive *= ray.getPayloadThroughput ();
7172 const scalar_type pdf = nee.deferred_pdf (scene, lightID, ray);
7273 assert (!hlsl::isinf (pdf));
7374 emissive *= ray.foundEmissiveMIS (pdf * pdf);
@@ -110,7 +111,7 @@ struct Unidirectional
110111 // TODO: we'll need an `eval_and_mis_weight` and `quotient_and_mis_weight`
111112 const scalar_type bsdf_pdf = materialSystem.pdf (matID, nee_sample, interaction);
112113 neeContrib.quotient *= materialSystem.eval (matID, nee_sample, interaction) * rcpChoiceProb;
113- if (!hlsl:: isinf ( neeContrib.pdf))
114+ if (neeContrib.pdf < bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity ))
114115 {
115116 const scalar_type otherGenOverLightAndChoice = bsdf_pdf * rcpChoiceProb / neeContrib.pdf;
116117 neeContrib.quotient /= 1.f + otherGenOverLightAndChoice * otherGenOverLightAndChoice; // balance heuristic
@@ -172,7 +173,9 @@ struct Unidirectional
172173 measure_type finalContribution = nee.get_environment_radiance (ray);
173174 typename nee_type::light_id_type env_light_id = nee.get_env_light_id ();
174175 const scalar_type pdf = nee.deferred_pdf (scene, env_light_id, ray);
175- finalContribution *= ray.foundEmissiveMIS (pdf * pdf);
176+ finalContribution *= ray.getPayloadThroughput ();
177+ if (pdf > scalar_type (0.0 ))
178+ finalContribution *= ray.foundEmissiveMIS (pdf * pdf);
176179 ray.addPayloadContribution (finalContribution);
177180 }
178181
0 commit comments