6.2 Sampling the rendering equation
6.2.4 Hey’s method
Hey and Purgathofer described a sophisticated method for importance sampling incident radiance using the photon map (Hey and Purgathofer, 2002). Like Jensen, they begin with akNN search to sample incident radiance. Also as in Jensen’s method, the photons are projected onto a 2D unit grid divided into cells. The paper suggests CH = 32×32
cells. Instead of summing the energy arriving in each cell, as Jensen did, the 3×3 circle of cells around the project direction is identified and each cell incremented by one. This table will be used to estimate the density of photon arriving from any given direction.
However, unlike Jensen’s method, this table is not directly used to generate final gather rays; it plays only a secondary role. The complicated details are carefully laid out in their paper. There are two fundamental ways in which their algorithm departs from Jensen’s. This first is that the actual list of photons found by the kNN search is kept and used while generating final gather directions.
The list of photons is sampled, with the probability of choosing a particular photon defined by the amount of energy it carried compared to the others. Once a specific photon
pis selected, a cone is generated fromx along the direction the photon arrived from,~ωp.
A random direction,~ωc, within this cone is then sampled as shown in Figure 6.10.
from the 2D table. This allows the algorithm to tightly mold the generated samples to the incident radiance function. If a photon has many neighbors, its cone will subtend a small solid angle and the samples will stay close to the photon’s direction. If, however, the photon is far from its neighbors it will generate samples covering a large portion of the visible hemisphere.
Importance sampling requires not only that the samplesXbe generated, but also that the probability of having selected X, p(X), be known. Because the cones around each photon may overlap and be arbitrarily large, X could have been generated by multiple photons. Therefore, computing p(X) requires a test to determine if X lies within the cones of any of the P photon. This test requiresP dot-products per sample.
The second difference between this method and Jensen’s is the use of Veach’s multiple importance sampling. The number of final gather rays,NF G, is divided withNBallocated
to BRDF sampling, as described in Section 6.2.1, and NP using the strategy outlined
here. This does however impose a significant additional cost, because the probability of having chosen a sample according toboth methods must be determined for every sample. For each of the NB final gather rays sampled according to the BRDF, the probability
of having selected them using the photons must be computed. This can be a costly operation because, as just described, the cone around all P photons must be compared against. For a total ofNF G samples, this will require NF G×P dot products. Unless the
computations of the BRDF are very expensive this will be the dominating cost of Hey’s method.
6.2.4.1 Resource requirements
Hey’s technique requires more storage since it must keep the list ofP photons. In addition to the 96 bytes per photon, using Jensen’s compact representation, Hey’s algorithm must store three 32-bit values for each photon. (The alternative would be recomputing these values before each sample is generated, an expensive strategy.) Additionally, a table of
size CH = 32×32 is stored as 32-bit floating point numbers. The total of 6,256 bytes is
presented in Table 6.1. Although this is significantly more storage than Jensen’s method requires, as long as P is not excessively large, it is not a prohibitive problem.
During the preprocess stage the photon density table is constructed, reflected radiance for each photon computed, the c.d.f. that will be used to choose each photon is built, and the footprint radius and height for every photon is computed. (See the original paper for more details.) This preprocessing alone requires P(8 + BRDF) + 2CH FLOPS.
The computational costs of generating the samples is however more significant. NB
samples are generated according to the BRDF. NP samples are generated by picking a
photon using a binary search in the c.d.f. for 1 FLOP, and then generating a sample in the cone surrounding the photon for 5 FLOPS. For all NF G samples, their proba-
bilities according to both the BRDF and all P photons must be computed. This costs (BRDF)NB+ 6NP + (1 + 5P + BRDF)NF G.
For the purposes of a concrete comparison, it is assumed that all three operations involving the BRDF (evaluation, importance sampling, and evaluating the p.d.f) cost 10 FLOPS. The results shown in Table 6.2 are high, over an order of magnitude higher than Jensen’s method.