Chapter25.pdf

(880 KB) Pobierz
25
Glossy Refl ection
25.1 Modeling
25.2 Implementation
25.3 Results
Objectives
By the end of this chapter, you should:
• understand what glossy refl ection is;
• understand how it can be modeled in ray tracing;
• have implemented glossy refl ection in your ray tracer;
• have more tools to produce nice images.
In this chapter, you will learn how to render glossy refl ections. Many real
materials are imperfect refl ectors, where the refl ections are blurred to various
degrees due to surface roughness that sca ers the incident radiance. The use
of glossy refl ections will allow us to remove the main inconsistency discussed
in Section 24.4 by treating specular highlights and refl ections in a consistent
manner. Figure 25.1 is a photograph of three glossy spheres.
25.1 Modeling
Consider a ray that hits a surface from the direction ω o and its associated direc-
tion of mirror refl ection r , as illustrated in Figure 25.2. We can simulate glossy
refl ection by choosing a random direction for the refl ected ray instead of using
529
979355824.194.png 979355824.205.png 979355824.216.png 979355824.227.png 979355824.001.png 979355824.012.png 979355824.023.png 979355824.034.png
530
25. Glossy Refl ection
Figure 25.1. Glossy spheres. Photograph by Kevin Suff ern.
n
the direction of mirror refl ection, but how do we choose the
direction? To make the simulation consistent with the specular-
highlights model in Chapter 15, we should use the same cosine
power formula. The density d in solid angle of the refl ected rays
around the mirror refl ection direction r is then given by
i
o
r
r
θ r ) e ,
d = (cos
(25.1)
p
θ r is the angle between r and ω i and e is the specular
exponent.
A suitable BRDF for this purpose is
where
surface
Figure 25.2. The refl ected ray
direction ω i makes an angle
θ r
with the direction of mirror
refl ection r .
θ r ) e = c k r c r ( r ω i ) e ,
f r,s ( p , ω i , ω o ) = c k r c r cos(
(25.2)
where c is a normalization constant. This constant is proportional to e + 1, so
that c
as e . It expresses the fact that as e increases, the BRDF (25.2)
becomes more concentrated around the direction of mirror refl ection. In the
limit e = , the BRDF becomes a delta function.
Substituting Equation (25.2) into (24.1) gives the following expression for
the refl ected radiance in the ω o direction:
( ) ((, , )cos .
e
L
(, )
p
=
ck
c
r
L
r p
θω
d
(25.3)
o
indirect
r
r
i
o
c
i
i
i
i
+
2
π
Because there are no delta functions in this integrand, we have to estimate its
value using Monte Carlo integration. The estimator is
n
e
s
ck
n
c
( •)
ω
r
L
(
r p
(
,
ω
),
ω
)s
θ
(25.4)
1
i
,
j
o
c
i
,
j
i
,
j
i
,
j
rr
L
(, )
p
ω
=
.
r
o
p
(
ω i
)
s
,
j
j
979355824.045.png 979355824.056.png 979355824.067.png 979355824.078.png 979355824.089.png 979355824.100.png 979355824.111.png 979355824.122.png 979355824.133.png 979355824.144.png 979355824.155.png 979355824.160.png 979355824.161.png 979355824.162.png 979355824.163.png 979355824.164.png
 
25.1 Modeling
531
In this expression, the measure of the pdf is solid angle in the hemisphere at
p . Because the choice of pdf determines the directions of the rays shot into the
hemisphere, to use the distribution (25.1), the pdf should be proportional to
the BRDF; that is,
( r ω i ) e .
p ( ω i, j )
(25.5)
A problem with this approach is that it ignores the cos
i term in Equation (25.3).
If we want the glossy refl ection to be consistent with perfect specular refl ection
in the limit e
θ
, we need to get rid of this term. One way would be to make
p ( ω i, j ) proportional to the product of the BRDF and cos
θ
i = n ω i :
p ( ω i, j ) ∝ ( r ω i ) e ( n ω i ),
but then the ray directions should also be derived from this product.
Unfortunately, that’s diffi cult to do. In spite of not being able to sample this
correctly, I’ll still use it with
p ( ω i, j ) ∝ c ( r ω i ) e ( n ω i ),
(25.6)
but I’ll keep the distribution (25.1) for the ray directions. With this pdf, the
BRDF normalization constant c cancels. The inconsistency in the pdf (25.6) and
the ray direction distribution approaches zero as e
.
With this choice of pdf, the estimator (25.4) simplifi es to
n
s
k
n
c
(25.7)
1
rr
s
L
(, )
p
=
L
((, , ,
rp
r
o
oc i
,
j
i
,
j
j
where each randomly refl ected ray is treated in the same way as perfect
mirror refl ection was treated in Chapter 24. The only source of noise in
Equation (25.7) is variations in the radiance returned by the refl ected rays.
This model has k s , c s , and e as parameters and, as you will see, produces nice
blurred refl ections that approach perfect mirrors as e
. Physically based
models of glossy refl ection are much more complex (see the Further Reading
section).
Figure 25.3 shows the plane through the hit point that’s perpendicular
to r . I’ll call this the normal plane . It’s relevant to the modeling because the
hemisphere over which the ray directions are distributed is oriented around r ,
instead of n as in previous chapters. The black dots sketched on the hemisphere
979355824.165.png 979355824.166.png 979355824.167.png
532
25. Glossy Refl ection
show where refl ected rays may penetrate the hemisphere. The
ray directions will all be on the “ r ” side of the normal plane.
In this context, Figure 15.4 shows how the exponent e con-
trols the distribution of the samples over the hemisphere and
concentrates them around r as e increases. We can therefore use
e to control the amount of glossiness. Because materials become
more glossy as the samples spread out over the hemisphere, the
smaller e is, the more glossy the material will be. This contin-
ues down to e = 1, which is Lambertian refl ection but oriented
around r , not n .
We can express the refl ected ray direction ω i in terms of an
orthonormal basis ( u , v , w ), where w is parallel to r , and u and
v are in the normal plane. The orientation of u and v around r
doesn’t ma er because the distribution of samples on the hemi-
sphere is rotationally symmetric about r . Provided we have
samples on a hemisphere with a cosine power distribution, the ray direction is
given by the same expression as Equation (17.4):
normal plane
n
i
o
r
p
hemisphere
Figure 25.3. The normal plane
at a hit point is perpendicu-
lar to the direction of mirror
refl ection.
ω i = s x u + s y v + s z w
(25.8)
Finally, we have to deal with the fact that Equation (25.8) can generate rays
that lie below the object’s surface at the hit point. To see how this happens,
consider an incoming ray that hits a surface with diff erent incident angles,
as in Figure 25.4. In Figure 25.4(a), the incoming ray direction ω o is normal
to the surface and therefore coincident with r and n . This is the only case
where the hemisphere that’s centered on r lies entirely above the surface. In
n
r
n
o
θ o = 99
45 o
o
n , r ,
o
r
o
normal
plane
surface
surfa
ace
hemisphere
normal plane
surface
(a) (b) (c)
Figure 25.4. (a) At normal incidence, none of the hemisphere is below the surface; (b) part
of the hemisphere is below the surface; (c) at grazing incidence, half of the hemisphere is
below the surface.
979355824.168.png 979355824.169.png 979355824.170.png 979355824.171.png 979355824.172.png 979355824.173.png 979355824.174.png 979355824.175.png 979355824.176.png 979355824.177.png 979355824.178.png 979355824.179.png 979355824.180.png 979355824.181.png 979355824.182.png 979355824.183.png 979355824.184.png 979355824.185.png 979355824.186.png 979355824.187.png 979355824.188.png 979355824.189.png 979355824.190.png 979355824.191.png 979355824.192.png 979355824.193.png 979355824.195.png 979355824.196.png 979355824.197.png 979355824.198.png 979355824.199.png 979355824.200.png 979355824.201.png 979355824.202.png 979355824.203.png 979355824.204.png 979355824.206.png 979355824.207.png 979355824.208.png 979355824.209.png 979355824.210.png 979355824.211.png 979355824.212.png 979355824.213.png 979355824.214.png 979355824.215.png 979355824.217.png 979355824.218.png 979355824.219.png 979355824.220.png 979355824.221.png 979355824.222.png 979355824.223.png 979355824.224.png 979355824.225.png 979355824.226.png 979355824.228.png 979355824.229.png 979355824.230.png 979355824.231.png 979355824.232.png 979355824.233.png 979355824.234.png 979355824.235.png 979355824.236.png 979355824.237.png 979355824.002.png 979355824.003.png 979355824.004.png 979355824.005.png 979355824.006.png
25.1 Modeling
533
, and the cyan section
of the hemisphere is below the surface 1 . In Figure 25.4(c),
the incoming ray is tangent to the surface, and half the
hemisphere is below the surface, a situation that occurs at
object silhoue es as seen from the camera or ray origin. The
fraction of refl ected rays that lie below the surface depends
on the angle of incidence and the value of e but is roughly
50% at grazing incidence for all values of e .
Figure 24.5(a) is a test scene that consists of a glossy
sphere and a blue background color. This image was ren-
dered with the estimator (25.7), e = 1, k r = 0.8, c r = white, 100
rays per pixel, and all refl ected rays traced. The color of the
sphere should be constant, but as you can see, it’s not. The
problem is that the rays under the surface hit the inside of
the sphere, and since the sphere’s material has no direct shading component,
they return zero radiance. As a result, the sphere is only half as bright at the
silhoue e as it is in the center.
Fortunately, there’s a simple solution. We just refl ect any rays that are below
the surface through r , a process that puts them above the surface. Figure 25.6
illustrates how this works, where rays below the surface (the gray dots) are
refl ected to become the red dots. This introduces some bias in the distribution,
where there are more rays than normal towards the periphery of the distribu-
tion, as in Figure 25.6(a). However, the bias decreases as the fraction of refl ected
rays increases, and it disappears at the silhoue e, as in Figure 25.6(b).
Figure 25.4(b), the incident angle is 45
°
Figure 25.5. Incorrect rendering of
a glossy sphere.
(a) (b)
Figure 25.6. Rays below the surface (cyan segments of the hemisphere) are refl ected
through r (at the center of the disks) to the red dots, above the surface.
1. For
θ 1 = 45
°
, ω o is in the normal plane.
979355824.007.png 979355824.008.png 979355824.009.png 979355824.010.png 979355824.011.png 979355824.013.png 979355824.014.png 979355824.015.png 979355824.016.png 979355824.017.png 979355824.018.png 979355824.019.png 979355824.020.png 979355824.021.png 979355824.022.png 979355824.024.png 979355824.025.png 979355824.026.png 979355824.027.png 979355824.028.png 979355824.029.png 979355824.030.png 979355824.031.png 979355824.032.png 979355824.033.png 979355824.035.png 979355824.036.png 979355824.037.png 979355824.038.png 979355824.039.png 979355824.040.png 979355824.041.png 979355824.042.png 979355824.043.png 979355824.044.png 979355824.046.png 979355824.047.png 979355824.048.png 979355824.049.png 979355824.050.png 979355824.051.png 979355824.052.png 979355824.053.png 979355824.054.png 979355824.055.png 979355824.057.png 979355824.058.png 979355824.059.png 979355824.060.png 979355824.061.png 979355824.062.png 979355824.063.png 979355824.064.png 979355824.065.png 979355824.066.png 979355824.068.png 979355824.069.png 979355824.070.png 979355824.071.png 979355824.072.png 979355824.073.png 979355824.074.png 979355824.075.png 979355824.076.png 979355824.077.png 979355824.079.png 979355824.080.png 979355824.081.png 979355824.082.png 979355824.083.png 979355824.084.png 979355824.085.png 979355824.086.png 979355824.087.png 979355824.088.png 979355824.090.png 979355824.091.png 979355824.092.png 979355824.093.png 979355824.094.png 979355824.095.png 979355824.096.png 979355824.097.png 979355824.098.png 979355824.099.png 979355824.101.png 979355824.102.png 979355824.103.png 979355824.104.png 979355824.105.png 979355824.106.png 979355824.107.png 979355824.108.png 979355824.109.png 979355824.110.png 979355824.112.png 979355824.113.png 979355824.114.png 979355824.115.png 979355824.116.png 979355824.117.png 979355824.118.png 979355824.119.png 979355824.120.png 979355824.121.png 979355824.123.png 979355824.124.png 979355824.125.png 979355824.126.png 979355824.127.png 979355824.128.png 979355824.129.png 979355824.130.png 979355824.131.png 979355824.132.png 979355824.134.png 979355824.135.png 979355824.136.png 979355824.137.png 979355824.138.png 979355824.139.png 979355824.140.png 979355824.141.png 979355824.142.png 979355824.143.png 979355824.145.png 979355824.146.png 979355824.147.png 979355824.148.png 979355824.149.png 979355824.150.png 979355824.151.png 979355824.152.png 979355824.153.png 979355824.154.png 979355824.156.png 979355824.157.png 979355824.158.png 979355824.159.png
 
Zgłoś jeśli naruszono regulamin