Roughness Using Microfacet Theory
9.6 Roughness Using Microfacet Theory
The preceding discussion of the ConductorBxDF and DielectricBxDF only considered the perfect specular case, where the interface between materials was assumed to be ideally smooth and devoid of any roughness or other surface imperfections. However, many real-world materials are rough at a microscopic scale, which affects the way in which they reflect or transmit light.
We will now turn to a generalization of these BxDFs using microfacet theory, which models rough surfaces as a collection of small surface patches denoted as microfacets. These microfacets are assumed to be individually very small so that they cannot be resolved by the camera. Yet, despite their small size, they can have a profound impact on the angular distribution of scattered light. Figure 9.20 shows cross sections of a relatively rough surface and a much smoother microfacet surface. We will use the term macrosurface to describe the original coarse surface (e.g., as represented by a Shape) and microsurface to describe the fine-scale geometry based on microfacets.
Figure 9.20: Microfacet surface models are often
described by a function that gives the distribution of microfacet
normals with respect to the surface normal
. (a) The greater the
variation of microfacet normals, the rougher the surface is. (b) Smooth
surfaces have relatively little variation of microfacet normals.
It is worth noting that pbrt can in principle already render rough surfaces without resorting to microfacet theory: users could simply create extremely high-resolution triangular meshes containing such micro-scale surface variations and render them using perfect specular BxDFs. There are two fundamental problems with such an approach:
- Storage and ray tracing efficiency: Representing micro-scale roughness using triangular geometry would require staggeringly large triangle budgets. The overheads to store and ray trace such large scenes are prohibitive.
- Monte Carlo sampling efficiency: A fundamental issue with perfect specular scattering distributions is that they contain Dirac delta terms, which preclude BSDF evaluation (their f() method returns zero, making BSDF sampling the only supported operation). This aspect disables light sampling strategies (Section 12.1), which are crucial for efficiency in Monte Carlo rendering.
A key insight of microfacet theory is that large numbers of microfacets can be efficiently modeled statistically, since it is only their aggregate behavior that determines the observed scattering. (A similar statistical physics approach is used to avoid the costly storage of vast numbers of small particles comprising participating media in Chapter 11.) This approach addresses both of the above issues: BSDF models based on microfacet theory do not require explicit storage of the microgeometry, and they replace the infinitely peaked Dirac delta terms with smooth distributions that enable more efficient Monte Carlo sampling.
Figure 9.21: Three Important Geometric Effects to Consider with Microfacet Reflection Models. (a) Masking: the microfacet of interest is not visible to the viewer due to occlusion by another microfacet. (b) Shadowing: analogously, light does not reach the microfacet. (c) Interreflection: light bounces among the microfacets before reaching the viewer.
Several factors related to the geometry of the microfacets affect how they scatter light (Figure 9.21): for example, a microfacet may be occluded (“masked”) or lie in the shadow of a neighboring microfacet, and incident light may interreflect among microfacets. Widely used microfacet BSDFs ignore interreflection and model the remaining masking and shadowing effects using statistical approximations with efficient evaluation procedures.
The two main components of microfacet models are a representation of the statistical distribution of facets and a BSDF that describes how light scatters from an individual microfacet. For the latter part, pbrt supports perfect specular conductors and dielectrics, though other choices are in principle also possible. Given these two ingredients, the aggregate BSDF arising from the microsurface can be determined.
9.6.1 The Microfacet Distribution
Microgeometry principally affects scattering via variation of the surface normal, which is a consequence of the central role of the surface normal in Snell’s law and the law of specular reflection. Under the assumption that the light source and observer are distant with respect to the scale of the microfacets, the precise surface profile has a lesser effect on masking and shadowing that we will study in Section 9.6.2. For now, our focus is on the microfacet distribution, which represents roughness in terms of its effect on the surface normal.
Let us denote a small region of a macrosurface as . The corresponding
microsurface
is obtained by displacing the macrosurface along
its normal
, which means that perpendicular projection of the microsurface exactly
covers the macrosurface:
(9.14)
where specifies the microfacet normal at
. However,
tracking the orientation of vast numbers of microfacets would be impractical as
previously discussed.
We therefore turn to a statistical approach: the microfacet distribution
function gives the relative differential area of microfacets with the
surface normal
. For example, a perfectly smooth surface has a Dirac delta
peak in the direction of the original surface normal—that is,
. The function is generally expressed in the standard
reflection coordinate system with
.
Cast into the directional domain, Equation (9.14) provides a useful normalization condition ensuring that a particular microfacet distribution is physically plausible, as illustrated in Figure 9.22.
(9.15)
Figure 9.22:
Given a differential area on a surface , the microfacet normal
distribution function
must be normalized such that the projected
surface area of the microfacets above the area is equal to
.
The most common type of microfacet distribution is isotropic, which also
leads to an isotropic aggregate BSDF. Recall that the local scattering behavior
of an isotropic BSDF does not change when the surface is rotated about the
macroscopic surface normal. In the isotropic case, a spherical coordinate
parameterization yields a
distribution that only depends on the elevation angle
.
In contrast, an anisotropic microfacet distribution also depends on the azimuth
to capture directional variation in the surface roughness.
Many real-world materials are anisotropic: for example, rolled or milled steel
surfaces feature grooves that are aligned with the direction of extrusion.
Rotating a flat sheet of such material about the surface normal results in
noticeable variation—for example, in the reflection
profile of indirectly observed light sources.
Brushed metal is an extreme case: its microfacet distribution varies from
almost a single direction to almost uniform over the hemisphere.
Many functional representations of microfacet distributions have been proposed over the years. Geometric analysis of a truncated ellipsoid leads to one of the most widely used distributions proposed by Trowbridge and Reitz (1975), in which the conceptual microsurface is composed of vast numbers of ellipsoidal bumps. Scaled along its different semi-axes, an ellipsoid can take on a variety of configurations including sphere-, pancake-, and cigar-shaped surfaces. It is enough to study the density of surface normals on a single representative ellipsoid, which has an analytic solution:
(9.16)
This equation assumes that the semi-axes of the ellipsoid are aligned with the
shading frame, and the reciprocals of the two variables encode a scale transformation applied along the two tangential
axes. When
, the ellipsoid has been stretched
to such a degree that it essentially collapses into a flat surface, and the
aggregate BSDF approximates a perfect specular material. For larger values
(e.g.,
), the ellipsoidal bumps introduce
significant normal variation that blurs the directional distribution of
reflected and transmitted light. When
, the azimuth
dependence drops out, and the model becomes isotropic.
A characteristic feature of the Trowbridge–Reitz model compared to other
microfacet distributions is its long tails: the density of microfacets
decays comparably slowly as approaches grazing configurations
(
). This matches the properties of many
real-world surfaces well. See Figure 9.23 for a graph
of it and another commonly used microfacet distribution function.

Figure 9.23:
Graphs of isotropic Beckmann–Spizzichino and Trowbridge–Reitz
microfacet distribution functions as a function of for
. Note that Trowbridge–Reitz has higher tails at
larger values of
.
The TrowbridgeReitzDistribution class encapsulates the state and functionality needed to use this microfacet distribution in a Monte Carlo renderer.
<>=
class TrowbridgeReitzDistribution { public: <<TrowbridgeReitzDistribution Public Methods>>
TrowbridgeReitzDistribution(Float alpha_x, Float alpha_y) : alpha_x(alpha_x), alpha_y(alpha_y) {} Float D(Vector3f wm) const { Float tan2Theta = Tan2Theta(wm); if (IsInf(tan2Theta)) return 0; Float cos4Theta = Sqr(Cos2Theta(wm)); Float e = tan2Theta * (Sqr(CosPhi(wm) / alpha_x) + Sqr(SinPhi(wm) / alpha_y)); return 1 / (Pi * alpha_x * alpha_y * cos4Theta * Sqr(1 + e)); } bool EffectivelySmooth() const { return std::max(alpha_x, alpha_y) < 1e-3f; } Float G1(Vector3f w) const { return 1 / (1 + Lambda(w)); } Float Lambda(Vector3f w) const { Float tan2Theta = Tan2Theta(w); if (IsInf(tan2Theta)) return 0; Float alpha2 = Sqr(CosPhi(w) * alpha_x) + Sqr(SinPhi(w) * alpha_y); return (std::sqrt(1 + alpha2 * tan2Theta) - 1) / 2; } Float G(Vector3f wo, Vector3f wi) const { return 1 / (1 + Lambda(wo) + Lambda(wi)); } Float D(Vector3f w, Vector3f wm) const { return G1(w) / AbsCosTheta(w) * D(wm) * AbsDot(w, wm); } Float PDF(Vector3f w, Vector3f wm) const { return D(w, wm); } Vector3f Sample_wm(Vector3f w, Point2f u) const { <<Transform w to hemispherical configuration>>
Vector3f wh = Normalize(Vector3f(alpha_x * w.x, alpha_y * w.y, w.z)); if (wh.z < 0) wh = -wh;
<<Find orthonormal basis for visible normal sampling>>
Vector3f T1 = (wh.z < 0.99999f) ? Normalize(Cross(Vector3f(0, 0, 1), wh)) : Vector3f(1, 0, 0); Vector3f T2 = Cross(wh, T1);
<<Generate uniformly distributed points on the unit disk>>
Point2f p = SampleUniformDiskPolar(u);
<<Warp hemispherical projection for visible normal sampling>>
Float h = std::sqrt(1 - Sqr(p.x)); p.y = Lerp((1 + wh.z) / 2, h, p.y);
<<Reproject to hemisphere and transform normal to ellipsoid configuration>>
Float pz = std::sqrt(std::max(0, 1 - LengthSquared(Vector2f(p)))); Vector3f nh = p.x * T1 + p.y * T2 + pz * wh; return Normalize(Vector3f(alpha_x * nh.x, alpha_y * nh.y, std::max(1e-6f, nh.z)));
} std::string ToString() const; static Float RoughnessToAlpha(Float roughness) { return std::sqrt(roughness); } void Regularize() { if (alpha_x < 0.3f) alpha_x = Clamp(2 * alpha_x, 0.1f, 0.3f); if (alpha_y < 0.3f) alpha_y = Clamp(2 * alpha_y, 0.1f, 0.3f); }
private: <<TrowbridgeReitzDistribution Private Members>>
Float alpha_x, alpha_y;
};
<>=
TrowbridgeReitzDistribution(Float alpha_x, Float alpha_y) : alpha_x(alpha_x), alpha_y(alpha_y) {}
<>=
The D() method is a fairly direct transcription of Equation (9.16) with some additional handling of numerical edge cases.
<>+=
Float D(Vector3f wm) const { Float tan2Theta = Tan2Theta(wm); if (IsInf(tan2Theta)) return 0; Float cos4Theta = Sqr(Cos2Theta(wm)); Float e = tan2Theta * (Sqr(CosPhi(wm) / alpha_x) + Sqr(SinPhi(wm) / alpha_y)); return 1 / (Pi * alpha_x * alpha_y * cos4Theta * Sqr(1 + e)); }
Even with those precautions, numerical issues involving infinite or
not-a-number values tend to arise at very low roughnesses. It is better to treat such
surfaces as perfectly smooth and fall back to the previously discussed
specialized implementations. The EffectivelySmooth() method tests the
values for this case.
<>+=
bool EffectivelySmooth() const { return std::max(alpha_x, alpha_y) < 1e-3f; }
9.6.2 The Masking Function
A microfacet distribution alone is not enough to construct a valid energy-conserving BSDF. Observed from a specific direction, only a subset of microfacets is visible, which must be considered to avoid non-physical energy gains. In particular, microfacets may be masked because they are backfacing, or due to occlusion by other microfacets. Our approach is once more to capture this effect in a statistically averaged manner instead of tracking the properties of an actual microsurface.
Recall Equation (9.15), which stated that the
micro- and macrosurfaces occupy the same area under perpendicular projection
along the surface normal . The masking function
enables a generalization of this statement to other projection directions
. We will shortly discuss how
is derived and simply postulate its
existence for now. The function specifies the fraction of microfacets with
normal
that are visible from direction
, and it therefore satisfies
for all arguments.
Figure 9.24:
As seen from a viewer or a light source, a differential area on
the surface has area , where
is the angle
of the incident direction with the surface normal. The projected surface area of
visible microfacets (thick lines) must be equal to
as well; the
masking function
gives the fraction of the total microfacet
area over
that is visible in the given direction.
Figure 9.24 illustrates the oblique
generalization of Equation (9.15), whose left hand
side integrates over microfacets and computes the area of their perpendicular
projection along . A maximum is taken to ignore backfacing microfacets,
and
accounts for masking by other facets. The right hand side captures the
relative size of the macrosurface, which shrinks by a factor of
.
(9.17)
We expect that physically plausible combinations of microfacet distribution
(the Trowbridge–Reitz distribution in our case) and masking function
should satisfy this equation. Unfortunately, the microfacet
distribution alone does not impose enough conditions to imply a specific
; an infinite family of functions could fulfill the constraint in
Equation (9.17). More information about the specific surface
height profile is necessary to narrow down this large set of possibilities.
At this point, an approximation is often taken: if the
height and normals of different points on
the surface are assumed to be statistically independent, the material
conceptually turns from a connected surface into an opaque soup of little
surface fragments that float in space (hence the name “microfacets”).
A consequence of this simplification is that masking becomes independent of the
microsurface normal , except for the constraint that backfacing facets
are ignored (
). The masking term can then be moved out of the
integral of Equation (9.17):
which can be rearranged to solve for :
(9.18)
This is Smith’s approximation. Despite the rather severe simplification, it has been found to be in good agreement with both brute-force simulation of scattering on randomly generated surface microstructures and real-world measurements.
The integral in Equation (9.18) has analytic solutions
for various common choices of microfacet distributions , including the
Trowbridge–Reitz model. In practice, the masking function is often expressed in
terms of an auxiliary function
that arises naturally when the
derivation of masking is conducted in the slope domain. This has some benefits
that we shall see shortly, and we therefore adopt the same approach that
relates
and
as follows:
(9.19)
The Lambda() method computes this function.
<>+=
Float G1(Vector3f w) const { return 1 / (1 + Lambda(w)); }
Under the uncorrelated height assumption, has the following
analytic solution for the Trowbridge–Reitz distribution:
(9.20)
where denotes the isotropic surface roughness. An anisotropic
generalization follows from the observation that anisotropy implies tangential
scaling of the microsurface based on
and
.
A 1-dimensional ray
that is not aligned with the
- or
-axis will
observe a different scaling amount that lies between these extremes.
The associated interpolated roughness is given by
(9.21)
Anisotropic masking reuses the isotropic with this definition of
. The “Further Reading” section at the end of this chapter provides
more details on these steps. The Lambda() function implements
Equation (9.20) in the general case.
<>+=
Float Lambda(Vector3f w) const { Float tan2Theta = Tan2Theta(w); if (IsInf(tan2Theta)) return 0; Float alpha2 = Sqr(CosPhi(w) * alpha_x) + Sqr(SinPhi(w) * alpha_y); return (std::sqrt(1 + alpha2 * tan2Theta) - 1) / 2; }

Figure 9.25: Spheres rendered with (left) an anisotropic microfacet distribution and (right) an isotropic distribution. Note the different specular highlight shapes from the anisotropic model. We have used spheres here instead of the dragon, since anisotropic models like these depend on a globally consistent set of tangent vectors over the surface to orient the direction of anisotropy in a reasonable way.
Figure 9.25 compares the appearance of two spheres with an isotropic and an anisotropic microfacet model lit by a light source simulating a distant environment.
Figure 9.26 shows a plot of the Trowbridge–Reitz
function for a few values of
. Observe how the function is close to
one over much of the domain but falls to zero at grazing angles, where masking
becomes dominant. Increasing the surface roughness (i.e., higher values of
) causes the function to fall off more quickly.

Figure 9.26: The Masking Function for the
Trowbridge–Reitz Distribution. Increasing surface roughness (higher
values) causes the function to fall off to zero more quickly.
9.6.3 The Masking-Shadowing Function
The BSDF is a function of two directional arguments, and each is subject to
occlusion effects caused by the surface microstructure. For viewing and
lighting directions, these are respectively denoted as masking and
shadowing. To handle both cases, the masking function must be
generalized into a masking-shadowing function
that gives the
fraction of microfacets in a differential area that are simultaneously visible
from both directions
and
.
We know that gives the fraction of microfacets that are visible from
the direction
, and
gives the fraction for
. If we assume
that masking and shadowing are statistically independent events, then these
probabilities can simply be multiplied together:
However, this independence assumption is a rather severe approximation that tends to overestimate the amount of shadowing and masking. This can produce undesirable dark regions in rendered images.
We instead rely on an approximation that accounts for the property that a microfacet with
a higher amount of elevation relative to the macrosurface is more likely to be
observed from both and
. If the heights of microfacets are normally
distributed, a less conservative model for
taking height-based correlation
into account can be derived:
(9.22)
The bidirectional form of implements this equation based on the previously
defined Lambda() function.
<>+=
Float G(Vector3f wo, Vector3f wi) const { return 1 / (1 + Lambda(wo) + Lambda(wi)); }
9.6.4 Sampling the Distribution of Visible Normals
Efficient rendering using microfacet theory hinges on our ability to determine the microfacet encountered by a particular incident ray—in essence, this operation must emulate the process of finding an intersection with the surface microstructure. Thanks to its stochastic definition, an actual ray tracing operation is fortunately not needed: the intersected microfacet follows a known statistical distribution that depends on the roughness and the direction of the incident ray.
Recall the normalization criterion from
Equation (9.17), which stated that the set of
visible microfacets (left hand side) occupy the same area as the underlying
macrosurface (right hand side) when observed from given direction with
elevation angle
:
The probability of a ray interacting with a particular microfacet is directly
proportional to its visible area; hence this equation can be seen to
encapsulate the distribution that should be used. Following division of both
sides by , the integral on the left hand side equals one—in other
words, it turns into a normalized density
that we shall refer
to as the distribution of visible normals:
(9.23)
It describes the projected area of forward-facing normals, where the first term
involving the masking function specifies an -dependent normalization
factor. The method D() evaluates this density function.
<>+=
Float D(Vector3f w, Vector3f wm) const { return G1(w) / AbsCosTheta(w) * D(wm) * AbsDot(w, wm); }
Two upcoming microfacet BSDFs will rely on the ability to sample microfacet
normals according to this density. At this point, one would ordinarily
apply the inversion method (Section 2.3) to
Equation (9.23) to build a sampling
algorithm, but this leads to a relatively complex and approximate method: part
of the problem is that the central inversion step lacks an analytic solution.
We instead follow a simple geometric approach that exploits the definition of the
microsurface in terms of an arrangement of many identical truncated spheres or
ellipsoids.
Before implementing the sampling routine, we will quickly take care of the method that returns the associated PDF, which is simply another name for the D() method.
<>+=
Float PDF(Vector3f w, Vector3f wm) const { return D(w, wm); }
Figure 9.27:
Sampling the distribution of visible normals is equivalent to
casting rays against the surface microstructure that is composed of many
truncated spherical or ellipsoidal bumps. It suffices to consider a single bump in this process.
Figure 9.27 illustrates the high-level idea:
it suffices to focus on a single ellipsoidal or spherical bump and perpendicularly project
parallel rays from an incident direction onto its surface. The
resulting normal directions
will then be distributed according to the
density function
.
Figure 9.28: Sampling the anisotropic variant of the Trowbridge–Reitz distribution entails perpendicular projection of uniformly distributed points onto a truncated ellipsoid. Applying the inverse of the ellipsoid’s scaling transformation to all parts of this problem (ellipsoid and incident ray) reduces this problem to the easier hemispherical/isotropic case.
An observation illustrated in Figure 9.28
can be used to further simplify this task: by applying the inverse of the
ellipsoid’s scaling transformation, the problem reduces to the simpler
isotropic case. For this, we must transform the incident direction to
the hemispherical configuration, perform a hemispherical sampling step, and
then re-transform the resulting points back to the ellipsoidal state. The
Sample_wm() method realizes this sequence of steps.
<>+=
Vector3f Sample_wm(Vector3f w, Point2f u) const { <<Transform w to hemispherical configuration>>
Vector3f wh = Normalize(Vector3f(alpha_x * w.x, alpha_y * w.y, w.z)); if (wh.z < 0) wh = -wh;
<<Find orthonormal basis for visible normal sampling>>
Vector3f T1 = (wh.z < 0.99999f) ? Normalize(Cross(Vector3f(0, 0, 1), wh)) : Vector3f(1, 0, 0); Vector3f T2 = Cross(wh, T1);
<<Generate uniformly distributed points on the unit disk>>
Point2f p = SampleUniformDiskPolar(u);
<<Warp hemispherical projection for visible normal sampling>>
Float h = std::sqrt(1 - Sqr(p.x)); p.y = Lerp((1 + wh.z) / 2, h, p.y);
<<Reproject to hemisphere and transform normal to ellipsoid configuration>>
Float pz = std::sqrt(std::max(0, 1 - LengthSquared(Vector2f(p)))); Vector3f nh = p.x * T1 + p.y * T2 + pz * wh; return Normalize(Vector3f(alpha_x * nh.x, alpha_y * nh.y, std::max(1e-6f, nh.z)));
}
The first transformation to the hemispherical configuration is accomplished by
applying the component-wise scaling factors and
to the incident direction
and renormalizing. By
convention, microfacet normals point into the upper hemisphere, and we
potentially flip the incident direction so that both directions are
consistently
oriented.
<>=
Vector3f wh = Normalize(Vector3f(alpha_x * w.x, alpha_y * w.y, w.z)); if (wh.z < 0) wh = -wh;
Next, we complete the unit vector to an orthonormal basis
(T1, T2, wh). The particular construction below satisfies
the additional constraint that T1 is perpendicular to the macroscopic
normal
.
<>=
Vector3f T1 = (wh.z < 0.99999f) ? Normalize(Cross(Vector3f(0, 0, 1), wh)) : Vector3f(1, 0, 0); Vector3f T2 = Cross(wh, T1);
Figure 9.29:
The perpendicular projection of a truncated hemisphere can be decomposed into
the projection of two half-disks highlighted in red and blue. The size and
shape of the projected tangential half-disk (blue) depends on the incident
direction and vanishes at grazing incidence.
Figure 9.29 illustrates the geometry of
the projection. When is perpendicularly incident (first column), the
hemisphere projects onto a disk. Non-perpendicular incidence (columns
2–4) reveals more interesting behavior: the bottom half that corresponds to the
perpendicular projection of the tangential half-disk (blue) undergoes a scaling
given by
along the vertical axis (i.e., the
T2 axis). Because the transformation is uniform, we can sample this set using
a vertical affine transformation of uniform points on the disk.
<>=
Point2f p = SampleUniformDiskPolar(u);
Let denote a point on the unit disk. For a given
,
the
-component lies on the interval
, where
specifies the
maximum height. Due to non-perpendicular projection, this interval must now be
reduced to
, which requires an affine transformation with
scale
and offset
. The following fragment efficiently performs
this transformation using the Lerp() function.
<>=
Float h = std::sqrt(1 - Sqr(p.x)); p.y = Lerp((1 + wh.z) / 2, h, p.y);
The last step projects the computed position onto the hemisphere and computes its 3D coordinates. Finally, it reapplies the ellipsoidal transformation and returns the result.
<>=
Float pz = std::sqrt(std::max(0, 1 - LengthSquared(Vector2f(p)))); Vector3f nh = p.x * T1 + p.y * T2 + pz * wh; return Normalize(Vector3f(alpha_x * nh.x, alpha_y * nh.y, std::max(1e-6f, nh.z)));
Note that it may seem that we should divide instead of multiplying by
and
to realize the inverse of the transformation from the
fragment <<Transform w to hemispherical configuration>>. This
ostensible blunder is explained by the property that normals transform
according to the inverse transpose of linear
transformations (Section 3.10.3).
9.6.5 The Torrance–Sparrow Model
We can finally explain how the ConductorBxDF handles rough microstructures via a BRDF model due to Torrance and Sparrow (1967). Instead of directly deriving their approach from first principles, we will instead explain how this model is sampled in pbrt, and then reverse-engineer the implied BRDF.
Combined with the visible normal sampling approach, the sampling routine of this model consists of three physically intuitive steps:
- Given a viewing ray from direction
, a microfacet normal
is sampled from the visible normal distribution
. This step encapsulates the process of intersecting the viewing ray with the random microstructure.
- Reflection from the sampled microfacet is modeled using the law of specular
reflection and the Fresnel equations, which yields the incident direction
and a reflection coefficient that attenuates the light carried by the path.
- The scattered light is finally scaled by
to account for the effect of masking by other microfacets.
Our goal will be to determine the BRDF that represents this sequence of
steps. For this, we must first find the probability density of the sampled
incident direction . Although visible normal sampling was involved, it is
important to note that
is not distributed according to the visible
normal distribution—to find its density, we must consider the sequence of
steps that were used to obtain
from
.
Taking stock of the available information, we know that the
probability density of is given by
,
and that
is obtained from
and
using the law of specular
reflection—that is,
(9.24)
This reflection mapping also has an inverse: the normal responsible for a specific reflection can be determined via
(9.25)
which is known as the half-angle or half-direction transform, as
it gives the unique direction vector that lies halfway between and
.
The Half-Direction Transform
Figure 9.30:
Microfacet normals, incident directions, and outgoing directions satisfy an interesting
geometric relationship. We hold the outgoing direction fixed and visualize the
set of microfacets (shaded in blue) that will yield a valid reflection from an
arc/cone of directions around the incident direction (shaded in green). In the
flatland setting shown in (a), the set of admissible microfacets is simply a
smaller arc. The 3D case is more complex and involves spherical
conic sections. In (b), with the center of the
cone aligned with
, the
admissible microfacets form a spherical circle.
(c) With a
angle between
and the central
direction, the microfacets form a spherical ellipse.
(d) A spherical hyperbola is the result with a
angle.
The Torrance–Sparrow model depends on the ratio of the surface area of these shaded
sets, which has a succinct analytic solution in the infinitesimally small
case.
Transitioning between half- and incident directions is effectively a change of
variables, and the Jacobian determinant of the
associated mapping enables the conversion of probability densities between
these two spaces.
The determinant is simple to find in flatland, as shown in
Figure 9.30(a). In the two-dimensional setting, the
half-direction mapping simplifies to
(9.26)
A slight perturbation of the incident angle (shaded green
region) while keeping
fixed requires a corresponding change
to the microfacet angle
(shaded blue region) to ensure that
the law of specular reflection continues to hold. However, this
perturbation to
is smaller—half as small, to be precise—which
directly follows from Equation (9.26). Indeed,
the derivative of Equation (9.26) yields
for the 2D case.
The 3D case initially appears challenging due to the varied behavior shown in
Figure 9.30(b–d). Fortunately, working with
infinitesimal sets leads to a simple analytic expression that can be derived by
expressing differential solid angles around and
using spherical
coordinates:
The expression can be simplified by noting that the law of specular reflection
implies and
in a spherical coordinate system oriented around
:
(9.27)
The resulting Jacobian determinant can be thus conveniently expressed in terms of the
microfacet normal and either or
.
Torrance–Sparrow PDF
With the relationship of Equation (9.27) at hand, we
are now able to evaluate the probability
per unit solid angle of the sampled incident directions obtained through the
combination of visible normal sampling and the reflection mapping:
(9.28)
where depends on
via the half-direction transform in
Equation (9.25). The following previously undefined
fragment incorporates these observations into ConductorBxDF::PDF().
<>=
Vector3f wm = wo + wi; if (LengthSquared(wm) == 0) return 0; wm = FaceForward(Normalize(wm), Normal3f(0, 0, 1)); return mfDistrib.PDF(wo, wm) / (4 * AbsDot(wo, wm));
The sign-related differences between equation and implementation ensure correct operation when the incident ray lies below the surface.
Torrance–Sparrow BRDF
The sampling routine of any BRDF model encodes a local strategy for importance sampling the scattering equation, (4.14). Here, we are dealing with an opaque surface, so the integral is only over the hemisphere. The single-sample Monte Carlo estimator is then
(9.29)
where denotes the sample’s probability per unit solid angle.
Recall our earlier introduction of the Torrance–Sparrow sampling routine as
a composition of physically intuitive steps: intersecting a ray against the
random microstructure via visible normal sampling, computation of via
the law of reflection, and attenuation of the incident radiance by the
Fresnel and masking factors. The radiance computed in this way should agree
with the Monte Carlo estimate from
Equation (9.29), which means that
must satisfy the identity
(9.30)
We will simply solve this equation to obtain . Further
substituting the PDF of the Torrance–Sparrow model from
Equation (9.28) yields the BRDF
(9.31)
Inserting the definition of the visible normal distribution from Equation (9.23) and assuming directions in the positive hemisphere results in the common form of the Torrance–Sparrow BRDF:
(9.32)
We will, however, make a small adjustment to the above expression:
Section 9.6.3 introduced a more accurate
bidirectional masking-shadowing factor that accounts for height
correlations on the microstructure. We use it to replace the product of
unidirectional
factors:
(9.33)
One of the nice things about the Torrance–Sparrow model is that the derivation
does not depend on the particular microfacet distribution being used.
Furthermore, it does not depend on a particular Fresnel function and can be
used for both conductors and dielectrics. However, the relationship between
and
used in the derivation does depend on the assumption of
specular reflection from microfacets, and the refractive variant of this model
will require suitable modifications.
Evaluating the terms of the Torrance–Sparrow BRDF is straightforward.
<>=
<<Compute cosines and for conductor BRDF>>
Float cosTheta_o = AbsCosTheta(wo), cosTheta_i = AbsCosTheta(wi); if (cosTheta_i == 0 || cosTheta_o == 0) return {}; Vector3f wm = wi + wo; if (LengthSquared(wm) == 0) return {}; wm = Normalize(wm);
<<Evaluate Fresnel factor F for conductor BRDF>>
SampledSpectrum F = FrComplex(AbsDot(wo, wm), eta, k);
return mfDistrib.D(wm) * F * mfDistrib.G(wo, wi) / (4 * cosTheta_i * cosTheta_o);
Incident and outgoing directions at glancing angles need to be handled explicitly to avoid the generation of NaN values:
<<Compute cosines and for conductor BRDF>>=
Float cosTheta_o = AbsCosTheta(wo), cosTheta_i = AbsCosTheta(wi); if (cosTheta_i == 0 || cosTheta_o == 0) return {}; Vector3f wm = wi + wo; if (LengthSquared(wm) == 0) return {}; wm = Normalize(wm);
Note that the Fresnel term is based on the angle of incidence relative to the
microfacet (i.e., ) rather than the macrosurface.
<>=
SampledSpectrum F = FrComplex(AbsDot(wo, wm), eta, k);
Torrance–Sparrow Sampling
The sampling procedure follows the sequence of steps outlined at the beginning
of this subsection. It first uses Sample_wm() to find a microfacet
orientation and reflects the outgoing direction about the microfacet’s normal
to find before evaluating the BRDF and density function.
<>=
<<Sample microfacet normal and reflected direction
>>
Vector3f wm = mfDistrib.Sample_wm(wo, u);
Vector3f wi = Reflect(wo, wm);
if ((wo, wi)) return {};
<>
Float pdf = mfDistrib.PDF(wo, wm) / (4 * AbsDot(wo, wm));
Float cosTheta_o = AbsCosTheta(wo), cosTheta_i = AbsCosTheta(wi); <<Evaluate Fresnel factor F for conductor BRDF>>
SampledSpectrum F = FrComplex(AbsDot(wo, wm), eta, k);
SampledSpectrum f = mfDistrib.D(wm) * F * mfDistrib.G(wo, wi) / (4 * cosTheta_i * cosTheta_o); return BSDFSample(f, wi, pdf, BxDFFlags::GlossyReflection);
A curious situation arises when the sampled microfacet normal leads to a computed direction that lies below the macroscopic surface. In a real microstructure, this would mean that light travels deeper into a crevice, to be scattered a second or third time. However, the presented ConductorBxDF only simulates a single interaction and thus marks such samples as invalid. This reveals one of the main flaws of the presented model: objects with significant roughness may appear too dark due to this lack of multiple scattering. Addressing issues related to energy loss is an active topic of research; see the “Further Reading” section for more information.
<<Sample microfacet normal and reflected direction
>>=
Vector3f wm = mfDistrib.Sample_wm(wo, u);
Vector3f wi = Reflect(wo, wm);
if ((wo, wi)) return {};
We omit the fragment <> that follows ConductorBxDF::PDF().
Visible normal sampling is still a relatively new development: for several
decades, microfacet models relied on sampling directly proportional to
the microfacet distribution, which tends to produce noisier renderings since
some terms of the BRDF are not sampled exactly.
Figure 9.31 compares this classical
approach to what is now implemented in pbrt.
Figure 9.31: Comparison of Microfacet Sampling Techniques.
The ground plane under the spheres has a metal material modeled using the
Torrance–Sparrow BRDF with a roughness of . Even with this
relatively smooth microsurface, (a) sampling the full microfacet
distribution
gives visibly higher error from unusable samples taken
from backfacing microfacets than (b) directly sampling the visible
microfacet distribution
.