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.
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.
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:
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 . Recall also that the sines in the first equation refer to the length of the tangential component of and perpendicular to .
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
where is the relative index of refraction toward the sampled direction . The reflective case is trivially subsumed, since 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.
The last line reflects an important implementation detail: with the previous definition in Equation (9.34), always points toward the denser medium, whereas pbrt uses the convention that micro- and macro-normal are consistently oriented (i.e., ). In practice, we therefore compute the following modified half-direction vector, where in local coordinates:
Next, microfacets that are backfacing with respect to either the incident or outgoing direction do not contribute and must be discarded.
Given , we can evaluate the Fresnel reflection and transmission terms using the specialized dielectric evaluation of the Fresnel equations.
We now have the values necessary to compute the PDF for , which depends on whether it reflects or transmits at the surface.
As before, the bijective mapping between and provides a change of variables whose Jacobian determinant is crucial so that we can correctly deduce the probability density of sampled directions . 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
Once more, this relationship makes it possible to evaluate the probability per unit solid angle of the sampled incident directions obtained through the combination of visible normal sampling and scattering:
The following fragment implements this computation, while additionally accounting for the discrete probability pt / (pr + pt) of sampling the transmission component.
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.
Rough Dielectric BSDF
BSDF evaluation is similarly split into reflective and transmissive components.
The reflection component follows the approach used for conductors in the fragment <<Evaluate rough conductor BRDF>>:
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
Finally, inserting the definition of the visible normal distribution from Equation (9.23) and switching to the more accurate bidirectional masking-shadowing factor yields
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).
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.
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.
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.
The last step evaluates the BTDF from Equation (9.40) and packs the sample information into a BSDFSample.