Graphics Reference
In-Depth Information
is not an emitter, but there is direct light from R to P , shown in cyan. Notice that
this division of light arriving at P from Q into different parts is a mathematical
convenience. There's no way, when a photon arrives at P from Q , to tell whether
it was directly emitted or was scattered. But dividing the arriving light in this way
allows us to structure our program to get better results.
The figure also shows the results of scattering these at P , which we'll call L d,s
and L i,s . The scattered radiance L r
is just L d,s + L i,s . Thus,
)= L r ( Q ,
L i,s ( P ,
v i ) f s ( Q ,
,
v i )
| v i ·
n Q |
d
v i , and
(31.92)
v
v
)= L e ( Q ,
L d,s ( P ,
v i ) f s ( Q ,
,
v i )
| v i ·
n Q |
d
v i ,
(31.93)
v
v
where Q = raycast ( P ,
) .
With these definitions, we restructure the code slightly (see Listing 31.5).
v
Listing 31.5: Kajiya-style path tracer, part 1.
v ):
define estimateL( C ,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
v )
P = raycast( C ,
resultSum = L e
v ) + estimateLr( P , v )
( P ,
return resultSum
v ):
return estimateLds( P ,
define estimateLr( P ,
v
v
) + estimateLis( P ,
)
v
define estimateLis( P ,
): // single sample estimate
u = uniform(0, 1)
ρ = scatterFraction(P)
if (u < ρ ):
v i = randsphere()
Q = raycast( P ,
v i )
integrand = estimateLr ( Q , v i ) * f s ( P ,
v i ,
v ) | v i · n |
1
4 π
density =
return integrand /( ρ
density )
*
return 0
define estimateLds(...
Notice that in estimating the scattered indirect light, we didn't scatter all the
radiance arriving at P from Q , but only L r .The L e portion of the radiance is the
direct light, which we're deliberately not including.
To estimate L d,s
(the scattering of the direct light), we are trying to evaluate
the integral
)= L e ( Q ,
L d,s ( P ,
v i ) f s ( P ,
,
v i )
| v i ·
n P |
d
v i ,
(31.94)
v
v
where Q denotes the result of a ray cast from P in direction
v i .
We're going to shift from a spherical integral to a surface integral (which
involves the usual change of variable factor), and integrate over all light sources.
(You should now think of Q as being a point on the light source in Figure 31.24.)
To keep things simple, we'll assume that we have only area light sources (no
point lights!), and that there are K of them, with areas A 1 ,
...
, A K , and total area
A = A 1 + A 2 +
...
+ A K .
 
 
Search WWH ::




Custom Search