spherical harmonic lighting jaroslav křivánek. overview function approximation function...
TRANSCRIPT
Spherical Harmonic LightingSpherical Harmonic Lighting
Jaroslav KJaroslav Křivánekřivánek
OverviewOverview
• Function approximationFunction approximation
• Spherical harmonicsSpherical harmonics
• Some other timeSome other time Illumination from environment mapsIllumination from environment maps
•BRDF representation by spherical harmonics
•Spherical harmonics rotation Hemispherical harmonicsHemispherical harmonics Radiance CachingRadiance Caching Precomputed Radiance TransferPrecomputed Radiance Transfer
•Clustered Principal Component Analysis
•Wavelet Methods
I) Function ApproximationI) Function Approximation
Function ApproximationFunction Approximation
• G(x) ... function to approximateG(x) ... function to approximate
• BB11(x), B(x), B22(x), … B(x), … Bnn(x) … basis functions(x) … basis functions
• We wantWe want
• Storing a finite number of coefficients Storing a finite number of coefficients ccii gives an gives an approximation of G(x)approximation of G(x)
)()(1
xBcxG i
n
ii
Function ApproximationFunction Approximation
• How to find coefficients cHow to find coefficients cii?? Minimize an error measureMinimize an error measure
• What error measure?What error measure? LL22 error error
2])()([
2 I i
iiL xBcxGE
Function ApproximationFunction Approximation
• Minimizing Minimizing EELL22 leads to leads to
• WhereWhere
(function scalar product)(function scalar product)
nnnnnn
n
BG
BG
BG
c
c
c
BBBBBB
BBBB
BBBBBB
2
1
2
1
21
2212
12111
I
dxxGxFGF )()(
Function ApproximationFunction Approximation
• Orthonormal basisOrthonormal basis
• If basis is orthonormal thenIf basis is orthonormal then
we want our bases to be orthonormalwe want our bases to be orthonormal
ji
jiGG ji 0
1
nn BG
BG
BG
c
c
c
2
1
2
1
II) Spherical HarmonicsII) Spherical Harmonics
Spherical HarmonicsSpherical Harmonics
• Spherical function approximationSpherical function approximation
• Domain Domain II = unit sphere = unit sphere SS = directions in 3D= directions in 3D
• Approximated function: G(Approximated function: G(θθ,,φφ))
• Basis functions: YBasis functions: Yii((θθ,,φφ)= Y)= Yll,,mm((θθ,,φφ)) indexing: i = indexing: i = ll (l+1)(l+1) ++ mm
Spherical HarmonicsSpherical Harmonics
Y0,0
Y1,-1
Y2,-2 Y2,-1 Y2,0 Y2,1 Y2,2
Y1,0 Y1,1
band 0 band 0 (l=0)(l=0)
band 1 band 1 (l=1)(l=1)
band 2 band 2 (l=2)(l=2)
Spherical HarmonicsSpherical Harmonics
• K … normalization constantK … normalization constant• P … Associted Legendre polynomialP … Associted Legendre polynomial
Orthonormal polynomial basis on (0,1)Orthonormal polynomial basis on (0,1)
• In general: In general:
YYl,ml,m((θθ,,φφ) = K . ) = K . ΨΨ((φφ) . P) . Pl,ml,m(cos (cos θθ)) YYl,ml,m((θθ,,φφ) is separable in ) is separable in θθ and and φφ
Function Approximation with SHFunction Approximation with SH
• n…approximation ordern…approximation order
• There are There are nn22 harmonics for order harmonics for order nn
),(),( ,
1
0, ml
n
l
lm
lmml YcG
Function Approximation with SHFunction Approximation with SH
• Spherical harmonics are ORTHONORMALSpherical harmonics are ORTHONORMAL
• Function projectionFunction projection Computing the SH coefficients Computing the SH coefficients
Usually evaluated by numerical integrationUsually evaluated by numerical integration
• Low number of coefficients Low number of coefficients
low-frequency signallow-frequency signal
2
0 0
,,,, sin),(),()()( ddYGdYGYGc ml
S
mlmlml
Product Integral with SHProduct Integral with SH
• Simplified indexing Simplified indexing YYii= = YYl,ml,m
ii = = ll ((ll+1)+1) ++ mm
• 2 functions represented by SH2 functions represented by SH
• Integral of F(Integral of F(ωω).G().G(ωω) is the dot product of ) is the dot product of F’s and G’s SH coefficientsF’s and G’s SH coefficients
)()(2
0
i
n
iiYfF
)()(2
0
i
n
iiYgG
2
0
)()(n
iii
S
gfdGF
Product Integral with SHProduct Integral with SH
F(ω) = fi Yi(ω)
G(ω) =gi Yi(ω)
G(ω)F(ω)dx = fi gi
Product Integral with SHProduct Integral with SH
• Fundamental property for graphicsFundamental property for graphics
• ProofProof
III) Illumination from environment III) Illumination from environment mapsmaps
Direct LightingDirect Lighting
• Illumination integral at a pointIllumination integral at a point
• How it simplifies for a parallel directional How it simplifies for a parallel directional lightlight
• Environment mapsEnvironment maps Approximate specular reflectionApproximate specular reflection Lighting does not depend on positionLighting does not depend on position General illumination integral for an environment General illumination integral for an environment
mapmap How it simplifies for a specular BRDFHow it simplifies for a specular BRDF What if the BRDF is not perfectly specular?What if the BRDF is not perfectly specular?
Illumination from environment mapsIllumination from environment maps
• SH representation for lighting & BRDFSH representation for lighting & BRDF
• RotationRotation
III) Hemispherical harmonicsIII) Hemispherical harmonics
Hemispherical harmonicsHemispherical harmonics
• New set of basis functions
• Designed for representing hemispherical functions
• Definition similar to spherical harmonics
Hemispherical harmonicsHemispherical harmonics
Shifting
Hemispherical harmonicsHemispherical harmonics
(0,0)
(1,-1)
(2,-2) (2,-1) (2,0) (2,1) (2,2)
(1,0) (1,1)
SH: YSH: Yl,ml,m((θθ,,φφ) = K . ) = K . ΨΨ((φφ) . P) . Pl,ml,m(cos (cos θθ))
HSH: HHSH: Hl,ml,m((θθ,,φφ) = K . ) = K . ΨΨ((φφ) . P) . Pl,ml,m(2cos (2cos θθ-1)-1)
Hemispherical HarmonicsHemispherical Harmonics
• videovideo
III) Radiance cachingIII) Radiance caching
Radiance CachingRadiance Caching
• Irradiance caching [Ward88]Irradiance caching [Ward88] Diffuse indirect illumination is smoothDiffuse indirect illumination is smooth Sample only sparsely, cache and interpolate Sample only sparsely, cache and interpolate
laterlater
• Low-frequency view BRDFLow-frequency view BRDF Indirect illumination smooth as wellIndirect illumination smooth as well But the illumination is view dependentBut the illumination is view dependent Irradiance does not describe view dependenceIrradiance does not describe view dependence Cache radiance instead of irradianceCache radiance instead of irradiance RADIANCE CACHINGRADIANCE CACHING
Radiance CachingRadiance Caching
• Incoming radiance representationIncoming radiance representation
• BRDF representationBRDF representation
• InterpolationInterpolation
• AlignmentAlignment
• GradientsGradients
• VideoVideo