Adaptive Numerical Cumulative Distribution Functions for ...

10
Eurographics Symposium on Rendering (2005) Kavita Bala, Philip Dutré (Editors) Adaptive Numerical Cumulative Distribution Functions for Efficient Importance Sampling Jason Lawrence Szymon Rusinkiewicz Ravi Ramamoorthi Princeton University Princeton University Columbia University Abstract As image-based surface reflectance and illumination gain wider use in physically-based rendering systems, it is becoming more critical to provide representations that allow sampling light paths according to the distribution of energy in these high-dimensional measured functions. In this paper, we apply algorithms traditionally used for curve approximation to reduce the size of a multidimensional tabulated Cumulative Distribution Function (CDF) by one to three orders of magnitude without compromising its fidelity. These adaptive representations enable new algorithms for sampling environment maps according to the local orientation of the surface and for multiple importance sampling of image-based lighting and measured BRDFs. Categories and Subject Descriptors (according to ACM CCS): I.3.7 [Computer Graphics]: Three-Dimensional Graphics and Realism I.3.6 [Computer Graphics]: Methodology and Techniques 1. Introduction Techniques are now common for accurately measuring real- world surface reflectance and illumination. As a result, densely sampled tabular representations of lighting and Bi- directional Reflectance Distribution Functions (BRDFs) ap- pear in off-line, physically-based rendering pipelines. Be- cause global illumination algorithms typically use Monte Carlo integration, employing common variance reduction techniques is critical to achieving a feasible rate of conver- gence. Consequently, it is important that representations of measured environment maps and BRDFs provide efficient importance sampling. While several specific representations of measured en- vironment maps and BRDFs do allow direct sampling, there is still no single representation that is appropriate for general multidimensional measured functions. As higher- dimensional datasets find their way into rendered scenes (e.g. light fields, reflectance fields, etc.), a general method for sampling them will become more important. Moreover, for the specific case of environment maps, existing represen- tations do not account for the local orientation of the surface (i.e. the cosine term in the rendering equation). This property can limit the effectiveness of environment map sampling in reducing variance for many scenes. Another important draw- 0 1.0 0 1.0 (a) 6 Samples (b) 18 Samples Figure 1: We represent a 1D CDF with a set of non- uniformly spaced samples of the original function. This re- sults in a more compact yet accurate approximation of the original function than uniform spacing would allow. In addi- tion, the final CDF maintains many key properties necessary for unbiased multiple importance sampling. back of some existing environment map representations is that they are not readily incorporated into a multiple impor- tance sampling framework [VG95]. In this paper, we apply a curve approximation algorithm to the task of compressing multidimensional tabular Cumu- lative Distribution Functions (CDFs) derived from measured datasets. Assume we have a 1D CDF, P(x), sampled uni- formly in x. In order to compress this function, we lift the restriction that the samples must be uniformly spaced, as shown in Figure 1. We use the Douglas-Peucker greedy al- c The Eurographics Association 2005.

Transcript of Adaptive Numerical Cumulative Distribution Functions for ...

Page 1: Adaptive Numerical Cumulative Distribution Functions for ...

Eurographics Symposium on Rendering (2005)Kavita Bala, Philip Dutré (Editors)

Adaptive Numerical Cumulative Distribution Functions forEfficient Importance Sampling

Jason Lawrence Szymon Rusinkiewicz Ravi Ramamoorthi

Princeton University Princeton University Columbia University

Abstract

As image-based surface reflectance and illumination gain wider use in physically-based rendering systems, it isbecoming more critical to provide representations that allow sampling light paths according to the distributionof energy in these high-dimensional measured functions. In this paper, we apply algorithms traditionally used forcurve approximation to reduce the size of a multidimensional tabulated Cumulative Distribution Function (CDF)by one to three orders of magnitude without compromising its fidelity. These adaptive representations enable newalgorithms for sampling environment maps according to the local orientation of the surface and for multipleimportance sampling of image-based lighting and measured BRDFs.

Categories and Subject Descriptors (according to ACM CCS): I.3.7 [Computer Graphics]: Three-DimensionalGraphics and Realism I.3.6 [Computer Graphics]: Methodology and Techniques

1. Introduction

Techniques are now common for accurately measuring real-world surface reflectance and illumination. As a result,densely sampled tabular representations of lighting and Bi-directional Reflectance Distribution Functions (BRDFs) ap-pear in off-line, physically-based rendering pipelines. Be-cause global illumination algorithms typically use MonteCarlo integration, employing common variance reductiontechniques is critical to achieving a feasible rate of conver-gence. Consequently, it is important that representations ofmeasured environment maps and BRDFs provide efficientimportance sampling.

While several specific representations of measured en-vironment maps and BRDFs do allow direct sampling,there is still no single representation that is appropriate forgeneral multidimensional measured functions. As higher-dimensional datasets find their way into rendered scenes(e.g. light fields, reflectance fields, etc.), a general methodfor sampling them will become more important. Moreover,for the specific case of environment maps, existing represen-tations do not account for the local orientation of the surface(i.e. the cosine term in the rendering equation). This propertycan limit the effectiveness of environment map sampling inreducing variance for many scenes. Another important draw-

0

1.0

0

1.0

(a) 6 Samples (b) 18 Samples

Figure 1: We represent a 1D CDF with a set of non-uniformly spaced samples of the original function. This re-sults in a more compact yet accurate approximation of theoriginal function than uniform spacing would allow. In addi-tion, the final CDF maintains many key properties necessaryfor unbiased multiple importance sampling.

back of some existing environment map representations isthat they are not readily incorporated into a multiple impor-tance sampling framework [VG95].

In this paper, we apply a curve approximation algorithmto the task of compressing multidimensional tabular Cumu-lative Distribution Functions (CDFs) derived from measureddatasets. Assume we have a 1D CDF, P(x), sampled uni-formly in x. In order to compress this function, we lift therestriction that the samples must be uniformly spaced, asshown in Figure 1. We use the Douglas-Peucker greedy al-

c© The Eurographics Association 2005.

Page 2: Adaptive Numerical Cumulative Distribution Functions for ...

J. Lawrence, et. al. / Adaptive Numerical CDFs for Importance Sampling

gorithm for polygonal approximation of 2D curves [DP73,HS92] to compute the location of these adaptive samples.We further extend this algorithm to represent multidimen-sional CDFs. To accomplish this, we compute marginal 1DCDFs in each dimension by summing the energy containedacross the orthogonal dimensions. Each of these 1D CDFs isrepresented by non-uniformly spaced samples and the result-ing set of these “cascading CDFs” approximates the originalhigh-dimensional distribution. There are several benefits ofusing this adaptive numerical representation:

• Allowing placement of non-uniformly spaced samples re-duces the number that must be stored to accurately rep-resent the original CDF. This is especially true for multi-dimensional distributions because the storage grows ex-ponentially with the number of dimensions. Significantreduction is also achieved for common “peaky” distribu-tions, for which many methods require O(n) storage.

• Generating directions according to the distribution, ac-complished using numerical inversion of the CDF, sim-ply requires a binary search over the sorted samples ofP(x). This is essentially the same algorithm as is used foruniformly sampled CDFs, but with the position of eachsample along the domain stored explicitly.

• Storing a “cascading set” of conditional 1D CDFs, eachrepresented by non-uniformly spaced samples of the orig-inal functions, promotes a direct implementation of unbi-ased stratified importance sampling. This results from thefact that each dimension can be sampled independently.

• The probability of a sample not drawn from the CDF itselfcan be efficiently computed from the final representation.This property is critical for combining distributions withstandard multiple importance sampling algorithms.

To demonstrate the benefit of our adaptive representation,we present a novel algorithm for sampling measured envi-ronment maps in an orientation-dependent manner. This isaccomplished by sampling the 4D function that results frommodulating an environment map with the horizon-clippedcosine term in the rendering equation. This algorithm ismore efficient than existing techniques that sample only asingle spherical distribution. Lastly, we show how our adap-tive representation can be used within a multiple importancesampling framework.

2. Related Work

Monte Carlo importance sampling has a long history inComputer Graphics [Vea97]. For stratified sampling from2D CDFs on a manifold (in the practical examples of this pa-per, the manifold is a sphere or hemisphere), Arvo [Arv01]describes a particular recipe when an analytic description ofthe function is available, with analytic sampling strategiesavailable in some cases [Arv95]. When dealing with mea-sured illumination or reflectance data, as in this paper, non-parametric or “numerical” CDFs are unavoidable, and it isimportant to compress them.

One possible approach is to use general function com-pression methods, such as wavelets or Gaussian mixturemodels. Wavelets have been previously used for importancesampling of BRDFs [CPB03,LF97]. However, the computa-tional cost for generating a sample can be significant, espe-cially if non-Haar wavelets are used (as is necessary to avoidmany kinds of blocking artifacts). Additionally, the imple-mentation for multidimensional functions such as measuredillumination and BRDFs can be difficult, requiring sparsewavelet data structures and a hexa-decary search.

A second approach to compact CDF representation thathas been applied for BRDFs is factorization [LRR04]. Thismethod takes advantage of the structure of the BRDF to fac-tor it into 1D and 2D pieces, thereby reducing dimensional-ity while still allowing for accurate representation and effi-cient importance sampling. The technique proposed here dif-fers in considering compression of general tabulated CDFs,and is not limited to BRDF sampling. Additionally, the CDFcompression considered here is independent of dimensionand orthogonal to any factorizations of the input data. Itcould therefore be applied equally well to methods that usea full tabular BRDF representation and sampling scheme (asshown in this paper), or to lower dimensional components.

Another specialized CDF compression approach, whichhas been applied to environment maps, is to decompose thefunction into piece-wise constant Voronoi or Penrose regionson the sphere [ARBJ03,KK03,ODJ04]. As compared to ourmethod, these techniques offer more optimal stratification,but do not directly extend to multidimensional distributions.Another drawback of these representations is that they aredifficult to use with standard multiple importance samplingalgorithms that require computing the probability of a di-rection generated from a separate distribution. Lastly, theserepresentations ignore the fact that half of the environmentis always clipped against the horizon of the surface and thatthe illumination is scaled by a cosine term (Figure 10).

3. Background

In this paper we address the problem of importance sam-pling. That is, we seek to generate samples according tosome Probability Density Function (PDF), p, which by defi-nition is non-negative and normalized (i.e., it integrates to 1).We accomplish this using the inversion method, which pre-computes the corresponding Cumulative Distribution Func-tion (CDF)

P(x) =Z x

−∞

dx′ p(x′) (1)

and evaluates its inverse P−1(ζ) at locations given by a uni-formly distributed random variable ζ ∈ [0,1].

We are interested in the case of a PDF specified numer-ically: in 1D, we assume that we are given probabilities piat locations xi. We precompute the corresponding CDF val-

c© The Eurographics Association 2005.

Page 3: Adaptive Numerical Cumulative Distribution Functions for ...

J. Lawrence, et. al. / Adaptive Numerical CDFs for Importance Sampling

Figure 2: The Douglas-Peucker algorithm greedily com-putes a polyline approximation of a smooth 2D curve. Itworks by inserting the next sample in the approximation atthe point of maximum deviation between the (black) originalcurve and the (red) current polyline approximation.

ues Pi and, at run-time, invert the CDF by performing a bi-nary search for the interval [Pi,Pi+1] that contains the ran-dom value ζ. Note that this search is required whether or notthe xi are spaced uniformly. This will be the key propertyused by our representation: we can represent many functionsmore efficiently by having non-uniformly spaced xi withoutincreasing the run-time cost of importance sampling.

In 2D, the situation is more complex. We must first de-compose the 2D PDF p(x,y) into two pieces, one dependentonly on x and the other on y:

p(x) =Z

−∞

dy p(x,y) (2)

p(y|x) =p(x,y)p(x)

(3)

The numerical representation then consists of a discretizedversion of p, given as samples pi at locations xi, togetherwith a collection of discretized conditional probability func-tions pi(y|xi). This technique generalizes naturally to anynumber of dimensions, producing a “cascading set” of CDFswhere a value in each dimension is generated sequentiallyusing the appropriate 1D marginal CDF at each step [Sch94].As an important special case, we note that functions ona sphere may be represented using the parameterizationp(z,φ), where the usual change of variables z = cosθ is usedto normalize for the area measure dω = sinθdθdφ.

If the CDFs are uniformly sampled along their domain,the total size of this set of CDFs will be slightly largerthan the size of the original function. In Computer Graph-ics, it is often the case that these functions can be bothhigh-dimensional and measured at high resolutions. Conse-quently, the combined size of the resulting 1D CDFs canquickly become prohibitively large. This motivates our in-vestigation into efficient techniques for compressing thesesampled functions without compromising their accuracy orutility.

4. Numerical CDF Compression

We use polygonal curve approximation algorithms to com-press a densely sampled CDF by representing it with a re-duced set of non-uniformly spaced samples selected to min-imize the reconstruction error.

4.1. Polygonal Curve Approximation

With early roots in cartography, several efficient algorithmshave been developed for computing polygonal approxima-tions of digitized curves. Polygonal approximation algo-rithms take as input a curve represented by an N-segmentpolyline and produce an M-segment polyline with vertices soas to minimize the error between the two (typically M N).

Although algorithms exist that output the optimal solu-tion [CC96, Goo94, CD03], we instead use the Douglas-Peucker [DP73, HS92] greedy algorithm because of its sim-plicity and speed. It has also been shown that these greedyalgorithms typically produce results within 80% accuracy ofthe optimal solution [Ros97].

The Douglas-Peucker curve approximation algorithmworks by iteratively selecting the vertex furthest from thecurrent polyline as the next vertex to insert into the ap-proximation (Figure 2). Initially only the endpoints of thecurve are selected, and the algorithm iteratively updates thisapproximation until either an error threshold is reached orsome maximum number of vertices have been used. Forcurves derived from numerical CDFs, we found this algo-rithm sufficient for producing near-optimal approximationswith few samples.

4.2. Applying Curve Approximation to CDFs

There are several ways of applying the above curve approx-imation algorithms to the task of representing numericalprobability functions. First, we can apply them to yield apiecewise linear approximation of the CDF, which is equiv-alent to a piecewise constant approximation of the cor-responding PDF. Because the Douglas-Peucker algorithm,when applied to the CDF, is guaranteed to yield a nonde-creasing function with a range of [0..1], the resulting approx-imation may be used directly as a CDF and differentiated tofind the corresponding PDF.

A second way of using curve approximation algorithmsis to apply them directly to the PDF to obtain a piecewiselinear approximation (which implies a piecewise quadraticCDF). In this case, the resulting approximation is not guar-anteed to integrate to one, and must be normalized beforeit can be used as a probability function. Figure 3, bottom,compares these two strategies on a (relatively smooth) func-tion: note that the two approaches result in samples beingplaced at different locations in the domain. For comparison,Figure 3, top, shows piecewise constant and piecewise linearapproximations using uniform sample spacing.

c© The Eurographics Association 2005.

Page 4: Adaptive Numerical Cumulative Distribution Functions for ...

J. Lawrence, et. al. / Adaptive Numerical CDFs for Importance Sampling

0

0.25

0.5

-3.14 -1.57 0.00 1.57 3.14

Pro

babi

lity

Phi

Beach PDF, 8 Uniform Samples

OriginalPiecewise Constant

Piecewise Linear

0

0.25

0.5

-3.14 -1.57 0.00 1.57 3.14

Pro

babi

lity

Phi

Beach PDF, 8 Adaptive Samples

OriginalPiecewise Constant

Piecewise Linear

Figure 3: A probability density function (corresponding toenvironment map in Figure 7) and its piecewise linear andpiecewise constant approximations with 8 samples placeduniformly (top) and computed by the Douglas-Peucker algo-rithm (bottom). The piecewise constant approximation wascomputed by running Douglas-Peucker on the integral ofthe PDF (i.e. the CDF). Note that, for this relatively smoothfunction, the piecewise linear approximation is closer to theoriginal.

One important difference between uniformly-sampledand adaptively-sampled CDFs is the cost of reconstructingthe value of the approximated function (i.e., evaluating theprobability) at an arbitrary position. This property is nec-essary for combining several distributions using multipleimportance sampling algorithms [Vea97]. When the sam-ples are uniformly spaced the cost is O(1), whereas adap-tively sampled representations require O(logN) time (hereN refers to the number of non-uniform samples). This in-creased complexity results from having to perform a binarysearch over the values of the function sorted along the do-main to find the desired interval. Because adaptive represen-tations provide such large compression rates, however, N istypically small enough to make this added cost insignificantin practice. In addition, the time complexity of generatinga sample (as opposed to evaluating the probability) remainsthe same at O(logN) in both cases.

In our experiments, we always used a piecewise constantapproximation of the PDF (i.e. piecewise linear CDF). Al-though this results in a slightly larger representation, in ourexperience this drawback was outweighed by the simpler im-plementation required for sampling a piecewise constant ap-proximation.

5. Multidimensional CDFs: The CascadingDouglas-Peucker Algorithm

In the previous section, we discussed how to apply curve ap-proximation algorithms to the task of efficiently representingnumerical 1D CDFs. In this section, we extend these ideas toaccomodate distributions of higher dimension. For the sakeof explanation, we first restrict our discussion to the 2D caseand provide an example with synthetic data in Figure 4. Ex-tending these techniques to higher dimensions is straightfor-ward and briefly discussed at the end of the section.

Recall that we can convert any 2D distribution (Figure 4top) into a single marginal CDF plus a set of conditionalCDFs according to Equations 1, 2 and 3. In order to gener-ate (x,y) pairs with probability proportional to the magni-tude of the original function, we first generate a value of xfrom the marginal CDF P(x) (Figure 4 bottom, red curve)and then generate a value of y from the corresponding con-ditional CDF P(y|x) (not shown in Figure 4).

As described previously, we use the Douglas-Peucker al-gorithm to select a set of non-uniformly spaced samplesthat accurately represent the marginal 1D CDF, P(x). Forthe example in Figure 4, we can perfectly approximate themarginal CDF with samples at the endpoints A and E and atinternal locations B and D. Next, we would compute a set ofconditional CDFs, P(y|x); one for each of these regions inx (e.g. in Figure 4 these regions are AB, BD and DE). Eachconditional CDF is the average across its associated range:

p(y|xi) =1

xi − xi−1

Z xi

xi−1

dx′p(x′,y)p(x′)

. (4)

For all the examples in this paper on measured data, build-ing a cascading set of CDFs according to Equation 4 was suf-ficient for accurately approximating the original distribution.However, there are potential situations where this approachalone ignores error introduced by approximating the distri-bution of energy within a region with a single CDF. Figure 4illustrates such a situation. In this case, the distribution of en-ergy within the region BD would be poorly approximated bya single conditional distribution because the two area lightsources are at different heights. In order to address this is-sue, we must also consider the gradient in the x-direction ofthe original distribution:

g(x) =Z

−∞

dy∣

∂p(x,y)∂x

(5)

When the function g(x) is large this indicates locations inx where the conditional CDFs, P(y|x), would not be wellapproximated by a single distribution. Therefore, after ourfirst application of the Douglas-Peucker algorithm to repre-sent P(x), we add additional samples according to this gradi-ent function. Specifically, we can compute a numerical CDFfrom g(x) and generate a fixed number of stratified samplesalong the domain (e.g. the x-axis) such that they occur atlocations where this function is large. Adding samples ac-

c© The Eurographics Association 2005.

Page 5: Adaptive Numerical Cumulative Distribution Functions for ...

J. Lawrence, et. al. / Adaptive Numerical CDFs for Importance Sampling

0

0.2

0.4

0.6

0.8

1

-3 -2 -1 0 1 2 3

Marginal CDFGradient

x

y

B CA D E

Figure 4: Efficiently approximating multi-dimensional dis-tributions requires computing a cascading set of 1Dmarginal and conditional CDFs. Here we show (top) asynthetic environment map that contains only two equalsized area light sources. We compute (bottom, red curve) amarginal CDF in x by summing the total energy across y.We also consider (bottom, green curve) the average gradientin the x-direction. We place non-uniformly spaced samplesaccording to the Douglas-Peucker algorithm at positions A,B, D and E and any additional points where the gradientfunction is large (i.e. at position C).

cording to the gradient guarantees that both P(x) is well rep-resented by the non-uniformly spaced samples and that theconditional CDFs computed for each region, P(y|xi), wellapproximate the variation present in the orthogonal dimen-sions. In the example in Figure 4, we additionally sample themarginal CDF at location C, separating the 2D distributioninto a total of four regions (AB, BC, CD and DE), where eachregion is now well approximated by a single CDF.

Lastly, we extend this sampling algorithm to arbitrary di-mensions by simply expanding the integrals over the entirerange of free variables (as opposed to just y for the 2D ex-ample considered above). For an N-dimensional distribution,p(x1,x2, . . .xN), both the marginal and conditional CDFs areproportional to the integral across the remaining free vari-ables (note: we omit the normalization constant for clarity):

p(xi|x1 . . .xi−1) ∝Z

−∞

dxi+1 . . .

Z

−∞

dxN p(x1 . . .xN),

and the gradient function would be computed similarly:

g(xi|x1 . . .xi−1) =Z

−∞

dxi+1 . . .

Z

−∞

dxN

∂p(x1 . . .xN)

∂xi

.

6. Evaluation of Algorithm

In general, global illumination algorithms perform numeri-cal integration of the rendering equation:

Lo(x,ωo) = Le(x,ωo)+Z

Ω2π

dωi Li(x,ωi)ρ(x,ωi,ωo)(ωi ·n).

A common approach to estimating the value of this in-tegral is to perform Monte Carlo integration over the spaceof incoming directions. Because the entire integrand is usu-ally not known a priori, a reasonable strategy is to sampleaccording to the terms that are known. For example, if theincident illumination Li is represented by an environmentmap, we may perform environment sampling. BRDF sam-pling, on the other hand, generates samples according to ei-ther ρ itself or ρ ·(ωi ·n). Although algorithms exist for sam-pling BRDFs and environment maps, these functions pro-vide a convenient platform to evaluate our representation.Moreover, our approach has several desirable properties thatthese existing techniques lack. These enable novel applica-tions that we present in Section 7.

6.1. Environment Map Sampling

One direct approach for generating samples according to ameasured environmet map [Deb98], is simply to compute afamily of numerical 1D CDFs directly from the 2D spheri-cal function [PH04]. Recall that one CDF will quantify thedistribution along φ, P(φ) and a set of 1D CDFs will controlthe distribution of samples along θ at each sampled locationof φ, Pi(θ|φi). These are derived from the intensity of eachpixel in the environment map (i.e. weighted average of colorvalues) using the method described in Section 3.

If the resolution of these CDFs is proportional to that ofthe environment map (as it should be to avoid aliasing) thisrepresentation will be slightly larger then the original mea-sured dataset itself. Therefore, there is significant opportu-nity for compression using our adaptive representation. Fig-ure 5 shows false-color visualizations on a logarithmic scaleof the full-resolution 1000×1000 (θ×φ) PDF of the GraceCathedral environment (http://www.debevec.org/Probes/),together with 16×16 and 64×64 approximations using bothuniform and non-uniform sample selection. As comparedto uniform sampling, adaptive sample placement results ina significantly more accurate approximation of the originaldistribution.

Figure 6 compares the error of our adaptive numericalrepresentation with uniform sample placement on two dis-tributions with qualitatively different behaviors. The uppergraphs show a single scanline (i.e. varying phi for a constanttheta) of the environment map, while the graphs at bottomplot the RMS error of the approximation as a function of thenumber of samples used (note that the horizontal axis is log-arithmic). At left, we consider a relatively smooth function.In this case, the gain from nonuniform placement of samples

c© The Eurographics Association 2005.

Page 6: Adaptive Numerical Cumulative Distribution Functions for ...

J. Lawrence, et. al. / Adaptive Numerical CDFs for Importance Sampling

(a) Grace Cathedral (b) Optimal ProbabilityLight Probe Distribution

(c) Distribution w/ 16×16 (d) Distribution w/ 16×16Uniform Samples Non-Uniform Samples

(e) Distribution w/ 64×64 (f) Distribution w/ 64×64Uniform Samples Non-Uniform Samples

Figure 5: False-color visualizations of spherical probabilitydensity functions on a logarithmic scale (red = largest prob-ability, green = smallest probability). Directions are mappedto the unit circle according to the parameterization used byDebevec [Deb98]. (a) A measured environment map of theinside of Grace Cathedral. (b) The probability density result-ing from using a numerically tabulated CDF sampled uni-formly at the same resolution of the original map. The prob-ability distribution of numerical CDFs computed from (c)16× 16 uniform samples (d) 16× 16 non-uniform samples(e) 64 × 64 uniform samples and (f) 64 × 64 non-uniformsamples.

is relatively modest. At right, we show a “peakier” functionthat is easier to compress with nonuniform sample place-ment. In this example, our adaptive representation reducesthe number of samples required at equal approximation er-ror by a factor of 16 compared to uniform downsampling.

0

0.25

0.5

-3.14 -1.57 0.00 1.57 3.14

Pro

babi

lity

Phi

Beach

0.0

2.0

4.0

-3.14 -1.57 0.00 1.57 3.14Phi

St. Peter’s

0

0.01

0.02

0.03

8 16 32 64 128 256

RM

S E

rror

of P

DF

Number of Samples

UniformAdaptive

0

0.1

0.2

0.3

8 16 32 64 128 256Number of Samples

UniformAdaptive

Figure 6: Two different probability distribution functionsand the RMS error in approximating them using differentnumbers of points and different sampling strategies. The dif-ferent sampling algorithms use either uniform or adaptiveplacement of sample locations.

6.2. BRDF Sampling

The BRDF gives the ratio of reflected light to incidentlight for every pair of incoming and outgoing directions:ρ(ωo,ωi). For glossy materials, it is advantageous to sam-ple the environment according to the distribution of energyin the BRDF. Because this is a 4D function (3D if the BRDFis isotropic), a tabular representation at a modest resolutionwould still be quite large. Consequently, we apply our adap-tive representation to the task of efficiently storing numericalCDFs derived from measured BRDFs.

We compared the size and accuracy of this representationwith a standard approach of pre-computing the CDFs at theirfull resolution [Mat03] for the same set of viewing directions(Figure 7). We evaluated the efficiency of generating sam-ples using an adaptive numerical CDF computed from twomeasured BRDFs [MPBM03]: nickel and metallic-blue.

For these results, we first reparameterized the BRDF intoa view/half-angle frame in order to maximize the redun-dancy among slices of the function giving greater oppor-tunity for compression [LRR04]. Each uniformly-sampledCDF had a resolution of 32 × 16 × 256 × 32 (θo × φo ×θh × φh) and occupied 65MB. Here, θh and φh are the el-evation and azimuthal angles of the half-angle vector re-spectively. To compute the corresponding adaptive numer-ical CDFs required, on average, roughly 30 samples in θhand 10 samples in φh. Using the Douglas-Peucker algorithm,these adaptive samples were selected from an initial set of2048× 1024 (θh × φh) uniformly-spaced samples—a reso-lution prohibitively expensive for the fully tabulated CDFs.It required 20 minutes of processing time to compute theadaptive representation for each BRDF.

c© The Eurographics Association 2005.

Page 7: Adaptive Numerical Cumulative Distribution Functions for ...

J. Lawrence, et. al. / Adaptive Numerical CDFs for Importance Sampling

Measured Nickel BRDF

Original (65MB) Compressed (3.9MB)

Measured Metallic-Blue BRDF

Original (65MB) Compressed (2.3MB)

Figure 7: BRDF importance sampling with adaptive numer-ical CDFs. We compare the variance in images rendered us-ing a path tracer that generates samples using the fully tab-ulated CDF and the adaptive CDF. In all cases we estimatethe radiance with 80 paths/pixel. We also list the total size ofthe probability representation below each image.

We found that for these BRDFs, sampling the adaptivenumerical CDF is nearly as efficient as the full tabular ap-proach. For the measured nickel BRDF, the compact CDFactually produces slightly less variance in the image becausethe uniform sampling was not sufficiently dense to capturethe very sharp highlight.

7. Novel Applications

In this section we present a new algorithm for sampling il-lumination from an environment map according to the localorientation of the surface. Additionally, we demonstrate howour representation facilitates multiple importance samplingof both illumination and the BRDF.

7.1. Local Environment Map Sampling

Using adaptive numerical CDFs, we introduce a novel algo-rithm for sampling an environment map in an orientation-dependent manner. In previous methods of sampling envi-ronment maps, incoming directions are drawn from a single

100%

42%

18%

7.8%

3.3%

(a) Illumination (b) SamplingEfficiency

Figure 8: For some orientations and lighting, sampling froma single distribution will be inefficient because most of theenergy is occluded by the horizon. (a) We examine this in-efficiency for an example in which the majority of light isabove and slightly behind the object being rendered. (b) Afalse-color image visualizes the percentage of samples thatwill be generated above the horizon and, consequently, makea positive contribution to the radiance estimate at that pixel.In many regions of this image only 5% of the samples aregenerated above the horizon.

spherical distribution [ARBJ03, KK03, ODJ04, PH04]. Thisapproach is inefficient when a significant amount of light inthe scene happens to fall below the horizon for a large num-ber of pixels. In Figure 8, there are many regions of the im-age where as few as 5% of the samples are generated abovethe horizon—this also indicates the inefficacy of standardtechniques like rejection sampling to address this problem.Furthermore, sampling from a single spherical distributioncannot consider the cosine term that appears in the render-ing equation (i.e. max(0,n ·ωi)). Accounting for this cosine-falloff would require sampling from a 4D function (i.e. thereare two degrees of freedom in the incoming direction andtwo in the normal direction). We show several 2D slices ofthis function for different normal directions in Figure 9. Aswith BRDFs, representing a 4D distribution even at a modestresolution could require prohibitively large storage.

We can store the 4D distribution that results from mod-ulating an environment map by the cosine term using ouradaptive CDF representation. During rendering, each pixelcorresponds to a normal direction that becomes an index intothe 4D distribution, producing a 2D distribution over incom-ing directions that we sample from. In our experiments, weevaluated the local environment map distribution at 25×10(φ× θ) normal directions and 1000× 2000 (φ× θ) incom-ing directions. Storing this tabular CDF directly would re-quire approx. 4GB of space. In contrast, our representationrequires 10-20MB of storage and 1-2 hours of compute timeto provide an acceptable approximation.

We compared local environment map sampling with jit-tered sampling of a stratified representation [ARBJ03] andsampling from a uniformly-spaced CDF [PH04] (see Fig-ure 10). Jittered sampling (Figure 10 left) performed the

c© The Eurographics Association 2005.

Page 8: Adaptive Numerical Cumulative Distribution Functions for ...

J. Lawrence, et. al. / Adaptive Numerical CDFs for Importance Sampling

nθ = 0, nφ = 0 nθ = π, nφ = 0

nθ = 2.35, nφ = 1.57 nθ = 2.35, nφ = 4.71

Figure 9: False-color visualizations of several CDFs com-puted at different surface orientations. Each distribution isvisualized on a logarithmic scale as in Figure 5. For eachsurface normal considered we clip the environment map tothe visible hemisphere and multiply each radiance value by(n ·ωi) before computing an adaptive CDF representation ofthe resulting 4D distribution.

worst mainly because this technique is ineffective for suchlow sample counts (note: we are using only 20 sampleshere). Moreover, there is significant error due to the biasintroduced by approximating each strata with a radial disk.Although unbiased jittering is not impossible to achieve, itis not a simple extension to published algorithms and hasnot been reported in previous work. We also compared ouralgorithm to sampling from a uniformly-sampled CDF andrejecting those samples that fell below the horizon [PH04](Figure 10 middle). This strategy is most comparable inquality to our own, but because it does not account for thehorizon-clipped cosine term in the rendering equation, itfails to achieve the same rate of convergence. Quantitatively,local environment map sampling achieved approx. 5 timeslower variance than sampling a single CDF computed at fullresolution and approx. 20 times better than jittered samplingfor these test scenes.

7.2. Multiple Importance Sampling

In practice, neither the BRDF nor the incident illuminationalone determine the final shape of the integrand in the ren-dering equation. Therefore, it is critical that a CDF repre-sentation supports multiple importance sampling [VG95].

St. Peter’s Basilica

Galileo’s Tomb

Grace Cathedral

Jittered Full CDF LocalSampling With Rejection Env. Sampling

Figure 10: We compare the variance of a Monte Carlo esti-mator computed according to (left column) jittered samplingof a stratified representation [ARBJ03], (middle column) auniformly-sampled CDF [PH04] where we reject samplesthat fall below the horizon and (right column) using ourlocal environment map sampling algorithm. We have ren-dered a perfectly diffuse object at 20 samples/pixel in threedifferent environments that all exhibit high-frequency light-ing. Cutouts include a magnified region of the image and avariance image (note: these are false-color visualizations ofthe logarithm of RMS error in image intensity where black≤ 0.135 and red ≥ 20.08). All three sampling methods re-quired approximately 15 seconds to render these images.

The main criterion this imposes is that the representationmust allow efficient computation of the probability of a di-rection that was not generated from the distribution itself.Algorithms that decompose environment maps into non-overlapping strata [ARBJ03, KK03, ODJ04], for example,do not readily provide this property because determining theprobability of an arbitrary direction would require searchingover the strata. Although not impossible, making this searchefficient has not previously been demonstrated and could beone direction of future work. With our adaptive numericalCDF, however, the probability of an arbitrary direction canbe computed in O(logN) where N is the number of non-

c© The Eurographics Association 2005.

Page 9: Adaptive Numerical Cumulative Distribution Functions for ...

J. Lawrence, et. al. / Adaptive Numerical CDFs for Importance Sampling

Cook-Torrance BRDF in the Beach Environment

Measured Nickel BRDF in Grace Cathedral Environment

Measured Plastic BRDF in Galileo’s Tomb Environment

Illumination BRDF Environment Relative CombinedSampling Sampling Efficiency Sampling

Figure 11: Multiple importance sampling using adaptive numerical CDFs computed from both BRDFs and image-based light-ing. The 4th column visualizes the relative reduction in variance using environment sampling vs. BRDF sampling: red = BRDFsampling has 8x less variance than environment map sampling, blue = environment sampling has 8x less variance than BRDFsampling. For these scenes, sampling from either the BRDF or environment alone will not effectively reduce variance over theentire image and performing multiple importance sampling is critical.

uniformly spaced samples. Moreover, because of the com-pression ratios possible with our representation, N is typ-ically small enough to make this operation inexpensive inpractice.

We show several scenes for which multiple importancesampling is critical (Figure 11). In these results, we usethe balance heuristic introduced by [VG95] to combine 50samples of the BRDF with 50 samples of the environment.The BRDF samples are generated using our adaptive CDFdiscussed in Section 6.2 and the illumination samples aregenerated using local environment map sampling (see Sec-tion 7.1). To demonstrate the benefit of a representation thatsupports multiple importance sampling, we also comparethese images to those rendered using 100 samples drawnfrom either the BRDF or environment alone.

8. Conclusions and Future Work

We have applied traditional curve approximation algorithmsto compress the size of numerically tabulated CumulativeDistribution Functions (CDFs) for efficient importance sam-pling. This representation results in a drastic reduction in thestorage cost of a numerical CDF without sacrificing signifi-cant accuracy in the reconstructed Probability Density Func-tion (PDF). We investigated the benefit of using adaptivenumerical CDFs to sample image-based lighting and mea-sured BRDFs. We also introduced local environment mapsampling, which accounts for the orientation dependence ofthe illumination. Lastly, we have demonstrated multiple im-portance sampling using adaptive numerical CDFs to repre-sent distributions for both the BRDFs and environment mapin the scene.

c© The Eurographics Association 2005.

Page 10: Adaptive Numerical Cumulative Distribution Functions for ...

J. Lawrence, et. al. / Adaptive Numerical CDFs for Importance Sampling

Because of the generality of our adaptive representation,it has potential applications in many other problems that relyon sampling from tabulated measured data. For example,the technique might be used to represent light fields, whichwould then be used to illuminate a scene or to sample fromthe full product of a cosine-weighted environment map witha measured BRDF. A second class of applications might in-volve synthesis of textures, video, or animation based onprobability distributions learned by example.

9. Acknowledgements

This work was supported in part by grants from the Na-tional Science Foundation (Szymon Rusinkiewicz: CCF-0347427, Practical 3D Model Acquisition; Ravi Ramamoor-thi: CCF-0446916, Mathematical and Computational Funda-mentals of Visual Appearance for Computer Graphics, CCF-0305322: Real-Time Rendering and Visualization of Com-plex Scenes), Alfred P. Sloan research fellowships to Szy-mon Rusinkiewicz and Ravi Ramamoorthi and a NDSEGfellowhip to Jason Lawrence.

References

[ARBJ03] AGARWAL S., RAMAMOORTHI R., BE-LONGIE S., JENSEN H. W.: Structured importance sam-pling of environment maps. In SIGGRAPH 03 (2003),pp. 605–612. 2, 7, 8

[Arv95] ARVO J.: Stratified sampling of spherical trian-gles. In SIGGRAPH 95 (1995), pp. 437–438. 2

[Arv01] ARVO J.: Stratified sampling of 2-manifolds. InSIGGRAPH 2001 Course Notes, volume 29 (2001). 2

[CC96] CHAN W., CHIN F.: On approximation of polyg-onal curves with minimum number of line segments orminimum error. Int. J. Comput. Geom. Appl. 6 (1996),59–77. 3

[CD03] CHEN D. Z., DAESCU O.: Space-efficient al-gorithms for approximating polygonal curves in two-dimensional space. International Journal of Computa-tional Geometry & Applications 13, 2 (2003), 95—111.3

[CPB03] CLAUSTRES L., PAULIN M., BOUCHER Y.:Brdf measurement modeling using wavelets for efficientpath tracing. Computer Graphics Forum 12, 4 (2003), 1–16. 2

[Deb98] DEBEVEC P.: Rendering synthetic objects intoreal scenes: bridging traditional and image-based graph-ics with global illumination and high dynamic range pho-tography. In Proceedings of the 25th annual conferenceon Computer graphics and interactive techniques (1998),ACM Press, pp. 189–198. 5, 6

[DP73] DOUGLAS D., PEUCKER T.: Algorithms for thereduction of the number of points required to represent a

digitized line or its caricature. The Canadian Cartogra-pher 10, 2 (1973), 112–122. 2, 3

[Goo94] GOODRICH M. T.: Efficient piecewise-linearfunction approximation using the uniform metric: (pre-liminary version). In Proceedings of the tenth annual sym-posium on Computational geometry (1994), ACM Press,pp. 322–331. 3

[HS92] HERSHBERGER J., SNOEYINK J.: Speeding upthe douglas-peucker line-simplification algorithm. In Pro-ceedings of the 5th International Symposium on SpatialData Handling (Charleston, South Carolina, 1992), vol. 1,pp. 134–143. 2, 3

[KK03] KOLLIG T., KELLER A.: Efficient illuminationby high dynamic range images. In Eurographics Sympo-sium on Rendering 03 (2003), pp. 45–51. 2, 7, 8

[LF97] LALONDE P., FOURNIER A.: Generating reflecteddirections from brdf data. Computer Graphics Forum 16,3 (1997), 293–300. 2

[LRR04] LAWRENCE J., RUSINKIEWICZ S., RA-MAMOORTHI R.: Efficient BRDF importance samplingusing a factored representation. ACM Transactions onGraphics (ACM SIGGRAPH 2004) 23, 3 (2004). 2, 6

[Mat03] MATUSIK W.: A Data-Driven Reflectance Model.PhD thesis, Massachussetts Institute of Technology, 2003.6

[MPBM03] MATUSIK W., PFISTER H., BRAND M.,MCMILLAN L.: A data-driven reflectance model. In SIG-GRAPH 03 (2003), pp. 759–769. 6

[ODJ04] OSTROMOUKHOV V., DONOHUE C., JODOIN

P.-M.: Fast hierarchical importance sampling with bluenoise properties. ACM Transactions on Graphics 23, 3(2004), 488–495. Proc. SIGGRAPH 2004. 2, 7, 8

[PH04] PHARR M., HUMPHREYS G.: Physically BasedRendering : From Theory to Implementation. MorganKaufmann, 2004. 5, 7, 8

[Ros97] ROSIN P. L.: Techniques for assessing polygonalapproximations of curves. IEEE Transactions on PatternAnalysis and Machine Intelligence 19, 6 (1997), 659–666.3

[Sch94] SCHEAFFER R. L.: Introduction to Probabilityand Its Applications (Statistics), 2nd ed. Duxbury Press,1994. 3

[Vea97] VEACH E.: Robust Monte Carlo Methods forLight Transport Simulation. PhD thesis, Stanford Uni-versity, 1997. 2, 4

[VG95] VEACH E., GUIBAS L.: Optimally combiningsampling techniques for Monte Carlo rendering. In SIG-GRAPH 95 (1995), pp. 419–428. 1, 8, 9

c© The Eurographics Association 2005.