Graphics Reference
In-Depth Information
Listing 29.3: Estimating the indirect light scattered back along a ray.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Radiance3 App::estimateIndirectLight(surfel, ray, bool isEyeRay){
Radiance3 radiance(0.0f);
// Use recursion to estimate light running back along ray from surfel that arrives from
// INDIRECT sources, by making a single-sample estimate of the arriving light.
Vector3 w_o = -ray.direction();
Vector3 w_i;
Color3 coeff;
if (surfel.scatter(w_o, w_i, coeff)) {
newRay = Ray(surfel.geometric.location, w_i).bumpedRay(
0.0001f * sign(surfel.geometric.normal.dot(w_i));
// the final "false" makes sure that we do not include direct light.
radiance = coeff * pathTrace(newRay, surfel.geometric.normal), false);
}
return radiance;
}
Without worrying too much about the details, what's happening here is that
we're picking a random direction w_i ,using scatter , on the outgoing hemisphere.
We're then using PathTrace to estimate the radiance arriving at P from that direc-
tion, that is, we're estimating L ( P ,
v i ) . The coefficient by which we multiply this
radiance includes the area of the hemisphere and an adjustment for the fact that
we did not pick our direction uniformly from all possible directions, but instead
biased our choice based on the BRDF, for reasons you'll learn about in Chapter 30.
To summarize: The recursive nature of the rendering equation is exactly
reflected in the recursive nature of the program. You might reasonably ask whether
the recursion will ever terminate, since there seems to be no stopping condition.
The answer is yes, because of the design of the scatter procedure: If a surface's
hemispherical reflectance is 0. 7, then 30% of the time scatter will return false
and the recursion will terminate. The other 70% of the time the coefficient coeff
is adjusted to take into account the probability of nonscattering.
29.4 The Rendering Equation for General
Scattering
In formulating the rendering equation, we assumed that our scene contained only
reflective materials rather than ones that could transmit light, or participating
media like fog that can scatter light as it passes through them.
We'll now generalize to handle transmissive materials as well. This will
require almost no new concepts, but we'll need to slightly revise the way we rep-
resent the radiance in a scene. A further revision is needed to handle participating
media, which we will not discuss here. Instead, we'll consider just one special
case, in which light is attenuated by absorption as it passes through a medium but
is never scattered in any new direction. More general models of scattering, dis-
cussed briefly in Chapter 27, can be used to generate quite striking renderings like
that shown in Figure 29.2 from 1987, one of the earliest high-quality synthetic
images of participating media.
Figure 29.2: Rendering with a
participating medium (dusty air).
(Courtesy of Holly Rushmeier,
©1987 ACM, Inc. Reprinted by
permission.)
 
 
 
Search WWH ::




Custom Search