Graphics Reference
In-Depth Information
Listing 14.8: The finite direct evaluation portion of a simple Lambertian BSDF
for surfaces such as walls covered in matte paint.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class
LambertianBSDF :
public
BSDF
{
private
:
// Each element on [0, 1]
Color3
k_L;
public
:
virtual
Color3
evaluateFiniteScatteringDensity
(
const
Vector3
& wi,
const
Vector3
& wo)
const
{
if
((wi.dot(cframe.rotation.getColumn(1)) > 0) &&
(wo.dot(cframe.rotation.getColumn(1)) > 0)) {
return
k_L / PI;
}
else {
return
Color3
::zero();
}
}
...
};
. That geo-
metric factor must be accounted for by the renderer, as shown in Listing 14.11. We
divide
k
L
by
Note that there is no projected area factor in
f
s
(
P
,
v
i
,
v
o
)=
k
L
/π
because the integral of the BSDF times the cosine of the angle of
incidence must be less than one over the entire hemisphere above a planar surface
π
to ensure energy conservation, and
S
+
(
.
Because Lambertian appearance arises from well-diffused light, Lambertian
reflectance is also called diffuse or perfectly diffuse reflection. We use the term
“diffuse” to describe all nonspecular behavior.
v
·
z
)
d
=
π
v
Phong introduced the phenomenological shading model [Pho75] described in
Chapter 6. His model describes a surface that exhibits Lambertian reflection with
a glossy highlight of adjustable sharpness.
The original Phong model has been reformulated as a BSDF and then extended
by many practitioners. The currently preferred form remains phenomenologically
based but has some basic properties that are desirable in a scattering model; for
example, it conserves energy and obeys the projected area property. For a richer
explanation of scattering models see Chapter 27. We simply present the model
here in a form suitable for implementation.
This is the modern formalization, in terms of physical units, of the model
that was described in Chapter 6. The replacement of
C
d
and
C
s
with
k
L
and
k
g
is
appropriate for three reasons. First, “Lambertian” is a more specific name for the
shape of the “diffuse” distribution; anything that isn't an impulse is “diffuse,” but
Phong prescribes a specific and geometrically well-founded Lambertian distribu-
tion for that term. Second, we've defined “specular” as a technical term for a mir-
ror impulse, following its English definition and physics terminology, reserving
“glossy” to denote reflection that's somewhat or very concentrated in a particular
direction. Third, this formulation is different from the original in both parameters
and form. These
k
parameters are no longer potentially ambiguous RGB triples