Optimal Spherical Harmonics Projection

Optimal Spherical Harmonics Projection

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.121.4172&rep=rep1&type=pdf

Optimal Spherical Harmonics ProjectionWILLEM H. DE BOERMucky Foot Productions Ltd.e-mail: reply@whdeboer.comWe introduce the reader to the mathematics behind projection ofn-dimensional vectors into abasis onn-dimensional space, wherencan be anything upto and including infinity. We showhow ideally one wants to project into the duals of a basis if this basis is not orthonormal, andprovide the mathematics to formulate this operation in matrix form. The second part of thearticle discusses spherical harmonics projection of real-valued scalar functions onS2, used in real-time global illumination applications and conclude that projection into the dual basis is equal tocalculating a least-squares solution.Categories and Subject Descriptors: I.3.7 [Computer Graphics]: Three-dimensional graphicsand realismGeneral Terms: Algorithms, human factors, performanceAdditional Key Words and Phrases: Spherical Harmonics, Projection, Basis1. INTRODUCTIONSpherical harmonics have been used in the field of computer graphics for providingsimplified solutions to the rendering equation, which is central to global illumina-tion problems. One of the key concepts of using spherical harmonics is projectinga real-valued scalar function onS2(such as the incoming radiance of a particu-lar point on the surface of an object) into the spherical harmonics. A projectionof a functionfinto the spherical harmonics1{Yi}yields coefficients{ci}, whichare the weights used in a linear combination of{Yi}to representf. In many pa-pers that treat spherical harmonics in computer graphics (including [Snyder 2002][Ramamoorthi and Hanrahan 2001]) the theory behind spherical harmonics andprojection is only briefly outlined. We feel that many people in the games fieldwill benefit from a more in-depth discussion of the theory behind projection. Anelementary background in linear algebra, and multi-variable calculus is assumed ofthe reader.Goal- Our goal is to provide an insight into spherical harmonics projection offunctions, by first drawing an analogy with the finite-dimensional case and later onproviding the machinery to optimally project an arbitrary function onS2into thespherical harmonics.Overview- We begin by considering projection in the finite-dimensional vectorspaceRn. Section 2 shows how projection works inRn, when it fails, and how tosolve this. In section 3 we consider the infinite-dimensional space. The first part1We will denote thereal-valuedspherical harmonics by{Yi}. Their complex equivalents aregenerally not directly used in computer graphics.2·of this section discusses projection of functions into the spherical harmonics, andthe second part describes optimal projection. In section 4 we will briefly discussan example of other applications in computer graphics that may see benefit fromprojection into the dual basis.2. PROJECTION IN A FINITE DIMENSIONAL SPACEConsider the finiten-dimensional Euclidean vector space,Rn. A vectorvin thisspace can be uniquely written as a linear combination of a complete set of basisvectors onRn:v=v1 ̄e1+v2 ̄e2+...+vn ̄en=n∑i=1vi ̄eiWhere{ ̄ei}are the basis vectors, and{vi}are the coordinates ofvin{ ̄ei}.There are certain problems in computer graphics that require us to be able to movethe other way: How can we compute{vi}when given a basis? Let us choose thebasis{ ̄ei}as this given basis and let us assume that this basis is orthonormal, so〈 ̄ei| ̄ej〉= 1 only ifi=j, 0 ifi6=j(wherei, j= 1, ..., n), and〈 | 〉denotes the dotproduct. Due to orthonormality of{ ̄ei}, we can obtain the componentviofvbyperforming a dot product with the appropriate basis vector:〈v| ̄ei〉=〈(n∑j=1vj ̄ej)| ̄ei〉=n∑j=1vj〈 ̄ej| ̄ei〉=vi(1)Doing this for every ̄eiin the basis results in a vectorv= [v1, v2, ..., vn]tof coor-dinates ofvin the basis{ ̄ei}. Equation (1) is called projection: We are projectinga vectorvinto a basis{ ̄ei}, to obtain the coordinates ofvin that basis.2.1 The DualsObtaining the coordinates of a vectorvin a basis by performing a projection worksbecause of the assumed orthonormality of the particular basis we are projectinginto, as we have just shown. What if we want to projectvinto a basis that is notorthonormal? Suppose{ ̄ei}is not orthonormal. Then using Eq. (1) to calculatethe component ofvwill not work, i.e.〈 ̄ei| ̄ej〉will not in general vanish fori6=j.In order to obtain the components ofvin a non-orthonormal basis we must use thedual of{ ̄ei}, denoted by{ ̄e∗i}. Thedefining propertyof the dual is that〈 ̄e∗i| ̄ej〉= 1ifi=j, 0 ifi6=j(wherei, j= 1, ..., n). By using ̄e∗irather than ̄eiin Eq. (1), wecan obtain the components ofvin{ ̄ei}even if this basis is not orthonormal:〈v| ̄e∗i〉=〈(n∑j=1vj ̄ej)| ̄e∗i〉=n∑j=1vj〈 ̄ej| ̄e∗i〉=vi(2)Another interesting result, which is very useful to infinite-dimensional projection(as we will shall see further on) is the following:〈v| ̄ei〉=〈(n∑j=1vj ̄ej)| ̄ei〉=n∑j=1vj〈 ̄ej| ̄ei〉(3)·3〈v| ̄ei〉=〈(n∑j=1wj ̄e∗j)| ̄ei〉=wi(4)Note how{vj}are the components ofvexpressed in{ ̄ej}, and{wj}are thecomponents ofvexpressed in{ ̄e∗j}. By equating Eq. (3) and Eq. (4) we obtain:wi=n∑j=1vj〈 ̄ej| ̄ei〉=v1〈 ̄e1| ̄ei〉+v2〈 ̄e2| ̄ei〉+...+vn〈 ̄en| ̄ei〉Or, the componentwican be obtained by calculating a weighted sum of thecomponents{vi}. In matrix notation:w=Avv=A−1w(5)WhereAis annxnmatrix, with componentsaij=〈 ̄ei| ̄ej〉. What does thismean? It means that if we have the components ofvin{ ̄ei}, we can calculate thecomponents ofvin{ ̄e∗i}by left-multiplying2vby the matrixA. Conversely, thecomponents ofvin{ ̄ei}can be obtained by left multiplyingwby the inverseA−1.Note that if{ ̄ei}is an orthonormal basis, the matrixAis the identity matrix, andtherefore{ ̄ei}is equal to its dual{ ̄e∗i}.3. PROJECTION IN INFINITE DIMENSIONAL SPACE3.1 Spherical Harmonics ProjectionRecent research into global illumination solutions that are usable in real-time ap-plications has seen a lot of focus on spherical harmonics. Spherical harmonics forma complete basis onS2(the unit spere inR3), the most important function do-main for global illumination. A function defined onS2can be represented by alinear combination of spherical harmonics{Yi}. Projection of a real-valued scalarfunctionfonS2into{Yi}is equivalent to Eq. (1), except we are working in aninfinite-dimensional space, and the way we perform a dot product in this particularspace is by evaluating an integral:〈f|Yi〉=∫2π0∫π0f(θ, φ)Yi(θ, φ) sinθ dθdφ=∫2π0∫π0(∞∑j=1cjYj(θ, φ))Yi(θ, φ) sinθ dθdφ=∞∑j=1cj(∫2π0∫π0Yj(θ, φ)Yi(θ, φ) sinθ dθdφ)=∞∑j=1cj〈Yj|Yi〉=ci(6)2Note that we assume vectors to be column vectors, so left-multiplication by a matrix makessense.4·Whereθrepresents elevation over the sphere, andφrepresents azimuth. Notehow Eq. (6) is the same as Eq. (1), onlyfhas replacedv, andYihas replaced ̄ei.The above equation works just like Eq. (1), because the spherical harmonics forman orthonormal basis onS2by their construction:〈Yi|Yj〉= 1 ifi=j, or 0 ifi6=j.In the case of projecting over thehemisphereH, the spherical harmonics do notform an orthonormal basis, so ideally we would want to projectfover the duals{Y∗i}, like we did in Eq. (2) for then-dimensional case. For computer graphicspurposes, it is generally not easy or desirable to calculate the duals directly. Itis easier to perform a matrix multiplication of the coefficients of a function in thespherical harmonics. We proceed as follows: We projectfinto{Yi}, to obtain thecoefficients in the dual basis{Y∗i}(as in Eq. (4)):〈f|Yi〉=∫2π0∫12π0(∞∑j=1bjY∗j(θ, φ))Yi(θ, φ) sinθ dθdφ=∞∑j=1bj(∫2π0∫12π0Y∗j(θ, φ)Yi(θ, φ) sinθ dθdφ)=∞∑j=1bj〈Y∗j|Yi〉=bi(7)Where{bi}are the coefficients offin the dual basis. Note how the domain ofintegration overθis [0,12π], because we are integrating over the hemisphere. Alsonote that we never need to evaluate{Y∗j}directly; we just perform an integration offwith the spherical harmonicYi. We then calculate the components of the matrixAas follows:aij=〈Yi|Yj〉=∫2π0∫12π0Yi(θ, φ)Yj(θ, φ) sinθ dφdθ(8)And left-multiply the vectorb= [b1, ..., bn]tby the inverseA−1, to obtain the co-efficients{ci}in{Yi}. Note howAis equal to the matrixA={Ajk}in Sloan [Sny-der 2003] used for calculating the least-squares optimal projection of a function,and howbis equal to the vector of coefficientsb={bi}in the same paper. We cantherefore re-interpretbas the coefficients offin the spherical harmonics dual basis{Y∗i}. Then the matrixAcan be interpreted as the representation of a change ofbasis transformation, equal to the one in Eq. (5). Therefore, we can conclude thatleast-squares optimal projection is equal to our method. Also note that if we takethe domain of integration to beS2entirely, the matrixAis equal to the identitymatrix, by the very construction of the spherical harmonics.3Note that typically,m= 9 orm= 25 for diffuse cases [Snyder 2002].·53.2 Optimal SH Projection OverviewThe general algorithm for projecting a functionfon the hemisphereHinto thespherical harmonics formcoefficients3is then:(1) Calculate the inverseA−1of themxmmatrixA, where each entryaijiscalculated using Eq. (8)(2) Calculate themprojection coefficients{bi}offin the dual basis, using Eq.(7)(3) Left-multiplyb= [b1, ..., bm]tbyA−1to obtainc= [c1, ..., cm]t: The coeffi-cients of the projection offinto{Yi}.Note that we can pre-calculateA−1and use it to project any function definedon the hemisphere into{Yi}. Any integration scheme can be used for 1. and2. Green [Green 2003] recommends using Monte-Carlo integration with stratifiedsampling.4. DISCUSSIONProjecting into the dual basis does not only benefit spherical harmonics projectionon the hemisphere. It can benefit numerous other applications in computer graphicsthat work with a non-orthonormal basis. One example is texture reconstruction.Textures are typically point-sampled representations of a continuous image signal,and ideally their reconstruction involves evaluating the convolution of the texturewith thesinc(x) filter in the spatial domain. In real-time computer graphics, how-ever, reconstruction is almost always performed using bilinear basis functions. Thisis especially true of all current graphics hardware. It is therefore tempting to re-place the original construction process with projection into the bilinear basis,{Bi}.Due to the overlap of neighbouring basis functions, it is easy to see that we wouldneed to project into the duals,{B∗i}:〈I|B∗i〉=∫10∫10(MxN∑j=1IjBj(x, y))B∗i(x, y)dydx=IiWhere{Ij}are the coefficients of the image signal in the bilinear basis (ie, thefinal texel values), andMandNare the width and height of the texture respec-tively.5. CONCLUSIONWe have presented the mathematics behind projection of a vector inn-dimensionalspace, wherenis any positive number upto and including infinity. Using elementarylinear algebra we have shown that projection of a vector into the dual of a non-orthonormal basis can be formulated as a matrix multiplication. One applicationof projection in computer graphics is global illumination using spherical harmonics,and we have shown how to optimally project an arbitrary real-valued scalar functiononS2into the spherical harmonics. We have also very briefly discussed anotherapplication in computer graphics that would ideally see a projection into the dualbasis.6·6. ACKNOWLEDGEMENTSA very big thanks to Peter-Pike Sloan for his valuable suggestions and discussions.REFERENCESGreen, R.2003. Spherical harmonic lighting: The gritty details.Game Developers ConferenceProceedings.Ramamoorthi, R. and Hanrahan, P.2001. An efficient representation of irradiance environmentmaps.SIGGRAPH Proceedings.Snyder, P. S. J. H. J. H. J.2003. Clustered principal components for precomputed radiancetransfer.SIGGRAPH Proceedings.Snyder, P. S. J. K. J.2002. Precomputed radiance transfer for real-time rendering in dynamic,low-frequency environments.SIGGRAPH Proceedings.

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值