# total internal reflection implementation in pbrt-v3

I've been implementing a path tracer, referring pbrt-v3. However, I'm a bit confused about its implementation. Code is here.

It seems when we sample to do transmission, it tests if it meets a total internal reflection, but it doesn't assign a proper value to the pdf, instead, after the function returns Vec3f(0,0,0) as BTDF value, it then tests if pdf is 0, if 0 then directly jumps out of the tracing loop.

I don't think this make sense since there should be radiance value if this ray continues to trace and does out of the specular object and hit a surface which is illuminated. But this implementation seems to leave out all such kind of radiance, and rely on the sample_f function to sample a reflection.

So how to properly compute the pdf of total internal reflection?

        // Account for the indirect subsurface scattering component
Spectrum f = pi.bsdf->Sample_f(pi.wo, &wi, sampler.Get2D(), &pdf,
BSDF_ALL, &flags);
if (f.IsBlack() || pdf == 0) break;


By returning 0 it's basically saying the same thing as pdf = 0 because f.IsBlack() returns true.
This is acceptable, it's basically saying the BSDF doesn't allow light go through at the given $$w_o$$