Skip to content

Commit 5e243d9

Browse files
committed
correct pdf method for mat system, added shouldDoMIS for ray payload
1 parent 120e179 commit 5e243d9

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

include/nbl/builtin/hlsl/path_tracing/concepts.hlsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ NBL_CONCEPT_END(
5858
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.init(v/*origin*/, v/*direction*/)), ::nbl::hlsl::is_same_v, void))
5959
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.template initInteraction<impl::DummyInteraction>(interaction)), ::nbl::hlsl::is_same_v, void))
6060
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.initPayload()), ::nbl::hlsl::is_same_v, void))
61+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.shouldDoMIS()), ::nbl::hlsl::is_same_v, bool))
6162
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.foundEmissiveMIS(scalar)), ::nbl::hlsl::is_same_v, typename T::spectral_type))
6263
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.addPayloadContribution(color)), ::nbl::hlsl::is_same_v, void))
6364
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.getPayloadAccumulatiion()), ::nbl::hlsl::is_same_v, typename T::spectral_type))

include/nbl/builtin/hlsl/path_tracing/unidirectional.hlsl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)