Glass photonBSDF gives pdf of 0.5?

39 views
Skip to first unread message

defdac

unread,
Feb 29, 2012, 2:30:22 AM2/29/12
to pbrt
Hi,

The Glass material contains two BxDFs: SpecularRefraction (sets pdf to
1.0) and SpecularTransmission (sets pdf to 1.0). BSDF::Sample_f will
calculate total pdf in this way:

// Compute overall PDF with all matching _BxDF_s
if (!(bxdf->type & BSDF_SPECULAR) && matchingComps > 1)
for (int i = 0; i < nBxDFs; ++i)
if (bxdfs[i] != bxdf && bxdfs[i]->MatchesFlags(flags))
*pdf += bxdfs[i]->Pdf(wo, wi);
if (matchingComps > 1) *pdf /= matchingComps;

This results in a pdf of 0.5 when one of the BxDF is selected/sampled
since matchingComps will be 2. This is correct and relatively
intuitive for BxDFs not containing delta distributions, but is this
really correct for materials like Glass where all the BxDFs contains
delta distributions?

In photonmap.cpp the pdf of 0.5 is used here:

Spectrum fr = photonBSDF->Sample_f(wo, &wi, BSDFSample(rng),
&pdf, BSDF_ALL, &flags);
if (fr.IsBlack() || pdf == 0.f) break;
Spectrum anew = alpha * fr * AbsDot(wi, photonBSDF-
>dgShading.nn) / pdf;

If you let the photonRay bounce around in a Glass tube for a while
(not using any Russian roulette in my case) the photons will take on
really high y() values: Much higher than was emitted from the light
source.

If this is correct without Russian roulette I think I must be pointed
to a page in the book where I can read up on this, or an explanation
here. The main thing I have problem understanding is photon weights
that get much higher weight than was originally emitted from the light
source. Intuitively for me the Fresnel and attenuation should dampen
the photon on it's way through the scene.

(I've also looked at the Whitted integrator, which circumvent this
problem by sampling specular reflection and specular transmission
separately, thus making the matchingComps in BSDF::Sample_f be only
one => pdf of 1.0. )


Thanks for a great forum/group
Daniel.

Iliyan Georgiev

unread,
Feb 29, 2012, 8:15:56 AM2/29/12
to pbrt
You are right, photon's energy can increase/decrease, because you're
not doing perfect importance sampling of the scattering kernel.
Ideally, you should choose whether to reflect of refract based on the
Fresnel weight. PBRT however makes this decision with uniform
probability. Therefore, when the Fresnel weight for reflection is
close to 1 and you choose reflection with probability 0.5, you almost
double the photon energy. The result is variance, due to this
imperfect importance sampling. Ideally, before choosing a BxDF to
sample, PBRT should compute the reflectance of each BxDF (which should
include the Fresnel weight) and then pick the BxDF proportionally to
the reflectance.

Hope this helps!

Cheers,
Iliyan

defdac

unread,
Feb 29, 2012, 2:46:55 PM2/29/12
to pbrt
This helped alot! Thanks!

defdac

unread,
Mar 1, 2012, 2:49:19 AM3/1/12
to pbrt
I think I found an example of the way you suggest to ideally select
which BxDF to sample Iliyan.

Browsing LuxRenders code base I noticed they have a method in their
BxDF interface named "Weight" which their MultiBSDF uses to select
which BxDF to sample.
Flipping up their version of SpecularReflection BxDF to see how they
calculate this weight, one can see they're evaluating the fresnel
term.

I will try to mimic this now. Again many thanks for explaining this.
Much appreciated.


On 29 Feb, 14:15, Iliyan Georgiev <for...@iliyan.com> wrote:

Iliyan Georgiev

unread,
Mar 1, 2012, 12:19:21 PM3/1/12
to pbrt
Glad to be of help ;)

It is in fact a pretty standard to choose between the different
components of a composite material, with a probability proportional to
the (hemispherical-directional, using PBRT's terminology) reflectance.
E.g. in a Phong-Diffuse, Specular-Diffuse, or more complex material.
This way you're guaranteed that the "brightness" (luminance, or some
other average intensity, depending on how you convert the multi-
spectral reflectance to a float) of the photon energy will stay the
same after the bounce, although the chromaticity (color) will change,
in case you're tracing multi-spectral (e.g. RGB) particles.

Cheers,
Iliyan
Reply all
Reply to author
Forward
0 new messages