Skip to content

Commit c2c8624

Browse files
added comments on why we dont check the relation between V and L or N and H in ...cos_remainder_and_pdf functions for delta distribution BSDFs
1 parent 64ac715 commit c2c8624

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

examples_tests/42.FragmentShaderPathTracer/litBySphere.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void closestHitProgram(in ImmutableRay_t _immutable, inout irr_glsl_xoroshiro64s
195195
// OETF smallest perceptible value
196196
const float bsdfPdfThreshold = getLuma(irr_glsl_eotf_sRGB(vec3(1.0)/255.0));
197197
const float lumaThroughputThreshold = bsdfPdfThreshold;
198-
if (bsdfPdf>bsdfPdfThreshold && getLuma(throughput)>lumaThroughputThreshold)
198+
if (bsdfPdf>bsdfPdfThreshold && (!doNEE || bsdfPdf<FLT_MAX) && getLuma(throughput)>lumaThroughputThreshold)
199199
{
200200
rayStack[stackPtr]._payload.throughput = throughput*rcpChoiceProb;
201201

include/irr/builtin/glsl/bxdf/bsdf/specular/dielectric.glsl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ vec3 irr_glsl_thin_smooth_dielectric_cos_remainder_and_pdf_wo_clamps(out float p
5858
return irr_glsl_thin_smooth_dielectric_cos_remainder_and_pdf_wo_clamps(pdf, sampleValue / sampleProb);
5959
}
6060

61+
// for information why we don't check the relation between `V` and `L` or `N` and `H`, see comments for `irr_glsl_transmission_cos_remainder_and_pdf` in `irr/builtin/glsl/bxdf/common_samples.glsl`
6162
vec3 irr_glsl_thin_smooth_dielectric_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSample _sample, in irr_glsl_IsotropicViewSurfaceInteraction interaction, in vec3 eta2, in vec3 luminosityContributionHint)
6263
{
6364
const bool transmitted = irr_glsl_isTransmissionPath(interaction.NdotV,_sample.NdotL);
@@ -104,6 +105,7 @@ float irr_glsl_smooth_dielectric_cos_remainder_and_pdf(out float pdf, in bool tr
104105
return transmitted ? rcpOrientedEta2:1.0;
105106
}
106107

108+
// for information why we don't check the relation between `V` and `L` or `N` and `H`, see comments for `irr_glsl_transmission_cos_remainder_and_pdf` in `irr/builtin/glsl/bxdf/common_samples.glsl`
107109
float irr_glsl_smooth_dielectric_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSample _sample, in irr_glsl_IsotropicViewSurfaceInteraction interaction, in float eta)
108110
{
109111
const bool transmitted = irr_glsl_isTransmissionPath(interaction.NdotV,_sample.NdotL);

include/irr/builtin/glsl/bxdf/common_samples.glsl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ irr_glsl_LightSample irr_glsl_transmission_cos_generate(in irr_glsl_AnisotropicV
99
return irr_glsl_createLightSample(-interaction.isotropic.V.dir,-1.0,interaction.T,interaction.B,interaction.isotropic.N);
1010
}
1111

12-
float irr_glsl_transmission_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSample s)
12+
/** Why don't we check that the incoming and outgoing directions equal each other (or similar for other delta distributions such as reflect, or smooth [thin] dielectrics:
13+
- The `remainder_and_pdf` functions are meant to be used with MIS
14+
- Our own generator can never pick an improbable path, so no checking necessary
15+
- For other generators the estimator will be `f_BSDF*f_Light*f_Visibility*clampedCos(theta)/(1+(p_BSDF^alpha+p_otherNonChosenGenerator^alpha+...)/p_ChosenGenerator^alpha)`
16+
when `p_BSDF` equals `FLT_INF` it will drive the overall MIS estimator for the other generators to 0 so no checking necessary
17+
**/
18+
float irr_glsl_transmission_cos_remainder_and_pdf(out float pdf)
1319
{
1420
pdf = 1.0/0.0;
1521
return 1.0;
@@ -21,7 +27,8 @@ irr_glsl_LightSample irr_glsl_reflection_cos_generate(in irr_glsl_AnisotropicVie
2127
return irr_glsl_createLightSample(L,interaction);
2228
}
2329

24-
float irr_glsl_reflection_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSample s)
30+
// for information why we don't check the relation between `V` and `L` or `N` and `H`, see comments for `irr_glsl_transmission_cos_remainder_and_pdf`
31+
float irr_glsl_reflection_cos_remainder_and_pdf(out float pdf)
2532
{
2633
pdf = 1.0/0.0;
2734
return 1.0;

0 commit comments

Comments
 (0)