Graphics Reference
In-Depth Information
The integral we want to compute is
)=
v PQ ) V ( P , Q ) | v PQ ·
n P || v PQ ·
n Q |
L d,s ( P ,
L e ( Q ,
v PQ ) f s ( P ,
v
v
,
dQ ,
Q
P
2
Q
lights
(31.95)
where
P ) is the unit vector pointing from P to Q , and V ( P , Q ) is
the visibility function, which is 1 if P and Q are mutually visible and 0 otherwise.
(The extra dot product, and the squared length in the denominator, come from the
change of variables.) Notice that in the integrand, we have L e and not L : We only
want to estimate scattering of direct light.
We can estimate this integral by picking a point Q uniformly at random with
respect to area (i.e., with probability A i /
v PQ = S ( Q
A it'll be a point of light i , and within light
i , it'll be uniformly randomly distributed), and using Q to perform a single-sample
estimate of the integral:
v PQ ) V ( P , Q ) | v PQ ·
n P || v PQ ·
n Q |
L d,s ( P ,
L e ( Q ,
)
A
·
v PQ ) f s ( P ,
,
.
v
v
Q
P
2
(31.96)
This makes the code for estimateLds fairly straightforward (see Listing 31.6).
Listing 31.6: Kajiya-style path tracer, part 2.
v
define estimateLds( P ,
):
Q = random point on an area light
if Q not visible from P :
return 0
else:
v PQ = S ( Q P )
geom = | v PQ · n P || v PQ · n Q |
Q P
1
2
3
4
5
6
7
8
2
v
v
v
return A
·
L e
(
Q ,
)
f s (
P ,
,
) ·
geom
PQ
PQ
Everything we've done here depends on the BSDF being “nice,” that is, having
no impulses. In the next chapter, we'll adjust the code somewhat to address that.
To summarize, path tracing works by estimating the integrand using a Markov
chain Monte Carlo approach, including the reuse of initial segments of the chain
for efficiency. It avoids the plethora of recursive rays generated by conventional
ray tracing; the time saved is allocated to collecting multiple samples for each
pixel. While path tracing is, in the abstract, an excellent algorithm, it does require
that you choose an acceptance probability (we've used the scattering fraction)
and a sampling strategy for outgoing rays; if these are chosen badly, the variance
will be high, requiring lots of samples to reduce noise in the final image. Fur-
thermore, the sampling strategy must be general enough to find all paths in your
scene that actually transport important amounts of light. If you allow purely spec-
ular surfaces and point lights, then paths of the form LS + DE are problematic as
mentioned above: The path starting from the eye must choose a direction, after
the first bounce, that happens to be reflected one or more times to reach the point
light. The probability of choosing this direction is unfortunately zero. If you allow
nearly point lights and nearly specular reflections, you can still get the same effect:
The probability of sampling a good path can be made arbitrarily small. To address
this limitation, we have to consider other ways of sampling from the space of all
 
 
Search WWH ::




Custom Search