球諧光照簡述

本文主要參考作者在Siggraph上的PPT,都在參考文獻中給出,詳細理論證明請看論文,代碼也在以下鏈接的論文主頁上

最終計算方法在最後兩張圖上,參考代碼在參考文獻網站上


論文作者提出經驗和理論證據表明,在實踐中,irradiance僅取決於的前2階spherical harmonic modes of the illumination,並且可以表示爲表面法線的笛卡爾分量的二次多項式。 實際上,Lambertian BRDF濾波器的99%能量包含在0,1和2階中。特別是,我們只關心照明的前2階,即9個參數。 這些前9個係數也是關於照明可以確定的所有係數。

對於遊戲開發而言,實際意義在於,可以預先給定一個場景的CubeMap,計算出球諧函數的9個參數,用着9個參數可以計算出mesh表面頂點的irradiance。

We must scale E by the surface albedo ρ, which may be dependent on position p and be described by a texture, to find the radiosity B, which corresponds directly to the image intensity.
B(p,n)=ρ(p)E(n) B(p,n)=\rho(p)E(n) 在這裏插入圖片描述

以下提到的符號請參考https://en.wikipedia.org/wiki/Radiance

Computing Irradiance

  • 每個像素是由半球積分得到的
  • 朗博表面是就像一個低通濾波器

在這裏插入圖片描述
The irradiance E is then a function of the surface normal n only and is given by an integral over the upper hemisphere Ω(n).
E(n)=Ω(n)L(ω)(nω)dω E(n) = \int_{\Omega(n)}L(\omega)(n \cdot \omega)d\omega

Spherical Harmonics

在這裏插入圖片描述
Spherical harmonics YlmY_{lm}, with l0l \ge 0 and lml−l \le m \le l, are the analogue on the sphere to the Fourier basis on the line or circle. The first 9 spherical harmonics (with l2l \le 2) are simply constant (l=0l = 0), linear (l=1l = 1), and quadratic (l=2l = 2) polynomials of the cartesian components (x, y, z). and are given numerically by
(3)(x,y,z)=(sinθcosϕ,sinθsinϕ,cosθ)Y00=0.282095(Y11;Y10;Y11)(θ,ϕ)=0.488603(x;z;y)(Y21;Y21;Y22)(θ,ϕ)=1.092548(xz;yz;xy)Y20(θ,ϕ)=0.315392(3z21)Y22(θ,ϕ)=0.546274(x2y2) \begin{aligned} (x,y,z) &= (\sin\theta\cos\phi, \sin\theta\sin\phi, \cos\theta)\\ Y_{00} &=0.282095\\ (Y_{11}; Y_{10}; Y_{1−1}) (\theta, \phi) &= 0.488603 (x; z; y)\\ (Y_{21}; Y_{2−1}; Y_{2−2}) (\theta, \phi) &= 1.092548 (xz; yz; xy)\\ Y_{20}(\theta, \phi) &= 0.315392(3z^2 − 1)\\ Y_{22}(\theta, \phi) &= 0.546274(x^2 − y^2) \end{aligned} \tag{3}

Spherical Harmonics Expansion

E(θ,ϕ)E(\theta, \phi) and L(θ,ϕ)L(\theta, \phi) can be represented by the coefficients— ElmE_{lm} and LlmL_{lm}—in their spherical harmonic expansion.
在這裏插入圖片描述

Analytic Irradiance Formula

We also define A=(nω)A=(n \cdot \omega) with coefficients AlA_l. Since AA has no azimuthal dependence, m=0m=0 and we use only the ll index.
A(θ)=max[cosθ,0]=lAlYl0(θ) A(\theta)=max[\cos \theta, 0]=\sum_l A_l Y_{l0}(\theta)

With these definitions one can show (參考文獻[1]可知) that
Elm=4π2l+1AlLlm E_{lm}=\sqrt{\frac{4 \pi}{2l+1}}A_lL_{lm}

It will be convenient to define a new variable Al^\hat{A_{l}} by
Al^=4π2l+1Al \hat{A_l}=\sqrt{\frac{4 \pi}{2l+1}}A_l

For rendering, it will be convenient to expand out the irradiance.
(7)E(θ,ϕ)=l,mA^lLlmYlm(θ,ϕ) E(\theta, \phi)=\sum_{l,m} \hat{A}_l L_{lm} Y_{lm}(\theta, \phi) \tag{7}

An analytic formula for Al can be derived. It can be shown that AlA^l vanishes for odd values of l>1l > 1, and even terms fall off very rapidly as l5/2l^{-5/2}. The analytic formulae are given by
l=1A^1=2π3l>1,oddA^l=0levenA^l=2π(1)l21(l+2)(l1)[l!2l(l2!)2] \begin{aligned} l=1 &\quad \hat{A}_1=\frac{2\pi}{3}\\ l>1,odd &\quad \hat{A}_l=0\\ l \quad even &\quad \hat{A}_l=2\pi \frac{(-1)^{\frac{l}{2}-1}}{(l+2)(l-1)}\left [ \frac{l!}{2^l(\frac{l}{2}!)^2} \right ] \end{aligned}

Numerically, the first few terms are
(9)A^0=3.141593A^1=2.094395A^2=0.785398A^3=0A^4=0.130900A^5=0A^6=0.049087 \hat{A}_0 = 3.141593 \quad \hat{A}_1 = 2.094395 \quad \hat{A}_2 = 0.785398 \\ \hat{A}_3 = 0 \quad \hat{A}_4 = −0.130900 \quad \hat{A}_5 = 0 \quad \hat{A}_6 = 0.049087 \tag{9}

在這裏插入圖片描述

9 Parameter Approximation

在這裏插入圖片描述

Computing Light Coefficients

給定envmap,計算9個lighting coefficient LlmL_{lm}
在這裏插入圖片描述

Rendering

在這裏插入圖片描述
For rendering, we can find the irradiance using equation 7. Since we are only considering l2l \le 2, the irradiance is simply a quadratic polynomial of the coordinates of the (normalized) surface normal. Hence, with nt=(x y z 1)n^t = (x \ y\ z\ 1), we can write
E(n)=ntMn E(n)=n^tMn
M is a symmetric 4x4 matrix. Each color has an independent matrix M. Equation 11 is particularly useful for rendering, since we require only a matrix-vector multiplication and a dot-product to compute E. The matrix M is obtained by expanding equation 7:
(12)M=(c1L22c1L22c1L21c2L11c1L22c1L22c1L21c2L11c1L21c1L21c3L20c2L10c2L11c2L11c2L10c4L00c5L20)c1=0.429043c2=0.511664c3=0.743125c4=0.886227c5=0.247708 M= \begin{pmatrix} c_1L_{22} & c_1L_{2-2} & c_1L_{21} & c_2L_{11}\\ c_1L_{2-2} & -c_1L_{22} & c_1L_{2-1} & c_2L_{1-1}\\ c_1L_{21} & c_1L_{21} & c_3L_{20} & c_2L_{10}\\ c_2L_{11} & c_2L_{1-1} & c_2L_{10} & c_4L_{00}-c_5L_{20} \end{pmatrix}\\ c_1=0.429043 \quad c_2=0.511664\\ c_3=0.743125 \quad c_4=0.886227 \quad c_5=0.247708 \tag{12}
The entries of M depend on the 9 lighting coefficients LlmL_{lm} and the expressions for the spherical harmonics. The constants come from the numerical values of A^l\hat{A}_l given in equation 9, and the spherical harmonic normalizations given in equation 3.
On systems not optimized for matrix and vector operations, it may be more efficient to explicitly write out equation 7 for the irradiance as a sum of terms, i.e. expand equation 12:
E(n)=c1L22(x2y2)+c3L20z2+c4L00c5L20+2c1(L22xy+L21xz+L21yz)+2c2(L11x+L11y+L10z) \begin{aligned} E(n) &= c_1L_{22}(x^2-y^2)+c_3L_{20}z^2+c_4L_{00}-c_5L_{20}\\ &+ 2c_1(L_{2-2}xy+L_{21}xz+L_{2-1}yz)\\ &+ 2c_2(L_{11}x+L_{1-1}y+L_{10}z) \end{aligned}

參考文獻

[1] An Efficient Representation for Irradiance Environment Maps
[2] On the Relationship between Radiance and Irradiance: Determining the illumination from images of a convex Lambertian object

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章