i
i
i
i
i
i
i
i
266 7. Advanced Shading
One model that was designed to be used in a multiple-term fitting process
is the Lafortune BRDF [710], which generalizes the calculation of the re-
flection vector used in the original Phong model [1014]. This generalization
enables the modeling of retroreflective and anisotropic surfaces. McAllister
et al. used multiple Lafortune terms to render SVBRDFs in real time on a
GPU [830, 831].
Ngan et al. [926] perform a detailed analysis of the errors introduced by
fitting various measured materials to a selection of analytic BRDF models.
For isotropic materials, Ward and Blinn-Phong BRDFs have the highest
errors, most likely due to their lack of a Fresnel term (the original form of
the Blinn-Phong BRDF was used, which does not have a Fresnel term). The
Lafortune BRDF also has fairly high errors, evidently due to the fact that
it is derived from a reflection-vector-based BRDF and shares the problems
of that class of BRDF models (see Section 7.5.7). The best results are
achieved with the HTSG, Cook-Torrance, and Ashikhmin-Shirley BRDFs.
About a third of the measured materials gained significant accuracy from
the addition of a second lobe of the same type—one lobe was sufficient for
the remainder.
Ngan et al. also analyzed several anisotropic materials. Only the Ward
[1326] and Poulin-Fournier [1027] BRDFs were used for fitting. Both of
them did moderately well on surfaces with simple anisotropic reflectance.
Surfaces such as fabrics with complex, periodic microgeometry structure
were not modeled well by any of the analytic BRDFs. For those materials,
Ngan adopted an interesting semi-analytic fitting approach; an arbitrary
microfacet distribution was deduced from the measurements, and then a
BRDF was generated from the microfacet distribution, using the method
introduced by Ashikhmin et al. [41]. This approach resulted in very good
matches to the measured data.
Ashikhmin and Premoˇze propose [46] a distribution-based BRDF model
that allows for extremely simple BRDF acquisition. A single image of
a sample with known, curved geometry (taken with the light source and
camera positions close to each other) can suffice to capture many materials.
Another way to represent BRDFs is to project them onto orthonor-
mal bases, such as spherical harmonics [1344], spherical wavelets [180, 715,
1135], or Zernike Polynomials [681]. These techniques are focused on rep-
resenting the shape of the BRDF as a generic function. Look again at
Figure 7.17: For a given incoming direction, a surface is formed that rep-
resents the reflectance at any outgoing direction. The BRDF surface is
generally changing in a smooth fashion, with few places where it changes
rapidly. This implies that a sum of a few low- and high-frequency functions
can capture the BRDF shape. Such projections are simpler to perform than
fitting to a BRDF or sum of BRDF terms, as no optimization process is
needed. However, many terms are usually needed to achieve a reasonable
i
i
i
i
i
i
i
i
7.7. BRDF Acquisition and Representation 267
Figure 7.42. Factorization of a BRDF for gold, using the Cook-Torrance surface
model [192]. The two textures are accessed with the incoming light and outgoing view
directions, respectively, and are multiplied together at each pixel to generate the teapot’s
illumination. (Images courtesy of NVIDIA Corporation.)
match to the original function (dozens or hundreds), making these methods
unsuitable for real-time rendering. Section 8.6.1 discusses basis projection
in more detail.
As four-dimensional functions, BRDFs can also be approximated, or
factored, into a sum of products of lower-dimensional functions. If these
functions are one or two dimensional, they can be stored in textures, making
this type of representation amenable to rendering on graphics hardware (al-
though graphics hardware can use volume textures, the storage cost tends
to be too high to be reasonable). In practice, it has been found that a single
pair of two-dimensional textures is sufficient to give reasonably convincing
results for many materials [625]. See Figure 7.42 for an example. The
basic factorization algorithm and its implementation are explained thor-
oughly and clearly by Kautz et al. [631] and Wynn [1389]. We recommend
these articles and the related source code to interested readers. McCool
et al. [835] present a newer factorization technique with some advantages
over the basic factorization algorithm, and also provide code.
The parameterization of the lower-dimensional functions (and thus the
set of values used as coordinates to look up the factored textures when
rendering) needs to be chosen with care so as to minimize the number of
functions needed. A naive parameterization would use the azimuth and
elevation angles θ
i
and φ
i
of the incoming light direction as the u and v
coordinates of one texture, and the angles θ
o
and φ
o
of the outgoing view
direction as the u and v coordinates of the second. In practice, such a
parameterization would yield a poor factorization, requiring a large num-
ber of texture pairs to be summed to approximate the BRDF. Finding a
good re-parameterization is not trivial and may depend on the material.
Rusinkiewicz suggested a parameterization based on the azimuth and ele-
vation angles of the half vector h and the incoming light vector l (l’s angles
measured relatively to h) [1090]. This parameterization is naturally aligned
i
i
i
i
i
i
i
i
268 7. Advanced Shading
Figure 7.43. Materials rendered using factorization [835], where the BRDF is approxi-
mated by pairs of two-dimensional textures. From left to right, the materials are a blue
Krylon latex enamel, satin, and a textured velvet body with garnet red paint on the knot
shape. The paints and velvet are from measured BRDF data [190, 200], and the satin
is computed using the analytic Poulin-Fournier anisotropic reflectance model [1027].
(Images generated by the “brdfview” program by McCool, Ang, and Ahmad.)
to the behavior of real-world surfaces and the features of common analytic
BRDFs. Other parameterizations (also based on the half vector, but in dif-
ferent ways) are suggested by Stark et al. [1217] and Edwards et al. [298].
If the quantities used as texture coordinates are to be interpolated, this
imposes additional conditions on the parameterization. For example, the
Rusinkiewicz parameterization does not interpolate well—Kautz et al. [625]
suggest several alternatives that do. This is not a concern if the quantities
are to be computed in the pixel shader. Once the parameterization has
been selected, the measured BRDF data can be factored (a fairly time-
consuming process). See Figure 7.43 for some results.
These factorization techniques have two limitations that may be prob-
lematic for most applications: They are not suitable for measured
SVBRDFS, since a separate factorization process needs to be performed
for each location, and the results cannot easily be edited. A recent pa-
per by Lawrence et al. [740] addresses both of these limitations. Their
method works directly on captured SVBRDF data, decomposing it into a
series of one- or two-dimensional textures. These textures are defined so
as to be suitable for editing. A shade tree is created to combine the tex-
tures and produce the final shaded pixel color. At the top level of the shade
tree, weight textures control the mixing of several basis BRDFs. Each basis
BRDF is decomposed into terms such as specular and diffuse, and each term
is further decomposed using Rusinkiewicz’s parameterization [1090]. The
bottom level nodes are editable one-dimensional curves or two-dimensional
maps. The curves control such aspects of the reflectance as isotropic NDFs
and color shifts at glancing angles. The two-dimensional maps are used
for anisotropic NDFs. The weight textures can also be edited, changing
the spatial distribution of the basis BRDFs. This paper is recommended
reading to anyone who needs to render scenes with acquired SVBRDFs.
Basis projections and factorizations have been discussed as represen-
tations for measured BRDFs. They could in theory be used for analytic
i
i
i
i
i
i
i
i
7.8. Implementing BRDFs 269
BRDF models as well, perhaps to save computation. In practice, the falling
cost of computation versus the cost of texture lookups on modern hardware,
combined with the many advantages of parametric BRDF representations,
makes this technique unpopular.
7.8 Implementing BRDFs
To incorporate a BRDF model in a rendering system, the BRDF needs
to be evaluated as part of a shading equation. The purpose of a shading
equation is to compute the outgoing radiance L
o
from a surface location
into the view direction v. Given a set of n point or directional light sources,
the outgoing radiance is computed thus (repeating Equation 7.21):
L
o
(v)=
n
k=1
f(l
k
, v) E
L
k
cos θ
i
k
.
The cosine factor is computed as the clamped dot product between the
surface normal and the kth light direction vector:
cos θ
i
k
=max(n · l
k
, 0). (7.61)
Various methods for computing the value of E
L
k
were discussed in Sec-
tion 7.4. The computation of the BRDF value f(l
k
, v) remains in order to
complete the evaluation of the shading equation.
As we have seen, most BRDFs contain a 1 factor. In many rendering
systems, this factor is folded into E
L
for convenience. When adapting a
radiometrically defined BRDF (such as can be found in academic papers,
or in Section 7.6 of this book) for use in such a rendering system, care must
be taken to multiply the BRDF by π.
The most straightforward way to evaluate any BRDF model that has
an analytic expression, as opposed to being represented by a factorization
or a sum of basis functions, is to simply evaluate the expression in a shader
for each light source (see Equation 7.21 on page 224). Evaluating the full
expression in the pixel shader will give the best visual results, but in some
cases slowly varying subexpressions can be evaluated in the vertex shader
and interpolated. For spatially varying BRDFs, a common approach is to
encode BRDF parameters in textures (see Section 6.5), although in some
cases it might make sense to store them in vertices instead. Since evaluation
of dot products is efficient on graphics hardware, BRDFs intended for real-
time use are usually formulated in terms of cosines of angles between vectors
such as the incoming light vector l, view vector v, half vector h,surface
normal n, tangent t, or bitangent b. If both vectors are of length 1, the
dot product is equal to the cosine of the angle between the vectors.
i
i
i
i
i
i
i
i
270 7. Advanced Shading
In principle, BRDF equations apply in the local frame of the surface
defined by the vectors n, t,andb. In practice, they can be evaluated in
any coordinate system (or more than one) as long as care is taken never
to perform an operation between vectors in different coordinate systems.
Per-pixel BRDF evaluation is often combined with normal mapping. In
principle, normal mapping perturbs the entire local frame, not just the
normal. Isotropic BRDFs rarely require tangent or bitangent vectors, so
perturbing the normal vector is sufficient. When shading with anisotropic
BRDFs, it is important to perturb any tangent or bitangent vectors used.
Anisotropic BRDFs introduce the possibility of per-pixel modification of
the tangent direction—use of textures to perturb both the normal and
tangent vectors is called frame mapping [618]. Frame mapping can enable
effects such as brushed swirls on metal or curly hair.
Some BRDFs are defined as a combination of subexpressions defined
analytically and subexpressions defined by values stored in one- or two-
dimensional data tables (see Section 7.6). These semi-analytic BRDFs are
computed much like fully analytic BRDFs, but with the addition of texture
lookups for the tabulated subexpressions.
Even for fully analytically defined BRDFs, there might be a perfor-
mance benefit in extracting a subexpression that is a function of one or two
variables and tabulating its values in a texture for lookup while rendering.
In the past, when computation was costly relative to texture lookups, this
was a very common practice. Now computation is relatively cheap—a rule
of thumb in 2007 was that one texture operation is equivalent to ten arith-
metic operations (or more).
20
This number will keep growing as graphics
hardware evolves [1400]. Only the most complex subexpressions will ben-
efit from being factored into a texture. To avoid losing the parametric
qualities of the BRDF, it is preferable for factored subexpressions to be
independent of the BRDF’s parameters.
BRDFs using non-parametric representations are more difficult to ren-
der efficiently. In the case of BRDFs defined as an orthonormal expansion
of bases such as spherical harmonics, rendering is straightforward—just
evaluate the basis functions—but due to the large number of coefficients
computation is likely to be expensive. More importantly, if the BRDF is
spatially varying, then a very large number of texture reads is needed to
read all of the coefficients, further reducing performance.
BRDFs that use factored representations are easier to render, since a
relatively small number of textures are read (usually two). Inverse Shade
Trees [740] use a larger number of textures (about twenty for the examples
given) but most of them are one dimensional. This is still well within
the capabilities of modern accelerators, but the large number of texture
20
This holds true for an NVIDIA G80, and it is likely that ATI is similar.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset