Download - Shperical Harmonics Lighting
![Page 1: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/1.jpg)
Shperical Harmonics Lighting계명대학교
이주영
![Page 2: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/2.jpg)
목 차
1. Global Illumination1. Global Illumination
2. 2. 몬테카를로 적분법몬테카를로 적분법 (Monte Carlo Integration)(Monte Carlo Integration)
3. 3. 구 샘플링구 샘플링4. Orthogonal Basis Functions4. Orthogonal Basis Functions
5. Spherical Harmonics5. Spherical Harmonics
6. Spherical Harmonics Projection6. Spherical Harmonics Projection
7. Spherical Harmonics Lighting Example7. Spherical Harmonics Lighting Example
![Page 3: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/3.jpg)
Global Illumination
Local Illumination – Local Illumination – 물체 표면과 광원의 관계를 물체 표면과 광원의 관계를 이용하여 계산하는 방법이용하여 계산하는 방법
Global Illumination – Global Illumination – 조명이 주변환경에 의해 반사되는 조명이 주변환경에 의해 반사되는 모든 빛을 계산하는 방법모든 빛을 계산하는 방법
![Page 4: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/4.jpg)
Global Illumination
Diffuse Surface ReflectionDiffuse Surface Reflection
Rendering EquationRendering Equation
: : 점 점 xx 에서 방향으로 전달되는 빛의 총 세기에서 방향으로 전달되는 빛의 총 세기
: : 점 점 xx 에서 방향으로 스스로 내뿜는 빛의 세기에서 방향으로 스스로 내뿜는 빛의 세기
: : 점 점 xx 에서 빛의 입에서 빛의 입 ,, 반사 방향에 대한 반사 방향에 대한 BRDF(BRDF( 반사율함수반사율함수 ))
: : 다른 점 다른 점 x’x’ 에서 방향으로 점 에서 방향으로 점 xx 에 입사하는 빛의 세기에 입사하는 빛의 세기
: : 점 점 xx 와 와 x’ x’ 간의 기하학적 관계간의 기하학적 관계
: : 서로가 서로에게 보이는지 유무서로가 서로에게 보이는지 유무 , 0 , 0 또는 또는 11
nlightss
iii LNlightcolsurfacecolI
1
)(**
s
kioiroeoo dwxxVxxGwxLwwxfwxLwxGwxL )',()',(),'(),(),(),(),(
),( owxL
ow
ow
),( oe wxL
),( oir wwxf
),'( iwxL
iw
)',( xxV)',( xxG
![Page 5: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/5.jpg)
Global Illumination
한 정점에서의 빛의 입사 및 반사
![Page 6: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/6.jpg)
Monte Carlo Integration
들어오는 광원을 표현하기 위한 함수를 근사치로 들어오는 광원을 표현하기 위한 함수를 근사치로 적분하기 위한 방법적분하기 위한 방법
수치계산으로 풀지 않고 확률 이용수치계산으로 풀지 않고 확률 이용- - 대상 함수를 샘플링하고 평균을 내서 근사치의 대상 함수를 샘플링하고 평균을 내서 근사치의 적분값을 구하는 방법적분값을 구하는 방법
대상 함수의 근사치를 구하는 식대상 함수의 근사치를 구하는 식
샘플링을 많이 할수록 대상 함수에 더 가까워진다샘플링을 많이 할수록 대상 함수에 더 가까워진다 ..
1
11
)()(11
iii
N
i i
i xwxfNxp
xf
N
dxxpxp
xfdxxf
![Page 7: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/7.jpg)
구 샘플링
구를 단위 영역으로 나누는 것구를 단위 영역으로 나누는 것 10,00010,000 개의 불규칙한 구 상의 샘플개의 불규칙한 구 상의 샘플
-> (θ,φ)-> (θ,φ) 를 사용하는 구 좌표계로 를 사용하는 구 좌표계로 Projection Projection x,yx,y 는 는 [0…1. 0…1] [0…1. 0…1] 범위 내에서 샘플링범위 내에서 샘플링
πyφxθ 21arccos2
![Page 8: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/8.jpg)
Orthogonal Basis Functions
Basis FunctionsBasis Functions 은 어떤 함수를 나타낼 수 있는 작은 은 어떤 함수를 나타낼 수 있는 작은 조각조각
크기를 적절하게 조정하고 결합하여 원래 함수의 크기를 적절하게 조정하고 결합하여 원래 함수의 근사치 계산근사치 계산
Projection(Projection( 내적내적 ) : ) : 적절한 크기를 조절하기 위해서 원래 적절한 크기를 조절하기 위해서 원래 함수와 함수와 basis functionsbasis functions 의 내적값을 구하는 것의 내적값을 구하는 것
1c
2c
3c
![Page 9: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/9.jpg)
Orthogonal Basis Functions
크기 조절을 마친 신호들을 결합하면 원래 함수와 크기 조절을 마친 신호들을 결합하면 원래 함수와 비슷한 모양을 만들 수 있다비슷한 모양을 만들 수 있다 ..
1c
2c
3c
![Page 10: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/10.jpg)
Orthogonal Basis Functions
Orthogonal Basis FunctionOrthogonal Basis Function
- - 두 함수가 직각을 의미하고 두 함수는 서로 관련이 없두 함수가 직각을 의미하고 두 함수는 서로 관련이 없다다 ..
- - 두 함수를 더해도 원래의 두 함수로 분해할 수 있다두 함수를 더해도 원래의 두 함수로 분해할 수 있다 ..
ji
jikdxxBxB ji 0
xBcN
iii
1
![Page 11: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/11.jpg)
Orthogonal Basis Functions
basis functionsbasis functions 을 구하기 위한 직교다항식 중에서 을 구하기 위한 직교다항식 중에서 SHFSHF에서는 에서는 Associated legendre polynomialsAssociated legendre polynomials 를 사용를 사용
Associated legendre polynomialsAssociated legendre polynomials
0,11
0246)2(
0135)2(
!!
)12(
)1(!)!12()1(
)1(1)12()(
1
2/2
21
x
evenxnn
oddxnn
x
pmxp
xmp
pmlPlxPml
mm
mm
mmmm
ml
ml
ml
![Page 12: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/12.jpg)
Orthogonal Basis Functions
4 개 주파수에서의 associated Legendre polynomials
![Page 13: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/13.jpg)
Spherical Harmonics
구를 생성하는 구를 생성하는 orthogonal basisorthogonal basis 를 형성를 형성 구 좌표계 상의 임의의 함수를 원하는 개수의 주파수 구 좌표계 상의 임의의 함수를 원하는 개수의 주파수
영역들로 분해하고영역들로 분해하고 , , 복원할 수 있다복원할 수 있다 .. SH functionSH function 은 은 yy 로 표기로 표기
PP 는 는 Associated legendre polynomialsAssociated legendre polynomials KK 는 함수를 표준화하기 위한 크기 조절 요소 는 함수를 표준화하기 위한 크기 조절 요소
0
0
0
,cos
,cossin2
,coscos2
,00 m
m
m
PK
PmK
PmK
y
ll
ml
ml
ml
ml
ml
|)!|(
|)!|(
4
)12(
ml
mllk lm
lmlRlwhereyml ,,
![Page 14: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/14.jpg)
Spherical Harmonics
– +Not thisdirection
Thisdirection
– +Not thisdirection
Thisdirection
![Page 15: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/15.jpg)
Spherical Harmonics
m = 2, l = 4
0
0
0
,cos
,cossin2
,coscos2
,00 m
m
m
PK
PmK
PmK
y
ll
ml
ml
ml
ml
ml
![Page 16: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/16.jpg)
Spherical Harmonics
00y
11y
11y
12y
22y
02y
12y2
2y
![Page 17: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/17.jpg)
Spherical Harmonics
데카르트 좌표계를 데카르트 좌표계를 SH SH 입력값으로하여 다항식으로 입력값으로하여 다항식으로 나타낼 수 있다나타낼 수 있다 ..
)(546274.0),(
092548.1),(
)13(315392.0),(
092548.1),(
092548.1),(
488603.0),(
488603.0),(
488603.0),(
282095.0),(
2222
21
220
21
22
11
10
11
00
yxY
xzY
zY
yzY
xyY
xY
zY
yY
Y
![Page 18: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/18.jpg)
Spherical Harmonics Projection
구 좌표계 상의 함수 구 좌표계 상의 함수 f(s)f(s) 는 주어진 주파수 는 주어진 주파수 l,ml,m 에 대해서 상수 에 대해서 상수 ccll
mm 로 분해로 분해 특별한 주파수를 위한 하나의 계수를 계산하기 위해서는 원 특별한 주파수를 위한 하나의 계수를 계산하기 위해서는 원
함수 함수 f(s)f(s) 와 와 SH SH 함수의 곱들을 더하기만 하면 된다함수의 곱들을 더하기만 하면 된다 ..
함수 함수 f(s)f(s) 의 의 ss 는 구 샘플는 구 샘플 ((θ,φθ,φ)) 각 샘플에 대해서 각 샘플에 대해서 yyll
mm 을 한번만 구하고 여기에 대상 함수값을 을 한번만 구하고 여기에 대상 함수값을 곱하면 곱하면 SH SH 계수 구할 수 있다계수 구할 수 있다 ..
S
ii dssysfc
![Page 19: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/19.jpg)
Spherical Harmonics Projection
몬테카를로 적분법의 식몬테카를로 적분법의 식
xxii 는 샘플의 배열이고는 샘플의 배열이고 , , 함수 함수 ff 는 는 f(xf(xii) = light(x) = light(xii)y)yii(x(xii))
이다이다 .. 각각 샘플마다 가중치 같도록 하면샘플마다 가중치 같도록 하면 , , 하나의 샘플이 구 하나의 샘플이 구
표면에서 나올 확률 표면에서 나올 확률 p(xp(xii) = 1/4π, ) = 1/4π, 가중치가중치 w(xw(xii) = 4π) = 4π
각 샘플마다 가중치가 같으므로 상수가 된다각 샘플마다 가중치가 같으므로 상수가 된다 ..
N
iii xwxf
Ndxxf
1
1
N
jjij
N
jjiji xyxlight
Nxyxlight
Nc
11
)()(4
4)()(1
![Page 20: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/20.jpg)
Spherical Harmonics Projection
원 함수의 근사값을 구할 수 있다원 함수의 근사값을 구할 수 있다 ..
주파수 수를 늘여 주파수 수를 늘여 SH functionSH function 의 개수가 많을수록 원 의 개수가 많을수록 원 함수에 더 근접한 함수를 얻을 수 있다함수에 더 근접한 함수를 얻을 수 있다 ..
2
0
1
0
)(~ N
iii
n
l
l
lm
ml
ml sycsycsf
![Page 21: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/21.jpg)
Spherical Harmonics Projection
-1-2 0 1 2
0
1
2
( , )lmY
xy z
xy yz 23 1z zx 2 2x y
l
m
Exact imageOrder 01 term
RMS error = 25 %
![Page 22: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/22.jpg)
Spherical Harmonics Projection
-1-2 0 1 2
0
1
2
( , )lmY
xy z
xy yz 23 1z zx 2 2x y
l
m
Exact imageOrder 14 terms
RMS Error = 8%
![Page 23: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/23.jpg)
Spherical Harmonics Projection
-1-2 0 1 2
0
1
2
( , )lmY
xy z
xy yz 23 1z zx 2 2x y
l
m
Exact imageOrder 29 terms
RMS Error = 1%
For any illumination, average error < 3% [Basri Jacobs 01]
![Page 24: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/24.jpg)
Spherical Harmonics Lighting 정리
입력값 (θ,φ) 생성
입력입사광에 대해 프로젝션한 벡터 생성
입사광에 대한 벡터 저장
렌더링시 한 점에서 재질의 색상과저장된 벡터의 내적으로
해당 점의 밝기 계산
구 샘플링 ( 몬테카를로 적분법 이용 )
Basis Function 으로 Associated Legendre Polynomials 를이용한 Spherical Harmonics 사용
( 두 각으로 표현되는 구 좌표계 상의임의의 함수를 원하는 개수의
주파수 영역들로 분해 )
미리 계산하여 저장하므로렌더링시 연산량 줄여줌 .
![Page 25: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/25.jpg)
SHL Example
Sample : 2,500 band : 4 Basis Functions : 16 개 Rotation : θ(43.3), φ(225.0)θ(43.3), φ(225.0)
otherwise
tdt
0
01,
![Page 26: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/26.jpg)
SHL Example
GL LightingGL Lighting
![Page 27: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/27.jpg)
SHL Example
SH Lighting - UnshadowedSH Lighting - Unshadowed
![Page 28: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/28.jpg)
SHL Example
SH Lighting - ShadowedSH Lighting - Shadowed
![Page 29: Shperical Harmonics Lighting](https://reader036.vdocuments.pub/reader036/viewer/2022081504/56812b1b550346895d8f0cc1/html5/thumbnails/29.jpg)
감사합니다 .