@@ -68,12 +68,11 @@ struct Unidirectional
6868 measure_type emissive = materialSystem.getEmission (matID, interaction);
6969
7070 const typename nee_type::light_id_type lightID = matLightID.getLightID ();
71- if (matLightID.isLight ())
71+ if (ray. shouldDoMIS () && matLightID.isLight ())
7272 {
7373 const scalar_type pdf = nee.deferred_pdf (scene, lightID, ray);
7474 assert (!hlsl::isinf (pdf));
75- const scalar_type pdfSq = hlsl::mix (pdf, pdf * pdf, pdf < numeric_limits<scalar_type>::max );
76- emissive *= ray.foundEmissiveMIS (pdfSq);
75+ emissive *= ray.foundEmissiveMIS (pdf * pdf);
7776 }
7877 ray.addPayloadContribution (emissive);
7978 }
@@ -120,9 +119,9 @@ struct Unidirectional
120119
121120 if (neeContrib.pdf > scalar_type (0.0 ))
122121 {
123- quotient_pdf_type bsdf_quotient_pdf = materialSystem.quotient_and_pdf (matID, nee_sample, interaction, _cache);
122+ const scalar_type bsdf_pdf = materialSystem.pdf (matID, nee_sample, interaction, _cache);
124123 neeContrib.quotient *= materialSystem.eval (matID, nee_sample, interaction, _cache) * rcpChoiceProb;
125- const scalar_type otherGenOverLightAndChoice = bsdf_quotient_pdf.pdf * rcpChoiceProb / neeContrib.pdf;
124+ const scalar_type otherGenOverLightAndChoice = bsdf_pdf * rcpChoiceProb / neeContrib.pdf;
126125 neeContrib.quotient /= 1.f + otherGenOverLightAndChoice * otherGenOverLightAndChoice; // balance heuristic
127126
128127 const vector3_type origin = intersectP;
0 commit comments