<<

Eurographics Symposium on Rendering 2017 Volume 36 (2017), Number 4 P. Sander and M. Zwicker (Guest Editors)

Area-Preserving Parameterizations for Spherical Ellipses

Ibón Guillén1,2 Carlos Ureña3 Alan King4 Marcos Fajardo4 Iliyan Georgiev4 Jorge López-Moreno2 Adrian Jarabo1

1Universidad de Zaragoza, I3A 2Universidad Rey Juan Carlos 3Universidad de Granada 4Solid Angle

Abstract

We present new methods for uniformly sampling the solid angle subtended by a disk. To achieve this, we devise two novel -preserving mappings from the unit square [0,1]2 to a spherical ellipse (i.e. the projection of the disk onto the unit ). These mappings allow for low-variance stratified sampling of direct illumination from disk-shaped light sources. We discuss how to efficiently incorporate our methods into a production renderer and demonstrate the quality of our maps, showing significantly lower variance than previous work. CCS Concepts •Computing methodologies → Rendering; Ray tracing; Visibility;

1. Introduction SHD15]. So far, the only practical method for uniformly sampling the solid angle of disk lights is the work by Gamito [Gam16], who Illumination from area light sources is among the most impor- proposed a rejection sampling approach that generates candidates tant lighting effects in realistic rendering, due to the ubiquity of using spherical quad sampling [UFK13]. Unfortunately, achieving such sources in real-world scenes. Monte Carlo integration is the good sample stratification with this method requires special care. standard method for computing the illumination from such lumi- naires [SWZ96]. This method is general and robust, supports arbi- In this paper we present a set of methods for uniformly sam- trary reflectance models and geometry, and predictively converges pling the solid angle subtended by an oriented disk. We exploit the to the actual solution as the number of samples increases. Accu- fact that a disk, as seen from a point, is bounded by an elliptical rately sampling the illumination from area light sources is crucial [Ebe99] and thus its solid angle defines a spherical ellipse for minimizing the amount of noise in rendered images. whose properties have been analyzed in depth [Boo44]. This allows us to define two different exact area-preserving mappings that can be Estimating the direct illumination at a point requires sampling used to transform stratified unit-square sample patterns to stratified the radiance contribution from directions inside the solid an- directions on the subtended spherical ellipse. We describe how to gle subtended by the given luminaire. A sensible strategy is to efficiently implement these mappings in practice and demonstrate distribute those directions uniformly. This, however, is hard to the lower variance they achieve compared to previous work. achieve for an arbitrary-shaped luminaire, as it involves first com- puting and then uniformly sampling its subtended solid angle. 2. Problem Statement and Previous Work Specialized methods have been proposed for spherical [Wan92], triangular [Arv95, Ure00], rectangular [UFK13], and polygonal Our goal is to compute the radiance Ls scattered at a point o in lights [Arv01]. These elaborate solid angle sampling techniques are direction ωbo due to irradiance from a disk-shaped luminaire D. This more computationally expensive than naïve methods that uniformly can be written as an over the solid angle ΩD subtended by sample the surface area of the luminaire. However, in most non- the luminaire: trivial scenes, where the sample contribution evaluation is orders Z Ls(o,ωo) = f (o,x ,ωo,ω)dµ(ω), (1) b oωb b b b of magnitude more costly than the sample generation, their lower ΩD variance improves overall efficiency. where x is the first visible point from o in direction ω, µ is the oωb b Few papers have focused on sampling oriented disk-shaped light solid angle measure, and the contribution function f is sources. Disk lights are important in practice, both for their artistic ( Le(x,−ωb) fs(o,ωbo,ωb)|ωb · nbo|, if o is on a surface, expressiveness and their use in a number of real-world scenarios, f (o,x,ωo,ω)= b b L (x,−ω)ρ(o,ω ,ω)T(o,x), if o is in a medium, generally including man-made light sources such as in architectural e b bo b lighting, film and photography. Moreover, disk lights form the base with fs, nbo, and ρ being respectively the BSDF, surface , for some approximate global illumination algorithms [HKWB09, and medium phase function (times the scattering coefficient) at o.

c 2017 The Author(s) Computer Graphics Forum c 2017 The Eurographics Association and John Wiley & Sons Ltd. Published by John Wiley & Sons Ltd. Guillén et al. / Area-preserving parameterizations for spherical ellipses

(a) Area sampling [SC97] (b) Gamito [Gam16] (c) Our parallel mapping (d) Our radial mapping (e) Our ld-radial mapping Figure 1: A stratified unit-square sample pattern transformed onto the surface of a disk using existing techniques and our proposed maps (with solid angle projections on the bottom row). The points are colored according to their canonical [0,1]2 coordinates to illustrate the continuity of the maps. Gamito’s rejection sampling does not allow for direct stratification, so we show the candidate low-discrepancy pattern for that case.

Le(x, −ωb) is the luminaire emission radiance at x in direction −ωb Area-preserving solid angle maps have been developed for trian- and T(o,x) is the medium transmitance between o and x. gles [Arv95] and rectangles [UFK13]. For sampling the solid angles of disks, Gamito [Gam16] proposed to use a rectangle map [UFK13] Solid angle sampling. Monte Carlo estimation of (1) followed by rejection sampling. This technique cannot be used with using N randomly sampled directions ωbi has the following form: fixed-size canonical point sets, and needs a low-discrepancy se- N f (o,x ,ω ,ω ) quence capable of progressively generating stratified sample candi- 1 oωi bo bi Ls(o,ωo) ≈ b , (2) dates. The rejection sampling also makes it very difficult to achieve b N ∑ p(ω ) i=1 bi good high-dimensional stratification in the presence of other dis- where p(ωb) is the pdf for sampling ωb. The choice of sampling tributed effects, e.g. volumetric scattering, where the coordination density p is important, since a lower variation of f /p makes the of the sample patterns of different effects is desired. In this paper we estimator more efficient [SWZ96]. For disk lights the traditional on area-preserving maps for disks that do not require rejection choice is uniform density over the luminaire surface D. This area sampling and work with any canonical sample pattern. Figure1 sampling technique is easy to implement and its resulting solid compares our proposed maps against existing techniques. angle pdf is p(ω) = ko−x k/(A(D)|ω · nx |), where A(D) is the b oωb b b oωb For surface scattering points o, an even better strategy is to im- area of D. This pdf can lead to very high variance in the radiance portance sample the term |ωb · nbo| in the contribution f . Such uni- estimator (2), especially when the point o is close to the luminaire. form sampling of the projected solid angle has been described by Our goal in this paper is to devise uniform solid angle sampling Arvo [Arv01] for polygonal lights. Extending our approach to pro- techniques that generate directions ωb with constant density p(ωb) = jected solid angle sampling is an interesting avenue for future work. 1/|ΩD|, yielding estimators with significantly lower variance than uniform area sampling. 3. Solid Angle Sampling of an Oriented Disk Area-preserving mapping. Sample stratification can greatly im- We base our sampling techniques on the key observation that the prove the efficiency of Monte Carlo estimators [Shi91, SK13, projected area of any ellipse, including a disk, forms a spherical ∗ PSC 15]. Most existing stratification techniques generate samples ellipse on the unit sphere around the shading point (Figure2). Thus, 2 in the canonical unit square [0,1] , however our goal is to sample in order to sample the solid angle subtended at point o by an oriented directions inside the solid angle ΩD. Therefore, in order to take disk with center c, normal nb, and radius r, we will uniformly sample advantage of these techniques, we need to find a mapping M from a point q on the spherical ellipse and then backproject it to the disk. 2 2 [0,1] to ΩD such that for any two regions R1,R2 ⊆ [0,1] : A(R ) µ(M(R )) Spherical ellipse. To compute the subtended spherical ellipse, we 1 = 1 , first define a local reference frame for the disk Rd = (xd,yd,zd): A(R2) µ(M(R2)) b b b c − o A µ where is the area measure, and is the solid angle measure as bzd = −nb, ybd = bzd × , xbd = ybd ×bzd. (3) in Equation (1). We call such maps area-preserving maps. This kc − ok key property makes it possible to generate stratified samples in ΩD, We then take the boundary disk coordinates y0 and y1 w.r.t. the ybd because stratification is far more easily achieved in [0,1]2. axis and project them onto the sphere (Figure2, left). From the

c 2017 The Author(s) Computer Graphics Forum c 2017 The Eurographics Association and John Wiley & Sons Ltd. Guillén et al. / Area-preserving parameterizations for spherical ellipses

y1 ybd 0 ye ze y1 b b c 0 β α yh 0 y0 ze yh b 0 0 z0 a z zh 1 xd b 00 b o yd x 0 zd x1 b 1 b b at y0 x0 t xbd x0 xe bzd o b ybe

Figure 2: Left: The disk’s local reference system Rd = (xbd,ybd,bzd) and the local coordinates required to characterize its solid angle projection. Center: Projections of the relevant coordinates onto the unit sphere, defining the spherical ellipse and its local reference system Re = (xbe,ybe,bze), where xbe ≡ xbd. Right: The spherical ellipse is defined by its semi-arcs α and β or, equivalently, by its semi-axes a and b in Re. The ellipse (in red), which lies on a tangent to the sphere at bze (i.e. the spherical ellipse center), is defined by its semi-axes at and bt.

0 0 0 0 coordinates y0, y1, z0, z1 of these projections (Figure2, middle) 3.1. Area-preserving mappings we can compute the spherical ellipse center: it is the result z of be Our new mappings are based on a generalization of the so-called normalizing the vector (0,y0 ,z0 ), where y0 = (y0 + y0 )/2 and z0 = h h h 0 1 h Hat-Box theorem. It states that the area of a region on (z0 + z0 )/2. (Note that z in general does not coincide with the 0 1 be the sphere between two parallels is equal to the area of that region’s spherical projection of the disk center c.) Reprojecting z onto the be projection onto a perpendicularly aligned bounding . This disk (Figure2, left), the obtained y coordinate defines a chord x x h 0 1 area-preserving property also holds for arbitrarily shaped regions on parallel to x . The chord endpoint projections onto the sphere, with bd the sphere (Figure3, left). The latter property was used by Tobler x -coordinates x0 and x0 , allow us to compute the lengths of the bd 0 1 et al. [TNSP98] to define compact metallic BRDFs (they provide a ellipse’s semi-axes, a and b, and semi-arcs, α and β (Figure2, right): demonstration). It was also used (although not explicitly stated) by 1 q Arvo [Arv95] and Ureña et al. [UFK13] to define area-preserving pa- a = x0 , b = (y0 − y0 )2 + (z0 − z0 )2, (4) 1 2 1 0 1 0 rameterizations for spherical and rectangles, respectively. −1 −1 α = sin a, β = sin b. (5) We use this cylindrical projection property to derive our area- preserving mappings for a spherical ellipse centered on the z axis. Finally, from α and β we can compute the semi-axes at = tanα and be The ellipse can be radially projected onto a cylinder, obtaining a bt = tanβ of the ellipse tangent to the sphere at ze (Figure2, right). b cylindrical ellipse. Two different unit-radius can be used. In the following, we use both the spherical and the tangent ellipses One is aligned with the ybe axis (Figure3, center), which we call a to derive two different mappings for uniformly sampling points q parallel map. The second one is aligned with the bze axis (Figure3, on the spherical ellipse which we then map to the surface of the disk. right), which we call a radial map. We also propose a variant of the These mappings operate in a coordinate system Re = (xbe,ybe,bze), radial map that uses Shirley’s low-distortion map [SC97], which we where xbe ≡ xbd and ybe = bze × xbe, shown in Figures2 and3. call a low-distortion radial map, or ld-radial map.

Maps overview. The basic idea behind our maps is to first select a x x xbe point p on the cylindrical ellipse as a function of a canonical unit- b be 2 square point (ε1,ε2) ∈ [0,1] . We then project p back onto the sphere perpendicularly to the cylinder axis (see Figure3, left) to get the q p point q. Let (φ,h) be the cylindrical coordinates of p. We first obtain y z b y be ybe bze be the azimuth angle φ by finding the lateral slice on the cylindrical bz ellipse whose solid angle is ε1ΩD (Figure4). With φ fixed, the altitude h is computed as a simple linear interpolation using ε2 along the lateral segment that is the intersection between the lateral Figure 3: Left: Any region (blue) on the unit sphere can be radially plane at angle φ and the cylindrical ellipse (green projected to another region (red) on a cylinder aligned with any axis in Figure4). The sampling of φ involves numerical inversion of (here yb). Any point q on the sphere can be expressed in cylindrical incomplete elliptic , as we show next. coordinates as (φ,h,r) (azimuth angle, altitude, distance from cen- ter). This point can be mapped to a point p on the unit cylinder with 3.2. Parallel Mapping coordinates (φ,h). The mapping preserves the of both finite and differential regions. Thus, to obtain a point on the spherical Our parallel mapping, whose cylinder axis is aligned with xbe, oper- region, we can sample inside the cylindrical region and project back ates by considering a portion (sector) of the cylindrical ellipse – the onto the sphere. Center: A spherical ellipse (blue), with center on red-shaded region in Figure4, left. This region is determined by the the bze axis, projected onto a cylinder aligned with the ybe axis. Right: green line segment, whose endpoints have cylindrical coordinates The same spherical ellipse projected onto a bze-axis aligned cylinder. (φp,hp) and (φp,−hp). The angle φp goes from −β to β, since the In this case, the projected region (red) has a ring-like . spherical ellipse is centered on the bze axis.

c 2017 The Author(s) Computer Graphics Forum c 2017 The Eurographics Association and John Wiley & Sons Ltd. Guillén et al. / Area-preserving parameterizations for spherical ellipses

Due to the Hat-Box theorem, the differential solid angle covered xe by the green segment is equal to its length, 2h , which is in fact a b p xbe function of φp. Thus, the solid angle subtended by the red region hp onto the spherical ellipse (the blue region in Figure4, left) can be written as the integral of the segment length: φr Z φp φp 0 0 ye ze ye Ωp(φp) = 2hp(φp)dφp, (6) b b hr b −β bze where the full solid angle of the spherical ellipse is ΩD = Ωp(β). Due to symmetry, for any angle φp ∈[0,β] it holds hp(−φp) = hp(φp). + We use this to express Ωp(φp) as a sum of integrals Ωp (φp) over positive angles: Figure 4: Illustration of our parallel (left) and radial (right) maps. 2 ( + + Given a canonical sample (ε1,ε2) ∈ [0;1] , we first find the azimuth Ωp (β) + Ωp (φp) : φp ≥ 0 Ωp(φp) = , (7) angle φp, respectively φr, that cuts a region on the cylindrical ellipse +( ) − +(− ) < Ωp β Ωp φp : φp 0 with area ε1ΩD (in red, determined by the green line segment). A where sample point on the cylinder is then obtained by linearly interpolat- ing the green segment endpoints using . For the parallel map, the φ ε2 + Z p 0 0 Ωp (φp) = 2hp(φp)dφp. (8) endpoint cylindrical coordinates are (φp,−hp) and (φp,hp), with 0 φp ∈ [−β,β]. For the radial map, these coordinates are (φr,hr) and In AppendixA we derive an expression for hp(φp): (φr,1), with φr ∈ [0,2π] (we use φr ∈ [0,π/2] in each quadrant).

s 2 1 − (p + 1)sin φp hp(φp) = ct 2 , (9) 3.3. Radial Mapping 1 − (m p + 1)sin φp The parallel mapping presented in Section 3.2 involves two elliptic where integrals and introduces noticeable distortions (see the converging 2 2 1 at − bt at lines in Figure 1c), which can increase discrepancy and ruin any blue p = 2 , m = 2 , ct = q . (10) bt at + 1 2 noise properties present in the input unit-square sample distribution. 1 + at In this section we present an alternative radial mapping that uses a Substituting Equation (9) into Equation (8) and simplifying, we get: single elliptical integral and also exhibits less distortion. It is based

+ 2ct h i on the analysis of the spherical ellipse topology by Booth [Boo44]. Ωp (φp) = (1 − n)Π(n;ϕp|m) − F(ϕp|m) , (11) bt We will exploit the fact that the four quadrants of the spherical where F(ϕ|m) and Π(n;ϕ|m) are Legendre incomplete elliptic inte- ellipse are radially symmetric (see Figure2, right), so its total area grals of respectively the first and third kind, m ∈ [0,1), and can be expressed as ΩD = 4Ωr, with Ωr being the area of each   quadrant. Within a quandant, the azimuth angle is φr ∈ [0,π/2]. −1 tanφp 2 ϕp = sin , n = −bt . (12) bt We now consider a bounding cylinder aligned with the bze axis (Figure4, right). Specifically, we are interested in the lateral region Unfortunately, no closed-form expressions are known for F(ϕ|m) (in red in Figure5) that is the radial projection of a fraction of the and Π(n;ϕ|m), so Equation (11) must be evaluated numerically. spherical quadrant. This region is determined by the position of the green line segment whose endpoints have cylindrical coordinates Sampling. With the fractional spherical ellipse area Ωp character- (φr,hr) and (φr,1). The segment length is 1−hr, which is a function ized, we can map a point on the unit square (ε ,ε ) ∈ [0,1]2 to a 1 2 of φr. Similarly to Equation (6), we use the Hat-Box theorem to point on the spherical ellipse q. We first need to find the angle φp express the fractional quadrant area as the integral of this length: that satisfies Ωp(φp) = ε1ΩD, for which we need to evaluate the Z φr Z φr −1  0  0 0 0 Ωp . This function has no analytical form, so we Ωr(φr) = 1 − hr(φr) dφr = φr − hr(φr)dφr. (16) resort to numerically finding the roots of the equation 0 0 Using the Pythagorean theorem, we express hr(φr) as (see Figure5) Ωp(φp) − ε1ΩD = 0. (13) q 2 Having sampled φp, we get the point p on the cylindrical ellipse by hr(φr) = 1 − r (φr), (17) first computing hp(φp) using Equation (9) and then linearly interpo- where r(φ ) is the (planar) elliptical radius of the spherical ellipse lating the altitude coordinate between −h (φ ) and h (φ ) using ε : r p p p p 2 with the following expression, which we derive in AppendixB: p = (φp,(2ε2 − 1)hp(φp)) = (φp,h). (14) ab r(φr) = q . (18) Finally, the corresponding point q on the ellipse is obtained by 2 2 2 2 a sin φr + b cos φr radially projecting p onto the sphere (see Figure3, left):   p 2 p 2 Plugging (17) and (18) back into Equation (16), and q = h, 1 − h sinφp, 1 − h cosφp . (15) using Booth’s derivations [Boo44], we can now express the frac- Figure 1c shows the resulting map. tional quadrant area Ωr(φr) using Legendre’s incomplete elliptic

c 2017 The Author(s) Computer Graphics Forum c 2017 The Eurographics Association and John Wiley & Sons Ltd. Guillén et al. / Area-preserving parameterizations for spherical ellipses z integral of the third kind Π(n;ϕ|m), so it becomes be 2 b(1 − a ) α Ωr(φr) = φr − √ Π(n;ϕr|m), (19) 2 β a 1 − b Ωr(φr) where   2 2 2 2 −1 at a − b a − b ϕr =tan tanφr , n= , m= . (20) bt a2(1 − b2) 1 − b2

Above, ϕr is the parametric angle of the tangent ellipse, and n and hr(φr) m are the elliptic characteristic and module that characterize the b a [Boo52]. φr r(φr) xbe Unfortunately, as with Equation (11), no closed-form expression is known for the general-case incomplete elliptic integral of the third ybe kind, so we need to evaluate Equation (19) numerically. Figure 5: Illustration of our polar mapping. Projected perpendicu- Direct radial mapping. Having an expression for the fractional larly to its axis bze onto the xbeybe plane, the spherical ellipse forms spherical ellipse Ωr, we can map a unit-square point (ε1,ε2) ∈ a planar ellipse with semi-axes a = sinα and b = sinβ. We use the 2 [0,1] to a point q on the spherical ellipse. Below we only consider Pythagorean theorem to express the altitude hr(φr) of the cylindrical sampling the first ellipse quadrant (shown in Figure5); the entire projection of the spherical ellipse’s in terms of a, b, and φr. ellipse can be covered by flipping the xbe- and ybe-coordinates of q.  First, we need to find the azimuth angle φr ∈ [0, π 2 ] satisfying  4. Implementation Ωr(φr) − ε1 Ωr( π 2 ) = 0. (21) We have implemented our maps as custom sampling procedures for Since we do not have a method to analytically invert Ωr(φr), we disk lights in two different systems: the Mitsuba renderer [Jak10] compute φr by numerically finding the roots of the above equation. and the Arnold production renderer [Faj10]. Having sampled φr, we obtain point p on the cylindrical ellipse In order to sample from each mapping, we need to find the roots by first computing hr(φr) using Equation (17) and then linearly of Equations (13) and (21) respectively. Since the elliptic integrals interpolating the altitude coordinate between hr(φr) and 1 using ε2: they contain prevent analytical inversion, we resort to numerical  p = φr, (1 − ε2)hr(φr) + ε2 = (φr,h). (22) root finding using an iterative Newton-Raphson method. However, We find the corresponding point q on the ellipse by projecting this method can become very expensive, since for each iteration we need to numerically evaluate two and one incomplete elliptic p = (φr,h) using Equation (15) with swapped xbe- and bze-coordinates. Figure 1d shows the resulting map. integrals (for the parallel and radial mappings, respectively).

Low-distortion radial mapping. As seen in Figure 1d, the direct 4.1. Tabulation mapping from above resembles the classical planar Cartesian-to- polar mapping. As such, it also exhibits the same distortion – the In order to reduce the significant cost of Newton-Raphson over area lines converging at the ellipse center, which does not preserve rela- sampling (up to 10× in simple scenes; see Figure6) and avoid the tive distances between samples and damages their stratification. In expensive numerical inversion, we approximate our radial mapping the planar case, the mapping of Shirley and Chiu [SC97] rectifies by tabulating Equation (19). We choose to tabulate this mapping as this distortion by warping concentric squares into concentric disks. it introduces less distortion in the output sample distribution than To achieve the analogous mapping on the spherical ellipse, we first the parallel one, as shown in Figure1. warp our input unit-square samples (ε ,ε ) to the unit disk using 1 2 We can write the fractional solid angle 0 = ( )/ ( /2) as a Shirley and Chiu’s concentric mapping. We then move back to the Ωr Ωr φr Ωr π function of ∈ [0, /2], ∈ [0, ] and ∈ [0, /2]. We can tabulate unit square using the following inverse polar mapping: α π β α φr π this function by discretizing each of the three parameters, producing  θ π a 3D array of values. A quick binary search based on φr (combined 2 : θ ∈ [0, 2 )  π with interpolation) then allows us to get approximate values of Ω0  θ − π/2 r  π 1 − 2 : θ ∈ [ 2 ,π) with good accuracy. However, storing such a table would require u = π , v = r2. (23) 0 θ − π 3π a large amount of memory. To address this, we reparametrize Ωr 2 : θ ∈ [π, ) 0  π 2 in terms of α, the ratio β = β/α (which is in [0,1]), and φr. This  θ − 3/2π 0 1 − 2 : θ ∈ [ 3π ,2π) version of Ωr has very low variation w.r.t. to α, so we can remove π 2 this parameter altogether, reducing the tabulation to a 2D array of 0 0 The result of this detour is a unit-square point set that, when warped Ωr values for a set of β and φr values. Each entry in this array using the classical (forward) planar polar mapping, gives Shirley and corresponds to a spherical defined by the fraction of φr Chiu’s low-distortion concentric disk distribution. We, instead, feed covered by the given entry and the value of θ(φr) at the start of this unit-square set to our direct radial mapping to get a concentric- the entry’s interval, which can be easily sampled [Arv95]. This like distribution on the spherical ellipse, which is shown in Figure 1e. approximation causes some generated samples to lie outside the

c 2017 The Author(s) Computer Graphics Forum c 2017 The Eurographics Association and John Wiley & Sons Ltd. Guillén et al. / Area-preserving parameterizations for spherical ellipses spherical ellipse, which we reject. Note that this rejection ensures unbiasedness; however, for practical reasons our production renderer 10−1 10 implementation simply assigns zero weight to such invalid samples, −2 10 1 −3 resulting in a slight understimation of the illumination. We have 10 1 10− 10−4 found the rejection ratio to be negligible, the storage requirement 10−2 10−5 −3 low, and the accuracy satisfactory for realistic rendering. In our −6 10 MSE 10 2 −4 −7 10 implementation we use a 2D table with resolution 1024 , which we 10 −8 −5 found to be accurate enough to provide an insignificant difference 10 10 10−9 10−6 in variance compared to the analytic solution. Finally, note that in 1 10 102 103 104 1 101 102 103 104 104 104 order to compute the samples’ pdf p(ω) = 1/|ΩD|, we still need to b 3 10 3 compute ΩD numerically. This computation is amortized among all 10 102 samples for a given shading point. 102 10 10 1

10−1 1 4.2. Efficiency Time (seconds) −2 1 10 10− 1 10 102 103 104 1 10 102 103 104 Similarly to existing solid angle sampling techniques (e.g. for spher- samples per pixel samples per pixel ical triangles [Arv95] and rectangles [UFK13]), the cost of drawing area wrt center Gamito radial ld-radial a sample with our technique is higher than that of uniform area area wrt sp parallel radial tab ld-radial tab sampling (though some of it is amortized over multiple samples). This overhead pays off when the luminaire is close to the shading Figure 6: Error (top) and cost (bottom) for the results shown in point (i.e. the subtended solid angle is relatively large). Figure7 (left) and Figure8 (right), w.r.t. sample count. As an optimization, our Arnold implementation (Figure9) em- ploys a simple heuristic to switch to uniform area sampling when the luminaire is far away. In order to provide a fair comparison against cost, our tabulated version is almost as fast as area sampling, and the existing techniques (in Figures7 and8), our Mitsuba implementa- fully numerical implementation can be up to 10× slower. Note that tion does not take advantage of this optimization. the performance of the iterative numerical inversion depends on the Even with the above tabulation scheme, we still need to compute geometrical configuration: the starting point for the inversion affects the number of iterations required for convergence. The parallel and the solid angle of the spherical ellipse ΩD for the sampling pdf, using either Equation (11) or (19). The elliptical integrals involved radial mappings take respectively 1-3 and 1-4 Newton-Raphson can be computed using Carlson’s fast numerical algorithms [Car95]. iterations in our tests. Also note that in scenes with higher geometric and shading complexity, the relative cost of the different methods has less impact on the overall rendering performance. 5. Results Finally, Figure9 shows a scene rendered in Arnold, comparing Figures7 and8 show a comparison between traditional area our tabulated radial map implementation to the renderer’s built-in sampling [SC97], Gamito’s rejection-based solid angle sam- uniform area sampling. The scene features many production fea- pling [Gam16] and our techniques (Mitsuba implementation), with- tures, including high-resolution texture maps, fur, displacement, out and with the presence of participating media. In both figures subsurface scattering, indirect surface and volume-to-surface light only direct illumination (single scattering) is computed, using 16 transport. In such cases the higher cost of our technique has a neg- samples/pixel. Inside a medium, we first sample a point along the ligible impact on the total rendering performance. With 256 sam- ray via equiangular sampling [KF12] w.r.t. the disk light center, and ples/pixel our tabulated radial map yields a noise-free image, while then use the corresponding disk sampling technique to generate a area sampling suffers from a substantial amount of noise. point on the light. In the case of uniform area sampling, a better strat- egy is to first sample the light surface and then perform equiangular sampling w.r.t. that chosen point. We therefore include this strategy 6. Conclusions in Figure8 (called “Area sampling (first)”), which is incompatible We have presented two new area-preserving mappings that enable with the solid angle mappings. The results show that our sampling the uniform solid angle sampling of oriented disk light sources. methods outperform Gamito’s method on surfaces, and perform at Following the key observation that this solid angle is a spherical least on par in participating media, where variance due to medium ellipse, we make use of the Hat-Box theorem to transform canon- sampling dominates when using solid angle sampling. In all cases, ical unit-square sample points onto the spherical ellipse in a way area sampling yields much higher variance. In the supplemental that preserves their stratification. To avoid costly numerical inver- document we provide global illumination comparisons between our sion, we develop a practical mapping tabulation that introduces little tabulated radial sampling and Mitsuba’s built-in disk area sampling. overhead over traditional uniform area sampling [SC97] while sig- Figure6 shows a comparison between the convergence and the nificantly reducing the variance of the illumination estimate. Our cost of the different techniques from Figures7 and8. For the same mappings are also competitive to existing disk solid angle sampling number of samples, our mappings produce lower error than Gamito techniques [Gam16], without imposing restrictions on the sample on surfaces and perform virtually identically in media. In terms of generator.

c 2017 The Author(s) Computer Graphics Forum c 2017 The Eurographics Association and John Wiley & Sons Ltd. Guillén et al. / Area-preserving parameterizations for spherical ellipses

As a by-product of our work, we have proposed two new [Ebe99]E BERLY D.: Perspective projection of an ellipse, 1999.1 expressions for the subtended solid angle of a disk, which in [Faj10] FAJARDO M.: Ray tracing solution for film production rendering. addition to graphics is important in other fields such as parti- ACM SIGGRAPH Talks: Global Illumination Across Industries (2010).5 cle transport. In this context, most previous analytic formula- [Gam16] GAMITO M.N.: Solid angle sampling of disk and cylinder tions [Pax59,TPK∗07,Con10] have included at least two incomplete lights. Computer Graphics Forum 34, 4 (2016).1,2,6,7,8 elliptic integrals that need to be computed numerically. In contrast, [Hei17] HEITZ E.: Analytical calculation of the solid angle subtended by our radial formulation, based on Booth’s spherical topology anal- an arbitrarily positioned to a point source. Nuclear Instruments ysis [Boo44], involves only one elliptic integral, making it more and Methods in Research 852 (2017).7 simple and practical than previous work. [HKWB09] HAŠAN M.,KRIVÁNEKˇ J.,WALTER B.,BALA K.: Virtual spherical lights for many-light rendering of glossy scenes. ACM Trans. While this work only considers circular disks, our approach could Graph. 28, 5 (dec 2009), 143:1–143:6.1 be extrapolated to other whose subtended solid angle is also [Jak10] JAKOB W.: Mitsuba renderer, 2010. http://www.mitsuba- an ellipse, such as elliptical disks and [Hei17]. Including renderer.org.5 these geometries would only require finding the spherical ellipses [KF12] KULLA C.,FAJARDO M.: Importance sampling techniques for subtended by them. Moreover, our mappings could reduce variance path tracing in participating media. Computer Graphics Forum 31, 4 of other shapes such as cylinders, following Gamito [Gam16]. (2012), 1519–1528.6 The main limitation of our method is the lack of analytical inver- [Pax59] PAXTON F.: Solid angle calculation for a circular disk. Review of sion of the proposed mappings, which requires using either costly Scientific Instruments 30, 4 (1959), 254–258.7 ∗ numerical inversion or tabulation. Unfortunately, it seems impossi- [PSC 15] PILLEBOUE A.,SINGH G.,COEURJOLLY D.,KAZHDAN M., ble to find a spherical ellipse mapping that does not involve incom- OSTROMOUKHOV V.: Variance analysis for Monte Carlo integration. ACM Trans. Graph. 34, 4 (2015), 124.2 plete elliptic integrals, whose inversion is unknown. The presented mappings also only consider the solid angle, but not the other con- [SC97] SHIRLEY P., CHIU K.: A low distortion map between disk and square. Journal of graphics tools 2, 3 (1997), 45–52.2,3,5,6,8 tribution terms in Equation (1), e.g. the BRDF or the foreshortening term. Developing methods for including at least some of these other [SHD15] SIMON F., HANIKA J.,DACHSBACHER C.: Rich-VPLs for improving the versatility of many-light methods. Computer Graphics terms is an interesting direction for future work. Furthermore, while Forum 34, 2 (2015), 575–584.1 our mappings are nearly optimal for uniformly emitting disk lumi- [Shi91] SHIRLEY P.: Discrepancy as a quality measure for sample distri- naires, it would be interesting to take into account spatially-varying butions. In Proceedings of Eurographics ‘91 (1991), vol. 91, pp. 183–194. emission profiles, in the spirit of the work of Bitterli et al. [BNJ15]. 2 [SK13] SUBR K.,KAUTZ J.: Fourier analysis of stochastic sampling Acknowledgements strategies for assessing bias and variance in integration. ACM Trans. Graph. 32, 4 (jul 2013), 128:1–128:12.2 We would like to thank the anonymous reviewers for their sugges- [SWZ96] SHIRLEY P., WANG C.,ZIMMERMAN K.: Monte Carlo tech- tions. This project was funded by the European Research Coun- niques for direct lighting calculations. ACM Trans. Graph. 15, 1 (jan cil (ERC Consolidator Grant 682080), DARPA (HR0011-16-C- 1996), 1–36.1,2 0025), and the Spanish Ministerio de Economía y Competitivi- [TNSP98] TOBLER R. F., NEUMANN L.,SBERT M.,PURGATHOFER dad (TIN2014-61696-EXP, TIN2013-47276-C6-3-R). Jorge López- W.: A new form factor analogy and its application to stochastic global Moreno was additionally founded by a Juan de la Cierva fellowship. illumination algorithms. In Proceedings of EGSR ‘98 (1998), pp. 35–44. 3 No ellipses were harmed in the making of this paper. [TPK∗07] TIMUS D.,PRATA M.,KALLA S.,ABBAS M.,ONER F., GALIANO E.: Some further analytical results on the solid angle subtended References at a point by a circular disk using elliptic integrals. Nuclear Instruments and Methods in Physics Research 580, 1 (2007), 149–152.7 [Arv95] ARVO J.: Stratified sampling of spherical triangles. In Proceed- ings of SIGGRAPH ‘95 (1995), ACM, pp. 437–438.1,2,3,5,6 [UFK13] UREÑA C.,FAJARDO M.,KING A.: An area-preserving parametrization for spherical rectangles. Computer Graphics Forum [Arv01] ARVO J.: Stratified sampling of 2-manifolds. SIGGRAPH 2001 32, 4 (2013), 59–66.1,2,3,6 Course Notes 29, 2 (2001).1,2 [Ure00] UREÑA C.: Computation of irradiance from triangles by adaptive [BNJ15] BITTERLI B.,NOVÁK J.,JAROSZ W.: Portal-masked environ- sampling. Computer Graphics Forum 19, 2 (2000), 165–171.1 ment map sampling. Computer Graphics Forum 34, 4 (2015), 13–19. 7 [Wan92] WANG C.: Physically correct direct lighting for distribution ray tracing. In Graphics Gems III (1992), Academic Press Professional, Inc., [Boo44] BOOTH J.: On the rectification and quadrature of the spherical pp. 307–313.1 ellipse. The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science 25, 163 (1844), 18–38.1,4,7 [Boo52] BOOTH J.: Researches on the geometrical properties of elliptic integrals. Philosophical Transactions of the Royal Society of London 142 (1852), 311–416.5 [Car95] CARLSON B.C.: Numerical computation of real or complex elliptic integrals. Numerical Algorithms 10, 1 (1995), 13–26.6 [Con10] CONWAY J. T.: Analytical solution for the solid angle subtended at any point by an ellipse via a point source radiation vector potential. Nuclear Instruments and Methods in Physics Research 614, 1 (2010), 17–27.7

c 2017 The Author(s) Computer Graphics Forum c 2017 The Eurographics Association and John Wiley & Sons Ltd. Guillén et al. / Area-preserving parameterizations for spherical ellipses

0.0043451 3.7234×10−5 1.2195×10−5 3.1013×10−6 1.2655×10−5

(a) Area sampling [SC97] (b) Gamito [Gam16] (c) Our parallel mapping (d) Our radial mapping (e) Our ld-radial mapping Figure 7: Top: Scene illuminated by a double-sided disk light, rendered with 16 samples/pixel. The light is to the ground and is invisible to camera rays. Bottom: False-color differences and MSE w.r.t. to a reference image computed with 32K samples/pixel.

0.700190 .14059 2.4044×10−4 2.3957×10−4 2.3610×10−4 2.3739×10−4

(a) Area sampling [SC97] (b) Area sampling (first) (c) Gamito [Gam16] (d) Our parallel mapping (e) Our radial mapping (f) Our ld-radial mapping Figure 8: Top: A scene with a participating medium illuminated by a single-sided disk light (invisible), rendered with 16 samples/pixel. Please refer to Section5 for details. Bottom: False-color differences and MSE w.r.t. to a reference image computed with 64K samples/pixel.

Figure 9: Colored disk lights (invisible) rendered in Arnold using area sampling (left) and our tabulated radial map (right) with 256 samples/pixel. Due to the use of complex surface and hair shaders, the higher cost of our technique has a negligible impact on performance.

c 2017 The Author(s) Computer Graphics Forum c 2017 The Eurographics Association and John Wiley & Sons Ltd. Guillén et al. / Area-preserving parameterizations for spherical ellipses

Appendix A: Derivation of Equation (9) Appendix B: Derivation of Equation (18)

Here we derive the expression for hp(φp) in Equation (9), whose Here we derive the expression for r(φr) in Equation (18), which is integral we then express as a combination of incomplete elliptic in- used in the radial mapping (Section 3.3). We consider the planar tegral functions in Equation (11). We use the tangent ellipse, shown ellipse resulting from the of the spherical ellipse in Figure 10 and introduced in Section3 and Figure2, right. The onto the xbeybe plane. This ellipse’s semi-major and semi-minor axes a b ellipse semi-axes at ≥ bt are aligned with xbe and ybe, respectively. are and , respectively (see Figure5).

For any angle φp ∈ [−β,β], we first obtain a coordinate y = tanφp Consider a point r whose polar coordinates (φr,r(φr)) and Carte- sian coordinates (x,y) are related as along the ybe axis. (We only consider φp > 0, thus y > 0, and convert negative φp to positive using symmetry, as described in Section 3.2.) x = r(φ )cosφ , y = r(φ )sinφ . (28) 2 2 r r r r Using the ellipse equation (x/at) + (y/bt) = 1, we can get the We want to define r(φr) in such a way that r is on the planar ellipse corresponding x ≥ 0 coordinate along xbe as a function of y: curve. Thus, x and y must obey the ellipse equation, i.e. q 2 x = at 1 − (y/bt) . (24)  x 2  y 2 + = 1. (29) a b We then consider the point t = (x,y,1) on the tangent ellipse and its We can substitute x and y from Equation (28) into the ellipse equa- spherical projection s = t/ktk. The xe-coordinate of s, and also of b tion, resulting in its cylindrical projection (see Figure4, left), is ! x b2 cos2 φ a2 sin2 φ r( )2 r + r = 1. (30) hp = p . (25) φr 2 2 2 2 x2 + y2 + 1 b a a b Substituting Equation (24) into (25): We can thus write ab p s 1 − py2 1 − py2 r(φr) = q , (31) 2 2 2 2 hp = at q = ct 2 (26) b cos φr + a sin φr 2 2 2 1 − m py y + 1 + at 1 − py which is Equation (18). where p, m and ct are as in Equation (10).

Using y = tanφp and 0 ≤ φp ≤ β ≤ π/2, in Equation (26) we 2 2 2 can substitute y by (sin φp)/(1 − sin φp). With this we can finally write hp explicitly as a function of φp:

s 2 1 − (p + 1)sin φp hp(φp) = ct 2 (27) 1 − (mp + 1)sin φp which is exactly Equation (9).

xe x b t = (x,y,1) hp s ybe

φp y ze bt b

at

Figure 10: A view of the tangent ellipse (red). For a given angle φp, we first obtain the coordinate y = tanφp along axis ybe. Using the ellipse equation, we then find the corresponding coordinate x along xbe. This gives point t on the tangent ellipse, whose spherical projection s has xbe-coordinate hp – the quantity we are interested in.

c 2017 The Author(s) Computer Graphics Forum c 2017 The Eurographics Association and John Wiley & Sons Ltd.