本文主要参考作者在Siggraph上的PPT,都在参考文献中给出,详细理论证明请看论文,代码也在以下链接的论文主页上
最终计算方法在最后两张图上,参考代码在参考文献网站上
参考代码,相关解释需要看参考文献[3]
文章目录
论文作者提出经验和理论证据表明,在实践中,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) B(p,n)=ρ(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
E(n)=∫Ω(n)L(ω)(n⋅ω)dω
Spherical Harmonics

Spherical harmonics
Y
l
m
Y_{lm}
Ylm, with
l
≥
0
l \ge 0
l≥0 and
−
l
≤
m
≤
l
−l \le m \le l
−l≤m≤l, are the analogue on the sphere to the Fourier basis on the line or circle. The first 9 spherical harmonics (with
l
≤
2
l \le 2
l≤2) are simply constant (
l
=
0
l = 0
l=0), linear (
l
=
1
l = 1
l=1), and quadratic (
l
=
2
l = 2
l=2) polynomials of the cartesian components (x, y, z). and are given numerically by
(3)
(
x
,
y
,
z
)
=
(
sin
θ
cos
ϕ
,
sin
θ
sin
ϕ
,
cos
θ
)
Y
00
=
0.282095
(
Y
11
;
Y
10
;
Y
1
−
1
)
(
θ
,
ϕ
)
=
0.488603
(
x
;
z
;
y
)
(
Y
21
;
Y
2
−
1
;
Y
2
−
2
)
(
θ
,
ϕ
)
=
1.092548
(
x
z
;
y
z
;
x
y
)
Y
20
(
θ
,
ϕ
)
=
0.315392
(
3
z
2
−
1
)
Y
22
(
θ
,
ϕ
)
=
0.546274
(
x
2
−
y
2
)
\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}
(x,y,z)Y00(Y11;Y10;Y1−1)(θ,ϕ)(Y21;Y2−1;Y2−2)(θ,ϕ)Y20(θ,ϕ)Y22(θ,ϕ)=(sinθcosϕ,sinθsinϕ,cosθ)=0.282095=0.488603(x;z;y)=1.092548(xz;yz;xy)=0.315392(3z2−1)=0.546274(x2−y2)(3)
Spherical Harmonics Expansion
E
(
θ
,
ϕ
)
E(\theta, \phi)
E(θ,ϕ) and
L
(
θ
,
ϕ
)
L(\theta, \phi)
L(θ,ϕ) can be represented by the coefficients—
E
l
m
E_{lm}
Elm and
L
l
m
L_{lm}
Llm—in their spherical harmonic expansion.

Analytic Irradiance Formula
We also define
A
=
(
n
⋅
ω
)
A=(n \cdot \omega)
A=(n⋅ω) with coefficients
A
l
A_l
Al. Since
A
A
A has no azimuthal dependence,
m
=
0
m=0
m=0 and we use only the
l
l
l index.
A
(
θ
)
=
m
a
x
[
cos
θ
,
0
]
=
∑
l
A
l
Y
l
0
(
θ
)
A(\theta)=max[\cos \theta, 0]=\sum_l A_l Y_{l0}(\theta)
A(θ)=max[cosθ,0]=l∑AlYl0(θ)
With these definitions one can show (参考文献[1]可知) that
E
l
m
=
4
π
2
l
+
1
A
l
L
l
m
E_{lm}=\sqrt{\frac{4 \pi}{2l+1}}A_lL_{lm}
Elm=2l+14πAlLlm
It will be convenient to define a new variable
A
l
^
\hat{A_{l}}
Al^ by
A
l
^
=
4
π
2
l
+
1
A
l
\hat{A_l}=\sqrt{\frac{4 \pi}{2l+1}}A_l
Al^=2l+14πAl
For rendering, it will be convenient to expand out the irradiance.
(7)
E
(
θ
,
ϕ
)
=
∑
l
,
m
A
^
l
L
l
m
Y
l
m
(
θ
,
ϕ
)
E(\theta, \phi)=\sum_{l,m} \hat{A}_l L_{lm} Y_{lm}(\theta, \phi) \tag{7}
E(θ,ϕ)=l,m∑A^lLlmYlm(θ,ϕ)(7)
An analytic formula for
A
l
A^l
Al can be derived. It can be shown that
A
l
A^l
Al vanishes for odd values of
l
>
1
l > 1
l>1, and even terms fall off very rapidly as
l
−
5
/
2
l^{-5/2}
l−5/2. The analytic formulae are given by
l
=
1
A
^
1
=
2
π
3
l
>
1
,
o
d
d
A
^
l
=
0
l
e
v
e
n
A
^
l
=
2
π
(
−
1
)
l
2
−
1
(
l
+
2
)
(
l
−
1
)
[
l
!
2
l
(
l
2
!
)
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}
l=1l>1,oddlevenA^1=32πA^l=0A^l=2π(l+2)(l−1)(−1)2l−1[2l(2l!)2l!]
Numerically, the first few terms are
(9)
A
^
0
=
3.141593
A
^
1
=
2.094395
A
^
2
=
0.785398
A
^
3
=
0
A
^
4
=
−
0.130900
A
^
5
=
0
A
^
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}
A^0=3.141593A^1=2.094395A^2=0.785398A^3=0A^4=−0.130900A^5=0A^6=0.049087(9)

9 Parameter Approximation

Computing Light Coefficients
给定envmap,计算9个lighting coefficient
L
l
m
L_{lm}
Llm

Rendering

For rendering, we can find the irradiance using equation 7. Since we are only considering
l
≤
2
l \le 2
l≤2, the irradiance is simply a quadratic polynomial of the coordinates of the (normalized) surface normal. Hence, with
n
t
=
(
x
y
z
1
)
n^t = (x \ y\ z\ 1)
nt=(x y z 1), we can write
E
(
n
)
=
n
t
M
n
E(n)=n^tMn
E(n)=ntMn
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
=
(
c
1
L
22
c
1
L
2
−
2
c
1
L
21
c
2
L
11
c
1
L
2
−
2
−
c
1
L
22
c
1
L
2
−
1
c
2
L
1
−
1
c
1
L
21
c
1
L
21
c
3
L
20
c
2
L
10
c
2
L
11
c
2
L
1
−
1
c
2
L
10
c
4
L
00
−
c
5
L
20
)
c
1
=
0.429043
c
2
=
0.511664
c
3
=
0.743125
c
4
=
0.886227
c
5
=
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}
M=⎝⎜⎜⎛c1L22c1L2−2c1L21c2L11c1L2−2−c1L22c1L21c2L1−1c1L21c1L2−1c3L20c2L10c2L11c2L1−1c2L10c4L00−c5L20⎠⎟⎟⎞c1=0.429043c2=0.511664c3=0.743125c4=0.886227c5=0.247708(12)
The entries of M depend on the 9 lighting coefficients
L
l
m
L_{lm}
Llm and the expressions for the spherical harmonics. The constants come from the numerical values of
A
^
l
\hat{A}_l
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
)
=
c
1
L
22
(
x
2
−
y
2
)
+
c
3
L
20
z
2
+
c
4
L
00
−
c
5
L
20
+
2
c
1
(
L
2
−
2
x
y
+
L
21
x
z
+
L
2
−
1
y
z
)
+
2
c
2
(
L
11
x
+
L
1
−
1
y
+
L
10
z
)
\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}
E(n)=c1L22(x2−y2)+c3L20z2+c4L00−c5L20+2c1(L2−2xy+L21xz+L2−1yz)+2c2(L11x+L1−1y+L10z)
参考文献
[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
[3] Light Probe Image Gallery
本文探讨了在游戏开发中,使用球谐函数表示光照环境映射的高效方法,通过9个参数近似光照,简化光照计算过程。该技术允许预计算场景的立方体贴图,以球谐函数的9个系数表示mesh表面顶点的照度,适用于实时渲染。


3385

被折叠的 条评论
为什么被折叠?



