Spherical Harmonics Lighting

Download Report

Transcript Spherical Harmonics Lighting

Spherical Harmonic Lighting
Jaroslav Křivánek
Overview
• Function approximation
• Spherical harmonics
• Some other time
 Illumination from environment maps
• BRDF representation by spherical harmonics
• Spherical harmonics rotation
 Hemispherical harmonics
 Radiance Caching
 Precomputed Radiance Transfer
• Clustered Principal Component Analysis
• Wavelet Methods
I) Function Approximation
Function Approximation
• G(x) ... function to approximate
• B1(x), B2(x), … Bn(x) … basis functions
• We want
n
G ( x)   ci Bi ( x)
i 1
• Storing a finite number of coefficients ci gives an
approximation of G(x)
Function Approximation
• How to find coefficients ci?
 Minimize an error measure
• What error measure?
 L2 error
EL2   [G( x)   ci Bi ( x)]
2
I
i
Function Approximation
• Minimizing EL2 leads to
 B1 B1

 B2 B1
 

 Bn B1
• Where
B1 B2
B2 B2
Bn B2



B1 Bn


Bn Bn
  c1   G B1 
  

 c2    G B2 
     
  

 cn   G Bn 
F G   F ( x)G( x)dx
I
(function scalar product)
Function Approximation
• Orthonormal basis
1 i  j
Gi G j  
0 i  j
• If basis is orthonormal then
 c1   G B1 
c   G B 
2 
 2  
   

  
cn   G Bn 
•  we want our bases to be orthonormal
II) Spherical Harmonics
Spherical Harmonics
• Spherical function approximation
• Domain I = unit sphere S
 = directions in 3D
• Approximated function: G(θ,φ)
• Basis functions: Yi(θ,φ)= Yl,m(θ,φ)
 indexing: i = l (l+1) + m
Spherical Harmonics
band 0
(l=0)
Y0,0
band 1
(l=1)
Y1,-1
Y2,-2
Y2,-1
Y1,0
Y2,0
Y1,1
Y2,1
Y2,2
band 2
(l=2)
Spherical Harmonics
• K … normalization constant
• P … Associted Legendre polynomial
•
 Orthonormal polynomial basis on (0,1)
In general:
Yl,m(θ,φ) = K . Ψ(φ) . Pl,m(cos θ)
 Yl,m(θ,φ) is separable in θ and φ
Function Approximation with SH
n 1 m l
G( ,  )    cl ,mYl ,m ( ,  )
l 0 m   l
• n…approximation order
• There are n2 harmonics for order n
Function Approximation with SH
• Spherical harmonics are ORTHONORMAL
• Function projection
 Computing the SH coefficients
2 
cl ,m  G Yl ,m   G( )Yl ,m ( )d    G( ,  )Yl ,m ( ,  ) sin dd
S
0 0
 Usually evaluated by numerical integration
• Low number of coefficients
 low-frequency signal
Product Integral with SH
• Simplified indexing
 Yi= Yl,m
 i = l (l+1) + m
• 2 functions represented by SH
n2
F ( )   f iYi ( )
i 0
n2
G( )   giYi ( )
i 0
• Integral of F(ω).G(ω) is the dot product of
F’s and G’s SH coefficients
n2
 F ()G()d   f g
S
i 0
i
i
Product Integral with SH
F(ω) = fi Yi(ω)
G(ω)F(ω)dx = fi
G(ω) =gi Yi(ω)
gi
Product Integral with SH
• Fundamental property for graphics
• Proof
III) Illumination from
environment maps
Direct Lighting
• Illumination integral at a point
• How it simplifies for a parallel directional
light
• Environment maps
 Approximate specular reflection
 Lighting does not depend on position
 General illumination integral for an environment
map
 How it simplifies for a specular BRDF
 What if the BRDF is not perfectly specular?
Illumination from environment maps
• SH representation for lighting & BRDF
• Rotation
III) Hemispherical harmonics
Hemispherical harmonics
• New set of basis functions
• Designed for representing hemispherical
functions
• Definition similar to spherical harmonics
Hemispherical harmonics
Shifting
Hemispherical harmonics
SH: Yl,m(θ,φ) = K . Ψ(φ) . Pl,m(cos θ)
HSH: Hl,m(θ,φ) = K . Ψ(φ) . Pl,m(2cos θ-1)
(0,0)
(1,-1)
(2,-2)
(1,0)
(2,-1)
(2,0)
(1,1)
(2,1)
(2,2)
Hemispherical Harmonics
• video
III) Radiance caching
Radiance Caching
• Irradiance caching [Ward88]
 Diffuse indirect illumination is smooth
 Sample only sparsely, cache and interpolate
later
• Low-frequency view BRDF





Indirect illumination smooth as well
But the illumination is view dependent
Irradiance does not describe view dependence
Cache radiance instead of irradiance
RADIANCE CACHING
Radiance Caching
• Incoming radiance representation
• BRDF representation
• Interpolation
• Alignment
• Gradients
• Video