The methods of Hey and Pharr improved upon that of Jensen in two ways: 1) they incorporated information about non-diffuse BRDFs into their sampling using multiple importance sampling; and 2) by sampling from within cones around the photons they achieve a tighter fit of the generated samples to the limited knowledge about the incident radiance function. In exchange for these improvements they incurred a large computa- tional cost. In this section I present a novel algorithm that incorporates knowledge of glossy BRDFs without a direct implementation of multiple importance sampling, keep- ing costs low while performing nearly as well as Hey and Pharr’s methods for the scenes described in Chapter 1.
In multiple importance sampling, the samples are generated according to two separate sampling strategies and the balance heuristic required computing a joint probability by consulting all M p.d.f.s. These requirements taken together require that information for both sampling strategies be stored throughout the sampling process and that many of computations be performed. Combined importance sampling, however, integrates the strategies together as a pre-process, leaving a single strategy to generate allNF Gsamples
can only be performed when it is possible to directly combine the M p.d.f.s. As will be shown shortly, this approach is simple when the p.d.f.s are expressed in a tabular form.
The balance heuristic (Equation 6.6) can be substituted into the MIS estimator (Equa- tion 6.5) to obtain the estimator used by Hey and Pharr (Equation 6.9).
FM,N = 1 N M X i=1 Ni X j=1 f(Xi,j) P k Ni Npk(Xi,j) (6.9)
Observe that this equation uses multiple sampling strategies. When restricted to two strategies, BRDF and photon-map-based incident radiance, the denominator can be rewritten as ˆ p(x) = NB N pB(x) + NP N pP(x) (6.10)
where pB(x) and pP(x) are the p.d.f.s for selecting according to the BRDF and photon
tables respectively. FN = 1 N N X i=1 f(Xi) ˆ p(Xi) (6.11)
Note that ˆp(x) is the weighted average of pB(x) and pP(x). This gives the reduced
estimator (Equation 6.11) the appearance of the standard importance sample estimator, presented earlier in this chapter. Most importantly, there is a single sampling strategy and only a single evaluation of ˆp(x) is required.
This new strategy can be easily applied to final gather ray generation using the photon map by building upon Jensen’s method. The following explanation is outlined in Algorithm 6.3. The starting point is a p.d.f. table constructed based on the incident radiance exactly as was performed in Jensen’s preprocessing. The transformations for the diffuse BRDF,T(u, v) and T−1(θ, φ), are used, regardless of the true BRDF.
A second p.d.f. table is generated according to the following rule. For each cell, a single ray, ~ωc, is generated through the middle of the corresponding portion of the
Pre-condition: pdfLiTable is computed as described in Algorithm 6.1 // Compute evaluatedBRDFTable
for each cell [u, v]∈evaluatedBRDFTable do
~
ωc ←centerDirectionOfCell(u, v)
evaluatedBRDFTable[u, v]←f(x, ~ωc, ~ωo)
totalReflectance←totalReflectance +f(x, ~ωc, ~ωo)
end for
// Donate a small portion of the total reflectance to any empty cells donation←0.05×totalReflectance/CJ
for each cell [u, v]∈evaluatedBRDFTable do if evaluatedBRDFTable[u, v] == 0 then
evaluatedBRDFTable[u, v]←donation
totalReflectance←totalReflectance + donation end if
end for
// Normalize the reflectance table, producing the p.d.f. for each cell [u, v]∈pdfBRDFTable do
pdfBRDFTable[u, v]←evaluatedBRDFTable[u, v]/totalReflectance end for
// Average the two p.d.f. tables
for each cell [u, v]∈pdfCombinedTable do
pdfCombinedTable[u, v]←(pdfLiTable[u, v] + pdfBRDFTable[u, v])/2 end for
// Construct a combined 1D c.d.f. array cdfArray[0]←0
for i= 1 to CJ + 1 do
cdfArray[i]←cdfArray[i−1] + pdfCombinedTable[i] end for
Algorithm 6.3: The preprocessing stage for combined importance sampling begins with that of Jensen’s (Algorithm 6.1). A second p.d.f. table is constructed and the results averaged to form a single p.d.f. table to sample from. A visual representation in shown in Figure 6.11.
(a) Incident radiance p.d.f. (b) BRDF p.d.f. (c) Combined p.d.f.
Figure 6.11: Combined importance sampling generates as a preprocess a tabular p.d.f. for both the incident radiance and the BRDF. These two p.d.f.s are then combined by averaging the values in each cell independently. Only one strategy for generating samples is therefore required andp(X) is simple to compute. An example of the samples generated using this p.d.f. is shown in Figure 6.8c.
Storage Bytes
Jensen 4CJ 128
Combined 4CJ 128
Pharr 96P 960
Hey 4CH + 128P 6,256
Table 6.1: The intermediate storage cost for each of the global importance sampling techniques. We assume that P photons were gathered for the radiance estimate, and that there wereNBsamples generated according to the BRDF andNP samples generated
according to the incident radiance for a total of N samples. Jensen’s and the combined technique require storage of tables withCJ cells, while Hey used tables of size CH.
non-positive values are given a small positive value and finally, the table is normalized in order forming a p.d.f. table.
Following Equation 6.10, the two p.d.f. tables are then directly averaged together to form a single p.d.f. that is used for sampling. This process is shown in Figure 6.11. The combined p.d.f. table is converted into a c.d.f. table as before. Samples are then generated using the same process as in Algorithm 6.1. Only a single operation is required to determine the probability of having generated a particular sample.
6.3.0.2 Resource requirements
The combined importance sampling method has costs similar to that of Jensen’s. The storage requirements are exactly the same, as is the cost to generate samples. The preprocess has additional costs however. They mostly arise from the evaluation of the BRDF for each cell; creating the additional p.d.f. table and averaging the two together are both relatively cheap. The total cost formula is 3P + (3 + BRDF)CJ+ 6NF G.
6.3.0.3 Discussion
Combined importance sampling is simple and efficient. It will be shown in the next section that it is effective for the scenes where the BRDF is not too glossy or the incident radiance too sharp. These two limitations both arise from the use of a low-resolution table to express the p.d.f. and are explained using the same rationale as was used for Jensen’s technique: samples within a single cell are generated purely randomly, so they can miss a particularly small feature in the integrand. Although it will consequently not be able to capture highly specular surfaces perfectly, these surfaces are often sampled specially in path tracers (Shirley, 2000). Experiments show that a 4×8 table is adequate for glossy surfaces. (Those equivalent to a Blinn-Phong cosine lobe of n=16.)
An important benefit of this approach, beyond the reduction in computational cost, is that the BRDF does not have to be sampled, only evaluated. Therefore neither T(u, v) nor T−1(θ, φ) need be known, or easy to evaluate. As was discussed in Section 6.2.1,
those functions can be difficult to specify and evaluate for acquired reflectance functions.