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 omega Subscript normal m with respect to the surface normal  bold n Subscript . (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 normal d upper A Subscript . The corresponding microsurface normal d upper A Subscript mu is obtained by displacing the macrosurface along its normal bold n Subscript , which means that perpendicular projection of the microsurface exactly covers the macrosurface:

integral Underscript normal d upper A Subscript mu Baseline Endscripts left-parenthesis omega Subscript normal m Baseline left-parenthesis normal p right-parenthesis dot bold n Subscript Baseline right-parenthesis normal d normal p equals integral Underscript normal d upper A Subscript Baseline Endscripts normal d normal p comma

where omega Subscript normal m Baseline left-parenthesis normal p right-parenthesis specifies the microfacet normal at normal p . 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 upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis gives the relative differential area of microfacets with the surface normal omega Subscript normal m . For example, a perfectly smooth surface has a Dirac delta peak in the direction of the original surface normal—that is, upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis equals delta left-parenthesis omega Subscript normal m Baseline minus bold n Subscript Baseline right-parenthesis . The function is generally expressed in the standard reflection coordinate system with bold n Subscript Baseline equals left-parenthesis 0 comma 0 comma 1 right-parenthesis .

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.

integral Underscript script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis Endscripts upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis left-parenthesis omega Subscript normal m Baseline dot bold n Subscript Baseline right-parenthesis normal d omega Subscript normal m Baseline equals integral Underscript script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis Endscripts upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis cosine theta Subscript normal m Baseline normal d omega Subscript normal m Baseline equals 1 period

Figure 9.22: Given a differential area on a surface normal d upper A Subscript , the microfacet normal distribution function upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis must be normalized such that the projected surface area of the microfacets above the area is equal to normal d upper A Subscript .

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 omega Subscript normal m Baseline equals left-parenthesis theta Subscript normal m Baseline comma phi Subscript normal m Baseline right-parenthesis yields a distribution that only depends on the elevation angle theta Subscript normal m .

In contrast, an anisotropic microfacet distribution also depends on the azimuth phi Subscript normal m 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:

upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis equals StartFraction 1 Over pi alpha Subscript x Baseline alpha Subscript y Baseline cosine Superscript 4 Baseline theta Subscript normal m Baseline left-parenthesis 1 plus tangent squared theta Subscript normal m Baseline left-parenthesis StartFraction cosine squared phi Subscript normal m Baseline Over alpha Subscript x Superscript 2 Baseline EndFraction plus StartFraction sine squared phi Subscript normal m Baseline Over alpha Subscript y Superscript 2 Baseline EndFraction right-parenthesis right-parenthesis squared EndFraction period

This equation assumes that the semi-axes of the ellipsoid are aligned with the shading frame, and the reciprocals of the two variables 1 slash alpha Subscript x Baseline comma 1 slash alpha Subscript y Baseline greater-than 0 encode a scale transformation applied along the two tangential axes. When alpha Subscript x Baseline comma alpha Subscript y Baseline almost-equals 0 , 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., alpha Subscript x Baseline comma alpha Subscript y Baseline almost-equals 0.3 ), the ellipsoidal bumps introduce significant normal variation that blurs the directional distribution of reflected and transmitted light. When alpha Subscript x Baseline equals alpha Subscript y , 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 omega Subscript normal m approaches grazing configurations ( theta Subscript m Baseline right-arrow 90 Superscript ring ). 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 theta for alpha equals 0.5 . Note that Trowbridge–Reitz has higher tails at larger values of  theta .

The TrowbridgeReitzDistribution class encapsulates the state and functionality needed to use this microfacet distribution in a Monte Carlo renderer.

<<TrowbridgeReitzDistribution Definition>>= 
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>>  <<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<Float>(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<Float>(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 Public Methods>>= 
TrowbridgeReitzDistribution(Float alpha_x, Float alpha_y) : alpha_x(alpha_x), alpha_y(alpha_y) {}

<<TrowbridgeReitzDistribution Private Members>>= 
Float alpha_x, alpha_y;

The D() method is a fairly direct transcription of Equation (9.16) with some additional handling of numerical edge cases.

<<TrowbridgeReitzDistribution Public Methods>>+=  
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 alpha values for this case.

<<TrowbridgeReitzDistribution Public Methods>>+=  
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 bold n Subscript . The masking function upper G 1 left-parenthesis omega Subscript Baseline comma omega Subscript normal m Baseline right-parenthesis enables a generalization of this statement to other projection directions omega Subscript . We will shortly discuss how upper G 1 is derived and simply postulate its existence for now. The function specifies the fraction of microfacets with normal omega Subscript normal m that are visible from direction omega Subscript , and it therefore satisfies 0 less-than-or-equal-to upper G 1 left-parenthesis omega Subscript Baseline comma omega Subscript normal m Baseline right-parenthesis less-than-or-equal-to 1 for all arguments.

Figure 9.24: As seen from a viewer or a light source, a differential area on the surface has area normal d upper A Subscript Baseline cosine theta , where cosine theta is the angle of the incident direction with the surface normal. The projected surface area of visible microfacets (thick lines) must be equal to normal d upper A Subscript Baseline cosine theta as well; the masking function upper G 1 gives the fraction of the total microfacet area over normal d upper A Subscript 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 omega Subscript . A maximum is taken to ignore backfacing microfacets, and upper G 1 accounts for masking by other facets. The right hand side captures the relative size of the macrosurface, which shrinks by a factor of cosine theta .

integral Underscript script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis Endscripts upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis upper G 1 left-parenthesis omega Subscript Baseline comma omega Subscript normal m Baseline right-parenthesis max left-parenthesis 0 comma omega Subscript Baseline dot omega Subscript normal m Baseline right-parenthesis normal d omega Subscript normal m Baseline equals omega Subscript Baseline dot bold n Subscript Baseline equals cosine theta period

We expect that physically plausible combinations of microfacet distribution upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis (the Trowbridge–Reitz distribution in our case) and masking function upper G 1 left-parenthesis omega Subscript Baseline comma omega Subscript normal m Baseline right-parenthesis should satisfy this equation. Unfortunately, the microfacet distribution alone does not impose enough conditions to imply a specific upper G 1 left-parenthesis omega comma omega Subscript normal m Baseline right-parenthesis ; 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 omega Subscript normal m , except for the constraint that backfacing facets are ignored ( omega Subscript Baseline dot omega Subscript normal m Baseline greater-than 0 ). The masking term can then be moved out of the integral of Equation (9.17):

upper G 1 left-parenthesis omega Subscript Baseline right-parenthesis integral Underscript script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis Endscripts upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis max left-parenthesis 0 comma omega Subscript Baseline dot omega Subscript normal m Baseline right-parenthesis normal d omega Subscript normal m Baseline equals cosine theta comma

which can be rearranged to solve for upper G 1 left-parenthesis omega Subscript Baseline right-parenthesis :

upper G 1 left-parenthesis omega Subscript Baseline right-parenthesis equals StartFraction cosine theta Over integral Underscript script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis Endscripts upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis max left-parenthesis 0 comma omega Subscript Baseline dot omega Subscript normal m Baseline right-parenthesis normal d omega Subscript normal m Baseline EndFraction period

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 upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis , including the Trowbridge–Reitz model. In practice, the masking function is often expressed in terms of an auxiliary function normal upper Lamda left-parenthesis omega Subscript Baseline right-parenthesis 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 upper G 1 and normal upper Lamda as follows:

upper G 1 left-parenthesis omega Subscript Baseline right-parenthesis equals StartFraction 1 Over 1 plus normal upper Lamda left-parenthesis omega Subscript Baseline right-parenthesis EndFraction period

The Lambda() method computes this function.

<<TrowbridgeReitzDistribution Public Methods>>+=  
Float G1(Vector3f w) const { return 1 / (1 + Lambda(w)); }

Under the uncorrelated height assumption, normal upper Lamda left-parenthesis omega Subscript Baseline right-parenthesis has the following analytic solution for the Trowbridge–Reitz distribution:

normal upper Lamda left-parenthesis omega Subscript Baseline right-parenthesis equals StartFraction StartRoot 1 plus alpha squared tangent squared theta EndRoot minus 1 Over 2 EndFraction comma

where alpha denotes the isotropic surface roughness. An anisotropic generalization follows from the observation that anisotropy implies tangential scaling of the microsurface based on 1 slash alpha Subscript x and 1 slash alpha Subscript y . A 1-dimensional ray omega Subscript that is not aligned with the x - or y -axis will observe a different scaling amount that lies between these extremes. The associated interpolated roughness is given by

alpha equals StartRoot alpha Subscript x Superscript 2 Baseline cosine squared phi plus alpha Subscript y Superscript 2 Baseline sine squared phi EndRoot period

Anisotropic masking reuses the isotropic normal upper Lamda with this definition of alpha . 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.

<<TrowbridgeReitzDistribution Public Methods>>+=  
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 upper G 1 left-parenthesis omega Subscript Baseline right-parenthesis function for a few values of alpha . 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 alpha ) causes the function to fall off more quickly.

Figure 9.26: The Masking Function upper G 1 left-parenthesis omega Subscript Baseline right-parenthesis for the Trowbridge–Reitz Distribution. Increasing surface roughness (higher alpha 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 upper G 1 must be generalized into a masking-shadowing function upper G that gives the fraction of microfacets in a differential area that are simultaneously visible from both directions omega Subscript normal o and omega Subscript normal i .

We know that upper G 1 left-parenthesis omega Subscript normal o Baseline right-parenthesis gives the fraction of microfacets that are visible from the direction omega Subscript normal o , and upper G 1 left-parenthesis omega Subscript normal i Baseline right-parenthesis gives the fraction for omega Subscript normal i . If we assume that masking and shadowing are statistically independent events, then these probabilities can simply be multiplied together:

upper G left-parenthesis omega Subscript normal o Baseline comma omega Subscript normal i Baseline right-parenthesis equals upper G 1 left-parenthesis omega Subscript normal o Baseline right-parenthesis upper G 1 left-parenthesis omega Subscript normal i Baseline right-parenthesis period

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 omega Subscript normal i and omega Subscript normal o . If the heights of microfacets are normally distributed, a less conservative model for upper G taking height-based correlation into account can be derived:

upper G left-parenthesis omega Subscript normal o Baseline comma omega Subscript normal i Baseline right-parenthesis equals StartFraction 1 Over 1 plus normal upper Lamda left-parenthesis omega Subscript normal o Baseline right-parenthesis plus normal upper Lamda left-parenthesis omega Subscript normal i Baseline right-parenthesis EndFraction period

The bidirectional form of upper G implements this equation based on the previously defined Lambda() function.

<<TrowbridgeReitzDistribution Public Methods>>+=  
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 omega Subscript with elevation angle theta :

integral Underscript script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis Endscripts upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis upper G 1 left-parenthesis omega Subscript Baseline right-parenthesis max left-parenthesis 0 comma omega Subscript Baseline dot omega Subscript normal m Baseline right-parenthesis normal d omega Subscript normal m Baseline equals cosine theta period

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 cosine theta , the integral on the left hand side equals one—in other words, it turns into a normalized density upper D Subscript omega Sub Subscript Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis that we shall refer to as the distribution of visible normals:

upper D Subscript omega Sub Subscript Subscript Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis equals StartFraction upper G 1 left-parenthesis omega Subscript Baseline right-parenthesis Over cosine theta EndFraction upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis max left-parenthesis 0 comma omega Subscript Baseline dot omega Subscript normal m Baseline right-parenthesis period

It describes the projected area of forward-facing normals, where the first term involving the masking function specifies an omega Subscript -dependent normalization factor. The method D() evaluates this density function.

<<TrowbridgeReitzDistribution Public Methods>>+=  
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 omega Subscript normal m 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.

<<TrowbridgeReitzDistribution Public Methods>>+=  
Float PDF(Vector3f w, Vector3f wm) const { return D(w, wm); }

Figure 9.27: Sampling the distribution of visible normals upper D Subscript omega Sub Subscript Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis 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 omega onto its surface. The resulting normal directions omega Subscript normal m will then be distributed according to the density function upper D Subscript omega Sub Subscript Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis .

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 omega Subscript 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.

<<TrowbridgeReitzDistribution Public Methods>>+=  
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>>  <<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<Float>(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<Float>(1e-6f, nh.z)));
}

The first transformation to the hemispherical configuration is accomplished by applying the component-wise scaling factors alpha Subscript x and alpha Subscript y to the incident direction omega Subscript 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.

<<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;

Next, we complete the unit vector monospace w monospace h to an orthonormal basis (T1, T2, wh). The particular construction below satisfies the additional constraint that T1 is perpendicular to the macroscopic normal left-parenthesis 0 comma 0 comma 1 right-parenthesis .

<<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);

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 omega Subscript and vanishes at grazing incidence.

Figure 9.29 illustrates the geometry of the projection. When omega Subscript 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 cosine theta equals omega Subscript Baseline dot bold n Subscript 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.

<<Generate uniformly distributed points on the unit disk>>= 

Let p equals left-parenthesis x comma y right-parenthesis denote a point on the unit disk. For a given x element-of left-bracket negative 1 comma 1 right-bracket , the y -component lies on the interval left-bracket negative h comma h right-bracket , where h equals StartRoot 1 minus x squared EndRoot specifies the maximum height. Due to non-perpendicular projection, this interval must now be reduced to left-bracket minus h cosine theta comma h right-bracket , which requires an affine transformation with scale one-half left-parenthesis 1 plus cosine theta right-parenthesis and offset StartFraction h Over 2 EndFraction left-parenthesis 1 minus cosine theta right-parenthesis . The following fragment efficiently performs this transformation using the Lerp() function.

<<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);

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.

<<Reproject to hemisphere and transform normal to ellipsoid configuration>>= 
Float pz = std::sqrt(std::max<Float>(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<Float>(1e-6f, nh.z)));

Note that it may seem that we should divide instead of multiplying by alpha Subscript x and alpha Subscript y 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:

  1. Given a viewing ray from direction omega Subscript normal o , a microfacet normal omega Subscript normal m is sampled from the visible normal distribution upper D Subscript omega Sub Subscript normal o Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis . This step encapsulates the process of intersecting the viewing ray with the random microstructure.
  2. Reflection from the sampled microfacet is modeled using the law of specular reflection and the Fresnel equations, which yields the incident direction omega Subscript normal i and a reflection coefficient that attenuates the light carried by the path.
  3. The scattered light is finally scaled by upper G 1 left-parenthesis omega Subscript normal i Baseline right-parenthesis 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 omega Subscript normal i . Although visible normal sampling was involved, it is important to note that omega Subscript normal i 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 omega Subscript normal i from omega Subscript normal m .

Taking stock of the available information, we know that the probability density of omega Subscript normal m is given by upper D Subscript omega Sub Subscript normal o Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis , and that omega Subscript normal i is obtained from omega Subscript normal m and omega Subscript normal o using the law of specular reflection—that is,

omega Subscript normal r Baseline equals minus omega Subscript normal o Baseline plus 2 left-parenthesis omega Subscript normal m Baseline dot omega Subscript normal o Baseline right-parenthesis omega Subscript normal m Baseline period

This reflection mapping also has an inverse: the normal responsible for a specific reflection can be determined via

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

which is known as the half-angle or half-direction transform, as it gives the unique direction vector that lies halfway between omega Subscript normal i and omega Subscript normal o .

The Half-Direction Transform

Figure 9.30: Microfacet normals, incident directions, and outgoing directions satisfy an interesting geometric relationship. We hold the outgoing direction omega Subscript normal o 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 omega Subscript normal i cone aligned with omega Subscript normal o , the admissible microfacets form a spherical circle. (c) With a 140 Superscript ring angle between omega Subscript normal o and the central omega Subscript normal i direction, the microfacets form a spherical ellipse. (d) A spherical hyperbola is the result with a 170 Superscript ring 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 normal d omega Subscript normal i slash normal d omega Subscript normal m 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

theta Subscript normal m Baseline equals StartFraction theta Subscript normal o Baseline plus theta Subscript normal i Baseline Over 2 EndFraction period

A slight perturbation of the incident angle theta Subscript normal i (shaded green region) while keeping theta Subscript normal o fixed requires a corresponding change to the microfacet angle theta Subscript normal m (shaded blue region) to ensure that the law of specular reflection continues to hold. However, this perturbation to theta Subscript normal m is smaller—half as small, to be precise—which directly follows from Equation (9.26). Indeed, the derivative of Equation (9.26) yields normal d theta Subscript normal m Baseline slash normal d theta Subscript normal i Baseline equals 1 slash 2 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 omega Subscript normal m and omega Subscript normal r using spherical coordinates:

StartFraction normal d omega Subscript normal m Baseline Over normal d omega Subscript normal i Baseline EndFraction equals StartFraction sine theta Subscript normal m Baseline normal d theta Subscript normal m Baseline normal d phi Subscript normal m Baseline Over sine theta Subscript normal i Baseline normal d theta Subscript normal i Baseline normal d phi Subscript normal i Baseline EndFraction period

The expression can be simplified by noting that the law of specular reflection implies theta Subscript normal i Baseline equals 2 theta Subscript normal m and phi Subscript normal i Baseline equals phi Subscript normal m in a spherical coordinate system oriented around omega Subscript normal o :

StartLayout 1st Row 1st Column StartFraction normal d omega Subscript normal m Baseline Over normal d omega Subscript normal i Baseline EndFraction 2nd Column equals StartFraction sine theta Subscript normal m Baseline normal d theta Subscript normal m Baseline normal d phi Subscript normal m Baseline Over sine 2 theta Subscript normal m Baseline 2 normal d theta Subscript normal m Baseline normal d phi Subscript normal m Baseline EndFraction 2nd Row 1st Column Blank 2nd Column equals StartFraction sine theta Subscript normal m Baseline Over 4 cosine theta Subscript normal m Baseline sine theta Subscript normal m Baseline EndFraction 3rd Row 1st Column Blank 2nd Column equals StartFraction 1 Over 4 cosine theta Subscript normal m Baseline EndFraction 4th Row 1st Column Blank 2nd Column equals StartFraction 1 Over 4 left-parenthesis omega Subscript normal i Baseline dot omega Subscript normal m Baseline right-parenthesis EndFraction equals StartFraction 1 Over 4 left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis EndFraction period EndLayout

The resulting Jacobian determinant can be thus conveniently expressed in terms of the microfacet normal and either omega Subscript normal i or omega Subscript normal o .

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 omega Subscript normal i obtained through the combination of visible normal sampling and the reflection mapping:

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 Over 4 left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis EndFraction comma

where omega Subscript normal m depends on omega Subscript normal i via the half-direction transform in Equation (9.25). The following previously undefined fragment incorporates these observations into ConductorBxDF::PDF().

<<Evaluate sampling PDF of rough conductor BRDF>>= 
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

StartLayout 1st Row 1st Column upper L Subscript normal o Superscript Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript normal o Baseline right-parenthesis 2nd Column equals integral Underscript script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis Endscripts f Subscript normal r 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 normal d omega Subscript normal i Baseline 2nd Row 1st Column Blank 2nd Column almost-equals StartFraction f Subscript normal r 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 comma EndLayout

where p left-parenthesis omega Subscript normal i Baseline right-parenthesis 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 omega Subscript normal i 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 f Subscript normal r must satisfy the identity

StartFraction f Subscript normal r 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 upper F left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline 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

We will simply solve this equation to obtain f Subscript normal r Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript normal o Baseline comma omega Subscript normal i Baseline right-parenthesis . Further substituting the PDF of the Torrance–Sparrow model from Equation (9.28) yields the BRDF

f Subscript normal r 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 upper F left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis upper G 1 left-parenthesis omega Subscript normal i Baseline right-parenthesis Over 4 left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis StartAbsoluteValue cosine theta Subscript normal i Baseline EndAbsoluteValue EndFraction period

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:

f Subscript normal r 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 upper F left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis upper G 1 left-parenthesis omega Subscript normal i Baseline right-parenthesis upper G 1 left-parenthesis omega Subscript normal o Baseline right-parenthesis Over 4 cosine theta Subscript normal i Baseline cosine theta Subscript normal o Baseline EndFraction period

We will, however, make a small adjustment to the above expression: Section 9.6.3 introduced a more accurate bidirectional masking-shadowing factor upper G that accounts for height correlations on the microstructure. We use it to replace the product of unidirectional upper G 1 factors:

f Subscript normal r 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 upper F left-parenthesis omega Subscript normal o Baseline dot omega Subscript normal m Baseline right-parenthesis upper G left-parenthesis omega Subscript normal i Baseline comma omega Subscript normal o Baseline right-parenthesis Over 4 cosine theta Subscript normal i Baseline cosine theta Subscript normal o Baseline EndFraction period

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 normal d omega Subscript normal m and normal d omega Subscript normal o 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.

<<Evaluate rough conductor BRDF>>= 
<<Compute cosines and omega Subscript normal m 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 omega Subscript normal m 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., omega Subscript normal o Baseline dot omega Subscript normal m ) rather than the macrosurface.

<<Evaluate Fresnel factor F for conductor BRDF>>= 
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 omega Subscript normal i before evaluating the BRDF and density function.

<<Sample rough conductor BRDF>>= 
<<Sample microfacet normal omega Subscript normal m and reflected direction omega Subscript normal i >> 
Vector3f wm = mfDistrib.Sample_wm(wo, u); Vector3f wi = Reflect(wo, wm); if (!SameHemisphere(wo, wi)) return {};
<<Compute PDF of wi for microfacet reflection>> 
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 omega Subscript normal m and reflected direction omega Subscript normal i >>= 
Vector3f wm = mfDistrib.Sample_wm(wo, u); Vector3f wi = Reflect(wo, wm); if (!SameHemisphere(wo, wi)) return {};

We omit the fragment <<Compute PDF of wi for microfacet reflection>> that follows ConductorBxDF::PDF().

Visible normal sampling is still a relatively new development: for several decades, microfacet models relied on sampling omega Subscript normal m 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 alpha equals 0.01 . Even with this relatively smooth microsurface, (a) sampling the full microfacet distribution upper D left-parenthesis omega Subscript normal m Baseline right-parenthesis gives visibly higher error from unusable samples taken from backfacing microfacets than (b) directly sampling the visible microfacet distribution upper D Subscript omega Sub Subscript normal o Baseline left-parenthesis omega Subscript normal m Baseline right-parenthesis .