9.7 Rough Dielectric BSDF

We will now extend the microfacet approach from Section 9.6 to the case of rough dielectrics. This involves two notable changes: since dielectrics are characterized by both reflection and transmission, the model must be aware of these two separate components. In the case of transmission, Snell’s law will furthermore replace the law of reflection in the computation that determines the incident direction.

Figure 9.32 shows the dragon rendered with the Torrance–Sparrow model and both reflection and transmission.

Figure 9.32: Dragon models rendered with the Torrance–Sparrow microfacet model featuring both reflection (a) and transmission (b). (Model courtesy of Christian Schüller.)

As before, we will begin by characterizing the probability density of generated samples. The implied BSDF then directly follows from this density and the sequence of events encapsulated by a scattering interaction: visible normal sampling, reflection or refraction, and attenuation by the Fresnel and masking terms.

Rough Dielectric PDF

The density evaluation occurs in the following fragment that we previously omitted during the discussion of the smooth dielectric case.

<<Evaluate sampling PDF of rough dielectric BSDF>>= 
<<Compute generalized half vector wm>> 
Float cosTheta_o = CosTheta(wo), cosTheta_i = CosTheta(wi); bool reflect = cosTheta_i * cosTheta_o > 0; float etap = 1; if (!reflect) etap = cosTheta_o > 0 ? eta : (1 / eta); Vector3f wm = wi * etap + wo; if (cosTheta_i == 0 || cosTheta_o == 0 || LengthSquared(wm) == 0) return {}; wm = FaceForward(Normalize(wm), Normal3f(0, 0, 1));
<<Discard backfacing microfacets>> 
if (Dot(wm, wi) * cosTheta_i < 0 || Dot(wm, wo) * cosTheta_o < 0) return {};
<<Determine Fresnel reflectance of rough dielectric boundary>> 
Float R = FrDielectric(Dot(wo, wm), eta); Float T = 1 - R;
<<Compute probabilities pr and pt for sampling reflection and transmission>> 
Float pr = R, pt = T; if (!(sampleFlags & BxDFReflTransFlags::Reflection)) pr = 0; if (!(sampleFlags & BxDFReflTransFlags::Transmission)) pt = 0; if (pr == 0 && pt == 0) return {};
<<Return PDF for rough dielectric>> 
Float pdf; if (reflect) { <<Compute PDF of rough dielectric reflection>> 
pdf = mfDistrib.PDF(wo, wm) / (4 * AbsDot(wo, wm)) * pr / (pr + pt);
} else { <<Compute PDF of rough dielectric transmission>> 
Float denom = Sqr(Dot(wi, wm) + Dot(wo, wm) / etap); Float dwm_dwi = AbsDot(wi, wm) / denom; pdf = mfDistrib.PDF(wo, wm) * dwm_dwi * pt / (pr + pt);
} return pdf;

We now turn to the generalized half-direction vector, whose discussion requires a closer look at Snell’s law (Equation (9.2)) relating the elevation and azimuth of the incident and outgoing directions at a refractive interface:

eta Subscript normal o Baseline sine theta Subscript normal o Baseline equals eta Subscript normal i Baseline sine theta Subscript normal i Baseline and phi Subscript normal o Baseline equals phi Subscript normal i Baseline plus pi period

Since the refraction takes place at the level of the microgeometry, all of these angles are to be understood within a coordinate frame aligned with the microfacet normal omega Subscript normal m . Recall also that the sines in the first equation refer to the length of the tangential component of omega Subscript normal i and omega Subscript normal o perpendicular to omega Subscript normal m .

A generalized half-direction vector builds on this observation by scaling and adding these directions to cancel out the tangential components, which yields the surface normal responsible for a particular refraction after normalization. It is defined as

omega Subscript normal m Baseline equals StartFraction eta Subscript normal i Baseline omega Subscript normal i Baseline plus eta Subscript normal o Baseline omega Subscript normal o Baseline Over double-vertical-bar eta Subscript normal i Baseline omega Subscript normal i Baseline plus eta Subscript normal o Baseline omega Subscript normal o Baseline double-vertical-bar EndFraction equals StartFraction eta omega Subscript normal i Baseline plus omega Subscript normal o Baseline Over double-vertical-bar eta omega Subscript normal i Baseline plus omega Subscript normal o Baseline double-vertical-bar EndFraction comma

where eta equals eta Subscript normal i Baseline slash eta Subscript normal o is the relative index of refraction toward the sampled direction omega Subscript normal i . The reflective case is trivially subsumed, since eta Subscript normal i Baseline equals eta Subscript normal o when no refraction takes place. The next fragment implements this computation, including handling of invalid configurations (e.g., perfectly grazing incidence) where both the BSDF and its sampling density evaluate to zero.

<<Compute generalized half vector wm>>= 
Float cosTheta_o = CosTheta(wo), cosTheta_i = CosTheta(wi); bool reflect = cosTheta_i * cosTheta_o > 0; float etap = 1; if (!reflect) etap = cosTheta_o > 0 ? eta : (1 / eta); Vector3f wm = wi * etap + wo; if (cosTheta_i == 0 || cosTheta_o == 0 || LengthSquared(wm) == 0) return {}; wm = FaceForward(Normalize(wm), Normal3f(0, 0, 1));

The last line reflects an important implementation detail: with the previous definition in Equation (9.34), omega Subscript normal m always points toward the denser medium, whereas pbrt uses the convention that micro- and macro-normal are consistently oriented (i.e., omega Subscript normal m Baseline dot bold n Subscript Baseline greater-than 0 ). In practice, we therefore compute the following modified half-direction vector, where bold n Subscript Baseline equals left-parenthesis 0 comma 0 comma 1 right-parenthesis in local coordinates:

Next, microfacets that are backfacing with respect to either the incident or outgoing direction do not contribute and must be discarded.

<<Discard backfacing microfacets>>= 
if (Dot(wm, wi) * cosTheta_i < 0 || Dot(wm, wo) * cosTheta_o < 0) return {};

Given omega Subscript normal m , we can evaluate the Fresnel reflection and transmission terms using the specialized dielectric evaluation of the Fresnel equations.

<<Determine Fresnel reflectance of rough dielectric boundary>>= 
Float R = FrDielectric(Dot(wo, wm), eta); Float T = 1 - R;

We now have the values necessary to compute the PDF for omega Subscript normal i , which depends on whether it reflects or transmits at the surface.

<<Return PDF for rough dielectric>>= 
Float pdf; if (reflect) { <<Compute PDF of rough dielectric reflection>> 
pdf = mfDistrib.PDF(wo, wm) / (4 * AbsDot(wo, wm)) * pr / (pr + pt);
} else { <<Compute PDF of rough dielectric transmission>> 
Float denom = Sqr(Dot(wi, wm) + Dot(wo, wm) / etap); Float dwm_dwi = AbsDot(wi, wm) / denom; pdf = mfDistrib.PDF(wo, wm) * dwm_dwi * pt / (pr + pt);
} return pdf;

As before, the bijective mapping between omega Subscript normal m and omega Subscript normal i provides a change of variables whose Jacobian determinant is crucial so that we can correctly deduce the probability density of sampled directions omega Subscript normal i . The derivation is more involved in the refractive case; see the “Further Reading” section for pointers to its derivation. The final determinant is given by

StartLayout 1st Row 1st Column normal d omega Subscript normal m 2nd Column equals StartFraction eta Subscript normal i Superscript 2 Baseline StartAbsoluteValue omega Subscript normal i Baseline dot omega Subscript normal m Baseline EndAbsoluteValue Over left-parenthesis eta Subscript normal i Baseline left-parenthesis omega Subscript normal i Baseline dot omega Subscript normal m Baseline right-parenthesis plus eta Subscript normal o Baseline left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis right-parenthesis squared EndFraction normal d omega Subscript normal i Baseline 2nd Row 1st Column Blank 2nd Column equals StartFraction StartAbsoluteValue omega Subscript normal o Baseline dot omega Subscript normal m Baseline EndAbsoluteValue Over left-parenthesis left-parenthesis omega Subscript normal i Baseline dot omega Subscript normal m Baseline right-parenthesis plus left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis slash eta right-parenthesis squared EndFraction normal d omega Subscript normal i Baseline period EndLayout

Once more, this relationship makes it possible to evaluate the probability per unit solid angle of the sampled incident directions omega Subscript normal i obtained through the combination of visible normal sampling and scattering:

p left-parenthesis omega Subscript normal i Baseline right-parenthesis equals upper D Subscript omega Sub Subscript normal o Subscript Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis StartFraction normal d omega Subscript normal m Baseline Over normal d omega Subscript normal i Baseline EndFraction equals StartFraction upper D Subscript omega Sub Subscript normal o Subscript Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis StartAbsoluteValue omega Subscript normal o Baseline dot omega Subscript normal m Baseline EndAbsoluteValue Over left-parenthesis left-parenthesis omega Subscript normal i Baseline dot omega Subscript normal m Baseline right-parenthesis plus left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis slash eta right-parenthesis squared EndFraction period

The following fragment implements this computation, while additionally accounting for the discrete probability pt / (pr + pt) of sampling the transmission component.

<<Compute PDF of rough dielectric transmission>>= 
Float denom = Sqr(Dot(wi, wm) + Dot(wo, wm) / etap); Float dwm_dwi = AbsDot(wi, wm) / denom; pdf = mfDistrib.PDF(wo, wm) * dwm_dwi * pt / (pr + pt);

Finally, the density of the reflection component agrees with the model used for conductors but for the additional discrete probability pr / (pr + pt) of choosing the reflection component.

<<Compute PDF of rough dielectric reflection>>= 
pdf = mfDistrib.PDF(wo, wm) / (4 * AbsDot(wo, wm)) * pr / (pr + pt);

Rough Dielectric BSDF

BSDF evaluation is similarly split into reflective and transmissive components.

<<Evaluate rough dielectric BSDF>>= 
<<Compute generalized half vector wm>> 
Float cosTheta_o = CosTheta(wo), cosTheta_i = CosTheta(wi); bool reflect = cosTheta_i * cosTheta_o > 0; float etap = 1; if (!reflect) etap = cosTheta_o > 0 ? eta : (1 / eta); Vector3f wm = wi * etap + wo; if (cosTheta_i == 0 || cosTheta_o == 0 || LengthSquared(wm) == 0) return {}; wm = FaceForward(Normalize(wm), Normal3f(0, 0, 1));
<<Discard backfacing microfacets>> 
if (Dot(wm, wi) * cosTheta_i < 0 || Dot(wm, wo) * cosTheta_o < 0) return {};
Float F = FrDielectric(Dot(wo, wm), eta); if (reflect) { <<Compute reflection at rough dielectric interface>> 
return SampledSpectrum(mfDistrib.D(wm) * mfDistrib.G(wo, wi) * F / std::abs(4 * cosTheta_i * cosTheta_o));
} else { <<Compute transmission at rough dielectric interface>> 
Float denom = Sqr(Dot(wi, wm) + Dot(wo, wm)/etap) * cosTheta_i * cosTheta_o; Float ft = mfDistrib.D(wm) * (1 - F) * mfDistrib.G(wo, wi) * std::abs(Dot(wi, wm) * Dot(wo, wm) / denom); <<Account for non-symmetry with transmission to different medium>> 
if (mode == TransportMode::Radiance) ft /= Sqr(etap);
return SampledSpectrum(ft);
}

The reflection component follows the approach used for conductors in the fragment <<Evaluate rough conductor BRDF>>:

<<Compute reflection at rough dielectric interface>>= 
return SampledSpectrum(mfDistrib.D(wm) * mfDistrib.G(wo, wi) * F / std::abs(4 * cosTheta_i * cosTheta_o));

For the transmission component, we can again derive the effective scattering distribution by equating a single-sample Monte Carlo estimate of the rendering equation with the product of Fresnel transmission, masking, and the incident radiance. This results in the equation

StartFraction f Subscript normal t Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript normal o Baseline comma omega Subscript normal i Baseline right-parenthesis upper L Subscript normal i Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript normal i Baseline right-parenthesis StartAbsoluteValue cosine theta Subscript normal i Baseline EndAbsoluteValue Over p left-parenthesis omega Subscript normal i Baseline right-parenthesis EndFraction ModifyingAbove equals With factorial left-parenthesis 1 minus upper F left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis right-parenthesis upper G 1 left-parenthesis omega Subscript normal i Baseline right-parenthesis upper L Subscript normal i Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript normal i Baseline right-parenthesis period

Substituting the PDF from Equation (9.37) and solving for the BTDF f Subscript normal t Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript normal o Baseline comma omega Subscript normal i Baseline right-parenthesis results in

f Subscript normal t Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript normal o Baseline comma omega Subscript normal i Baseline right-parenthesis equals StartFraction upper D Subscript omega Sub Subscript normal o Subscript Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis StartAbsoluteValue omega Subscript normal o Baseline dot omega Subscript normal m Baseline EndAbsoluteValue upper D Subscript omega Sub Subscript normal o Subscript Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis left-parenthesis 1 minus upper F left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis right-parenthesis upper G 1 left-parenthesis omega Subscript normal i Baseline right-parenthesis Over left-parenthesis left-parenthesis omega Subscript normal i Baseline dot omega Subscript normal m Baseline right-parenthesis plus left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis slash eta right-parenthesis squared StartAbsoluteValue cosine theta Subscript normal i Baseline EndAbsoluteValue EndFraction period

Finally, inserting the definition of the visible normal distribution from Equation (9.23) and switching to the more accurate bidirectional masking-shadowing factor upper G yields

f Subscript normal t Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript normal o Baseline comma omega Subscript normal i Baseline right-parenthesis equals StartFraction upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis left-parenthesis 1 minus upper F left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis right-parenthesis upper G left-parenthesis omega Subscript normal i Baseline comma omega Subscript normal o Baseline right-parenthesis Over left-parenthesis left-parenthesis omega Subscript normal i Baseline dot omega Subscript normal m Baseline right-parenthesis plus left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis slash eta right-parenthesis squared EndFraction StartFraction StartAbsoluteValue omega Subscript normal i Baseline dot omega Subscript normal m Baseline EndAbsoluteValue StartAbsoluteValue omega Subscript normal o Baseline dot omega Subscript normal m Baseline EndAbsoluteValue Over StartAbsoluteValue cosine theta Subscript normal i Baseline EndAbsoluteValue StartAbsoluteValue cosine theta Subscript normal o Baseline EndAbsoluteValue EndFraction period

The next fragment implements this expression. It also incorporates the earlier orientation test and handling of non-symmetric scattering that was previously encountered in the perfect specular case (Section 9.5.2).

<<Compute transmission at rough dielectric interface>>= 
Float denom = Sqr(Dot(wi, wm) + Dot(wo, wm)/etap) * cosTheta_i * cosTheta_o; Float ft = mfDistrib.D(wm) * (1 - F) * mfDistrib.G(wo, wi) * std::abs(Dot(wi, wm) * Dot(wo, wm) / denom); <<Account for non-symmetry with transmission to different medium>> 
if (mode == TransportMode::Radiance) ft /= Sqr(etap);
return SampledSpectrum(ft);

Rough Dielectric Sampling

Sampling proceeds by drawing a microfacet normal from the visible normal distribution, computing the Fresnel term, and stochastically selecting between reflection and transmission.

<<Sample rough dielectric BSDF>>= 
Vector3f wm = mfDistrib.Sample_wm(wo, u); Float R = FrDielectric(Dot(wo, wm), eta); Float T = 1 - R; <<Compute probabilities pr and pt for sampling reflection and transmission>> 
Float pr = R, pt = T; if (!(sampleFlags & BxDFReflTransFlags::Reflection)) pr = 0; if (!(sampleFlags & BxDFReflTransFlags::Transmission)) pt = 0; if (pr == 0 && pt == 0) return {};
Float pdf; if (uc < pr / (pr + pt)) { <<Sample reflection at rough dielectric interface>> 
Vector3f wi = Reflect(wo, wm); if (!SameHemisphere(wo, wi)) return {}; <<Compute PDF of rough dielectric reflection>> 
pdf = mfDistrib.PDF(wo, wm) / (4 * AbsDot(wo, wm)) * pr / (pr + pt);
SampledSpectrum f(mfDistrib.D(wm) * mfDistrib.G(wo, wi) * R / (4 * CosTheta(wi) * CosTheta(wo))); return BSDFSample(f, wi, pdf, BxDFFlags::GlossyReflection);
} else { <<Sample transmission at rough dielectric interface>> 
Float etap; Vector3f wi; bool tir = !Refract(wo, (Normal3f)wm, eta, &etap, &wi); if (SameHemisphere(wo, wi) || wi.z == 0 || tir) return {}; <<Compute PDF of rough dielectric transmission>> 
Float denom = Sqr(Dot(wi, wm) + Dot(wo, wm) / etap); Float dwm_dwi = AbsDot(wi, wm) / denom; pdf = mfDistrib.PDF(wo, wm) * dwm_dwi * pt / (pr + pt);
<<Evaluate BRDF and return BSDFSample for rough transmission>> 
SampledSpectrum ft(T * mfDistrib.D(wm) * mfDistrib.G(wo, wi) * std::abs(Dot(wi, wm) * Dot(wo, wm) / (CosTheta(wi) * CosTheta(wo) * denom))); <<Account for non-symmetry with transmission to different medium>> 
if (mode == TransportMode::Radiance) ft /= Sqr(etap);
return BSDFSample(ft, wi, pdf, BxDFFlags::GlossyTransmission, etap);
}

Once again, handling of the reflection component is straightforward and mostly matches the case for conductors except for extra factors that arise due to the discrete choice between reflection and transmission components.

<<Sample reflection at rough dielectric interface>>= 
Vector3f wi = Reflect(wo, wm); if (!SameHemisphere(wo, wi)) return {}; <<Compute PDF of rough dielectric reflection>> 
pdf = mfDistrib.PDF(wo, wm) / (4 * AbsDot(wo, wm)) * pr / (pr + pt);
SampledSpectrum f(mfDistrib.D(wm) * mfDistrib.G(wo, wi) * R / (4 * CosTheta(wi) * CosTheta(wo))); return BSDFSample(f, wi, pdf, BxDFFlags::GlossyReflection);

The transmission case invokes Refract() to determine wi. A subsequent test excludes inconsistencies that can rarely arise due to the approximate nature of floating-point arithmetic. For example, Refract() may sometimes indicate a total internal reflection configuration, which is inconsistent as the transmission component should not have been sampled in this case.

<<Sample transmission at rough dielectric interface>>= 
Float etap; Vector3f wi; bool tir = !Refract(wo, (Normal3f)wm, eta, &etap, &wi); if (SameHemisphere(wo, wi) || wi.z == 0 || tir) return {}; <<Compute PDF of rough dielectric transmission>> 
Float denom = Sqr(Dot(wi, wm) + Dot(wo, wm) / etap); Float dwm_dwi = AbsDot(wi, wm) / denom; pdf = mfDistrib.PDF(wo, wm) * dwm_dwi * pt / (pr + pt);
<<Evaluate BRDF and return BSDFSample for rough transmission>> 
SampledSpectrum ft(T * mfDistrib.D(wm) * mfDistrib.G(wo, wi) * std::abs(Dot(wi, wm) * Dot(wo, wm) / (CosTheta(wi) * CosTheta(wo) * denom))); <<Account for non-symmetry with transmission to different medium>> 
if (mode == TransportMode::Radiance) ft /= Sqr(etap);
return BSDFSample(ft, wi, pdf, BxDFFlags::GlossyTransmission, etap);

The last step evaluates the BTDF from Equation (9.40) and packs the sample information into a BSDFSample.

<<Evaluate BRDF and return BSDFSample for rough transmission>>= 
SampledSpectrum ft(T * mfDistrib.D(wm) * mfDistrib.G(wo, wi) * std::abs(Dot(wi, wm) * Dot(wo, wm) / (CosTheta(wi) * CosTheta(wo) * denom))); <<Account for non-symmetry with transmission to different medium>> 
if (mode == TransportMode::Radiance) ft /= Sqr(etap);
return BSDFSample(ft, wi, pdf, BxDFFlags::GlossyTransmission, etap);