Global Illumination Compendium version ι March 16, 2000 Philip Dutré
[email protected] Program of Computer Graphics Cornell University
http://www.graphics.cornell.edu/~phil/GI/
This collection of formulas and equations is supposed to be useful for anyone who is active in the field of global illumination in computer graphics. The specific selection is made on an ‘as we go’ basis, adding more items if necessary. This compendium does not claim to be complete. Any further input and suggestions for more useful content are therefore strongly appreciated. If possible, adequate references are given to look up some of the equations in more detail, or to look up the derivations. Remember, a compendium as this can only be helpful if it contains content that you would need on a regular basis. Therefore, please let me know what stuff you would like to see included! Since this is still an early version of the compendium, there is a fair chance of errors. Please report any errors, such that future versions have the correct equations and formulas. Thanks to Neeharika Adabala, Martin Blais, Chas Ehrlich, Fabio Pellacini, Mahesh Ramasubramanian, Andrew Willmott, for giving suggestions and/or spotting errors.
Global Illumination Compendium
1
I. General Mathemathics (1) Dirac-impulse (δ-function)
δ ( x ) = 0 if x ≠ 0
∫ dx δ ( a – x ) f ( x )
= f ( a ) if a ∈ D
D
Notation: δ ( a – x ) = δ a ( x )
Global Illumination Compendium
2
II. Geometry (2) Differential surface area at point x : dA x Surface normal at point x : n x Direction vector: Θ (3) Ray casting function surface r ( x, Θ ) = x + t inf ⋅ Θ
r ( x, Θ )
t inf = inf { t > 0: ( x + t ⋅ Θ ) ∈ A }
Θ x if y = r ( x, Θ ) and x ∈ A ⇒ x = r ( y, – Θ ) or x = r ( r ( x, Θ ), – Θ )
surface y = r ( x, Θ )
x = r ( x, – Θ )
Θ
-Θ
surface (4) Visibility function
1 V ( x, y ) = 0
if x and y are mutually visible if x and y are not mutually visible
Global Illumination Compendium
3
III. Hemispherical Geometry (5) Solid angle
nx
A Ω = ---2 r
A Ω x
(6) (Hemi-)Spherical coordinates
r
Z
direction Θ = ( ϕ, θ )
direction Θ solid angle dωΘ
θ
ϕ ∈ [ 0, 2 π ] θ ∈ [ 0, π ⁄ 2 ] x = r cos ϕ sin θ
Y
x
y = r sin ϕ sin θ z = r cos θ r =
ϕ 2
2
x +y +z
2
X
tan ϕ = y ⁄ x 2
2
x +y tan θ = --------------------z 2
dxdydz = r sin θ drd θ d ϕ Spherical coordinates: above formulas remain the same, except θ ∈ [ 0, π ] (7) Differential solid angle d ω Θ = sin θ d θ d ϕ (8) Transformation between differential surface area and differential solid angle cos θ y dA y d ω Θ = -----------------------2 r xy
ny
θy
dAy solid angle dωΘ x
Global Illumination Compendium
y
rxy direction Θ
4
(9) Useful integrals over the full hemisphere (see also 18, 19, 20 and 21) 2π
∫ d ωΘ
Ω
=
π⁄2
∫ dϕ ∫ 0
sin θ d θ = 2 π
0 2π
∫ cos ( Θ, nx ) d ωΘ
=
Ω
∫ dϕ ∫ 0 2π
∫ cosn ( Θ, nx ) d ω Θ
=
Ω
π⁄2
0 π⁄2
∫ dϕ ∫ 0
cos θ sin θ d θ = π 2π cosn θ sin θ d θ = -----------n+1
0
(10) Useful integrals over spherical digons
∫ cosn ( Θ, m ) cos ( Θ, nx ) d ωΘ
(10a)
nx m
(cosine lobe is non-zero on Ω 2 only)
Ω2
A method for computing this integral was presented by J. Arvo, as part of a general method for computing double-axis moments on the hemisphere.1 Pseudocode looks as follows:
Ω1
Ω2
F(nx, m, n) S = 0; d = m.nx; c = sqrt(1-d*d); T = if even(n) then π/2 else c; A = if even(n) then π/2 else π-acos(d); i = if even(n) then 0 else 1; while i 0
= 1
D
b
P[a < y ≤ b] =
∫ p ( x ) dx a
(13) Probability distribution function (a.k.a cumulative distribution function or cdf) x
P(x) =
∫ p ( x ) dx
–∞
0 = P ( –∞ ) ≤ P ( x ) ≤ P ( ∞ ) = 1 (14) Expected value of a random variable x with pdf p(x) ∞
E[x] =
∞
∫ xp ( x ) dx
E[f(x )] =
–∞
∫ f ( x ) p ( x ) dx
–∞
(15) Variance of a random variable x with pdf p(x) 2
2
σ [ f( x )] = E[ (f (x ) – E[ f( x) ] ) ] 2
2
σ [ f( x )] = E[f (x ) ] – E[ f( x )]
2
(16) Generate random variable with given density p ( x ) , using inverse cdf –1
Generate uniform random number r, 0 ≤ r ≤ 1 then compute x = P ( r ) . (17) Generate random variable with given density p ( x ) , using rejection sampling
∀x: p ( x ) < M ; generate uniform random tuplet ( x, y ) ∈ D × [ 0, M ] . If p ( x ) < y reject; otherwise accept.
B. GENERATING POINTS AND DIRECTIONS ON THE (HEMI)SPHERE 1 (18) Generate random point on sphere ( c x, c y, c z, R ) with density p ( Θ ) = -----4π
ϕ = 2 π r1 θ = acos ( 1 – 2r 2 )
Global Illumination Compendium
x = c x + 2R cos ( 2 π r 1 ) r 2 ( 1 – r 2 ) y = c y + 2R sin ( 2 π r 1 ) r 2 ( 1 – r 2 ) z = c z + R ( 1 – 2r 2 ) 7
1 (19) Generate random direction on unit hemisphere with density p ( Θ ) = -----2π 2
x = cos ( 2 π r 1 ) 1 – r 2
ϕ = 2 π r1
2
y = sin ( 2 π r 1 ) 1 – r 2
θ = acos ( r 2 )
z = r2 1 With θ ∈ [ 0, θ max ] and p ( Θ ) = ----------------------------------------2 π ( 1 – cos θ max )
θ max
x x = cos ( 2 π r 1 ) 1 – ( 1 – r 2 ( 1 – cos θ max ) )
ϕ = 2 π r1 θ = acos ( 1 – r 2 ( 1 – cos θ max ) )
y = sin ( 2 π r 1 ) 1 – ( 1 – r 2 ( 1 – cos θ max ) )
2
2
z = r2 cos θ (20) Generate random direction on unit hemisphere with density p ( Θ ) = -----------π x = cos ( 2 π r 1 ) 1 – r 2
ϕ = 2 π r1 θ = acos ( r 2 )
y = sin ( 2 π r 1 ) 1 – r 2 z =
r2
cos θ With θ ∈ [ 0, θ max ] and p ( Θ ) = -------------------------π sin2 θ max x = cos ( 2 π r 1 ) sin θ max r 2
ϕ = 2 π r1
y = sin ( 2 π r 1 ) sin θ max r 2
θ = acos ( 1 – r 2 sin2 θ max )
z =
1 – r 2 sin2 θ max
n+1 (21) Generate random direction on unit hemisphere with density p ( Θ ) = ------------ cosn θ 2π
ϕ = 2 πr1
x = cos ( 2 π r 1 ) 1 –
2 -----------n+1 r2
y = sin ( 2 π r 1 ) 1 –
2 -----------n+1 r2
1
n----------+ 1 θ = acos r 2
z =
Global Illumination Compendium
1 -----------n+1 r2
8
( n + 1 ) cosn θ With θ ∈ [ 0, θ max ] and p ( Θ ) = --------------------------------------------------2 π ( 1 – cosn + 1 θ max )
ϕ = 2 π r1
x = cos ( 2 π r 1 ) 1 – ( 1 – r 2 ( 1 –
cosn + 1 θ
y = sin ( 2 π r 1 ) 1 – ( 1 – r 2 ( 1 –
cosn + 1 θ
max ) )
1
----------- n + 1 θ = acos ( 1 – r 2 ( 1 – cosn + 1 θ max ) )
z = ( 1 – r2 ( 1 –
cosn + 1 θ
max ) )
max ) )
2 -----------n+1
2 -----------n+1
1 -----------n+1
(22) Generate uniform random direction on a spherical triangle See the paper published by J. Arvo in SIGGRAPH 95 for a complete formula and algorithm.1 (23) Generate random direction on spherical digon with density proportional to cosn α , with α angle between direction and off-nornal axis 1. Normalize distribution using (10b) to get proper pdf. 2. Generate direction on unit hemisphere using (21). 3. Transform direction by transforming normal to off-normal axis. 4. If transformed direction has angle greater then π/2 with normal, reject direction and try again.
1. Stratified Sampling of Spherical Triangles, J.Arvo; Proceedings of SIGGRAPH 95. Global Illumination Compendium
9
V. Monte Carlo Integration1 (24) Basic MC integration I =
∫ f ( x ) dx
D
D = [ α 1 …β 1 ] × [ α 2 …β 2 ] × … × [ α d …β d ]
( α i, β i ∈ ℜ )
d Generate a sequence of samples ( x 1, x 2, x 3, ..., x N ) using a uniform pdf p ( x ) = ∏ ( β i – α i ) i = 1 N 1 〈 I〉 = ---- ∑ f ( xi ) N i=1
d ⋅ ∏ ( βi – α i ) i = 1
E [ 〈 I〉 ] =
–1
∫ f ( x ) dx
D
2 1 2 1 2 2 - ∫ ( f ( x ) – I ) dx = -------------------------------------- ∫ f ( x ) dx – I σ [ 〈 I〉 ] = -------------------------------------d d D D N ⋅ ∏ ( βi – αi ) N ⋅ ∏ ( βi – αi ) i=1
i=1
(25) MC integration using importance sampling Generate a sequence of samples ( x 1, x 2, x 3, ..., x N ) using pdf p ( x ) N
1 〈 I〉 = ---N
f ( xi )
∑ ----------p (xi )
E [ 〈 I〉 ] =
∫ f ( x ) dx
D
i=1
2
2 2 1 f(x) 1 f(x) 2 σ [ 〈 I〉 ] = ---- ∫ ---------- – I p ( x ) dx = ---- ∫ ------------ dx – I N p(x ) N p( x) D
D
Optimal pdf for importance sampling, giving minimum variance: f(x) p ( x ) = ------------------∫ f ( x ) dx D
(26) MC integration using stratified sampling α1
1
∫ f ( x ) dx 0
=
α2
αm – 1
∫ f ( x ) dx + ∫ f ( x ) dx + ... + ∫ 0
α1
αm – 2
1
f ( x ) dx +
∫
f ( x ) dx
αm – 1
1. For an introduction on Monte Carlo integration: Monte Carlo Methods, J.M. Hammersley, D.C. Handscomb; Chapman and Hall, London, 1964 Monte Carlo Methods, M.H. Kalos, P.A. Whitlock; Wiley-Interscience, New York, 1986 Monte Carlo: Concepts, Algorithms and Applications, G.S. Fishman; Springer-Verlag, 1996 Global Illumination Compendium
10
If each stratum j receives n j samples, distributed uniformly within each stratum: m 2
σ =
∑ j=1
( α j – αj – 1 ) ---------------------------nj
2
αj 2 1 ∫ f ( x ) dx – ∑ ---n-j ∫ f ( x ) dx αj – 1 j = 1 αj – 1 αj
m
If all strata have equal size, and each stratum contains one sample: 2
αj 2 2 1 σ = ---- ∫ f ( x ) dx – ∑ ∫ f ( x ) dx N j = 1 αj – 1 0 N
1
(27) Combined estimators1 Nj
n
〈 I〉 =
∑ j=1
1 ----Nj
f ( x i, j )
∑ wj ( xi, j ) ---------------p j ( x i, j )
i=1
with x i, j the ith sample, from a total of N j , taken from pdf p j ( x ) . n
If
∑ wj( x )
= 1 for all x, then 〈 I〉 is unbiased.
j=1
(28) Combined estimators: balance heuristic cj pj ( x ) Balance Heuristic: w j ( x ) = ------------------------- with N j = c j N , with N total number of samples. ∑ cj pj ( x ) j
If 〈 I〉 bh is obtained by the balance heuristic, and 〈 I〉 by any other set of w j ( x ) , then:
1 2 2 1 σ [ 〈 I〉 bh ] ≤ σ [ 〈 I〉 ] + ----------------- – -------------- ∫ f ( x ) dx min j N j ∑ N j D j
One sample model ( N = 1 ): if p j is cosen with probability c j , then the balance heuristic gives the lowest variance. (29) Efficiency of a Monte Carlo estimator2 2 1 ε = --------- where T is the time to take 1 sample, and σ is the variance for 1 sample. 2 Tσ
(30) Quasi-random sequences ∞
Radical inverse function: i =
∑ aj b j=0
∞ j
⇒ Φb ( i ) =
∑ aj b
–j–1
j=0
1. Optimally Combining Sampling Techniques for Monte Carlo Rendering, E. Veach, L. Guibas, SIGGRAPH 95 2. Monte Carlo Methods, M.H. Kalos, P.A. Whitlock; Wiley-Interscience, New York, 1986; pp. 91-92 Global Illumination Compendium
11
a. Van der Corput sequence xi = Φb ( i ) b. Halton sequence ( s dimensions) x i = ( Φ b ( i ), Φ b ( i ), Φ b ( i ), Φ b ( i ), …, Φ b ( i ) ) with b 1, b 2, b 3, …, b s relative primes. 1
2
3
4
s
c. Hammersley sequence ( s dimensions, length N ) i x i = ----, Φ b ( i ), Φ b ( i ), Φ b ( i ), Φ b ( i ), …, Φ b ( i ) with b 1, b 2, b 3, …, b s – 1 relative primes. N 1 2 3 4 s–1
Global Illumination Compendium
12
VI. Radiometry & Photometry A general overview of units and measurements can be found at the “How many?” website (http://www.unc.edu/ ~rowlett/units/index.html). (31) Radiometric and Photometric units Radiometry
Photometry
Joule
Radiant Energy Q
→
Luminous Energy
Talbot
Watt
Radiant Power
→
Luminous Power
Lumen (lm)
Watt/m2
Radiosity / Radiant exitance Irradiance
→
Luminosity Illuminance
Lux (lm/m2)
Watt/sr
Radiant Intensity
→
Luminous Intensity
Candelaa (cd or lm/sr)
Watt/m2sr
Radiance
→
Luminance
Nit (cd/m2 or lm/m2sr)
a. Definition of Candela: The luminous intensity, in a given direction, of a source that emits monochromatic radiation of frequency 540x1012 Hz and that has a radiant intensityin that direction of 1/683 Watt per steradian. (PODIS, Glassner, p. 1135) From the “How Many” website: Candela: the fundamental SI unit for measuring the intensity of light. Candela is the Latin word for "candle." The unit has a long and complicated history. Originally, it represented the intensity of an actual candle, assumed to be burning whale tallow at a specified rate in grains per hour. Later this definition was replaced with a definition in terms of the light produced by the filament of an incandescent light bulb. Still later a standard was adopted which defined the candela as the intensity of 1/600 000 square meter of a "black body" (a perfect radiator of energy) at the temperature of freezing platinum (2042 K) and a pressure of 1 atmosphere. This definition has also been discarded, and the candela is now defined to be the luminous intensity of a light source producing single-frequency light at a frequency of 540 terahertz (THz) with a power of 1/683 watt per steradian, or 18.3988 milliwatts over a complete sphere centered at the light source. The frequency of 540 THz corresponds to a wave length of approximately 555.17 nanometers (nm). Light of this frequency has a yellow-green color and roughly the same visual brightness as ordinary daylight. In addition, normal human eyes are more sensitive to this wavelength than to any other. In order to produce 1 candela of single-frequency light of wavelength l, a lamp would have to radiate 1/(683V(l)) watts per steradian, where V(l) is the relative sensitivity of the eye at wavelength l. Values of V(l) are defined by the International Commission on Illumination (CIE).
(32) Flux: radiant energy flowing through a surface per unit time (Watt = Joule/sec) dQ Φ = P = ------dt (33) Irradiance: incident flux per unit surface area (Watt/m2) dΦ E = ------dA Radiant exitance (a.k.a Radiosity): departing flux per unit surface area (Watt/m2) dΦ M = B = ------dA (34) Radiant Intensity: flux per solid angle (Watt/sr) dΦ I = ------dω Global Illumination Compendium
13
(35) Radiance: flux per solid angle per unit projected area (Watt/m2sr) 2
2
dE d Φ d Φ L = ------- = ------------------ = --------------------------⊥ d ω dA cos θ dω d ω dA Notations: L ( x → Θ ) : radiance leaving point x in direction Θ L ( x ← Θ ) : radiance arriving at point x from direction Θ L ( x → y ) : radiance leaving point x in the direction towards point y L ( x ← y ) : radiance arriving at point x, coming from the direction of point y Properties: L ( x → y ) = L ( y ← x ) if x and y are mutually visible L ( x → Θ ) = L ( r ( x, Θ ) ← – Θ ) Integration: specify integration domain if specific values are needed
Φ =
∫ dA x ∫ d ωx L ( x → Θ ) cos θ
E(x ) =
∫ d ωx L ( x ← Θ ) cos θ
B(x ) =
∫ d ωx L ( x → Θ ) cos θ
I( Θ) =
∫ dA x L ( x → Θ )
=
∫ dAx E ( x )
=
∫ d ω x I ( Θ ) cos θ
(36) Radiometric quantities → Photometric quantities Integrate radiometric quantity R ( λ ) weighted by the spectral luminous efficiency curve V ( λ ) 1 V(λ) 1 0.8
0.6
0.4
0.2
0 380
430
480
530
580
630
680
730
780
λ ( nm )
770nm
P = Km
∫
V ( λ ) R ( λ ) dλ
K m = 680lumen/watt
380nm
1. Tabular data for the spectral luminous efficiency curve: Principles of Digital Image Synthesis, A. Glassner, p. 1170 Global Illumination Compendium
14
VII. Optics (37) Reflection at perfect mirror (incoming, direction, outgoing direction, and surface normal in same plane)
θr = θi (38) Refraction at transition from vacuum to material (incoming direction, refracted direction, and surface normal in same plane) sin θ i ------------- = n sin θ r
1 sin θ g = --n
π 0 < θ i < --2
0 < θr < θg
θi
θr
θi for small angles: ----- = n (Kepler’s formula) θr
θg
(39) Refraction at transition from material to vacuum (incoming direction, refracted direction, and surface normal in same plane) if 0 < θ i < θ g
θr
sin θ i 1 ------------- = --sin θ r n
θi 1 for small angles: ----- = --θr n
θi θg
(40) Refraction at transition from material 1 to material 2 (incoming direction, refracted direction, and surface normal in same plane)
θi
n2 sin θ i ------------- = ----- = n 1 → 2 sin θ r n1
n1 n2 θr
(41) Total internal refraction (incoming direction, refracted direction, and surface normal in same plane)
π if θ g < θ i < --2
n1
θ t = θi
θi
θg
θt
n2
(42) Fresnel Equations N2 Material 1 to material 2; relative index of refraction N = ------ = η + j κ ; θ is angle of incidence N1
Global Illumination Compendium
15
2
2
a + b – 2 acos θ + cos2 θ F s = --------------------------------------------------------------2 2 a + b + 2 acos θ + cos2 θ 2
2
a + b – 2 acos θ tan θ + sin2 θ tan2 θ F p = F s ---------------------------------------------------------------------------------------2 2 a + b + 2 acos θ tan θ + sin2 θ tan2 θ 2
2
2
2 2
2
2
2
2
2
2 2
2
2
2a =
2
( η – κ – sin2 θ ) + 4 η κ + ( η – κ – sin2 θ )
2
( η – κ – sin2 θ ) + 4 η κ – ( η – κ – sin2 θ )
2b =
Polarized light: reflectance F r = sF s + pF p with s + p = 1 Fs + Fp Unpolarized light: F r = -----------------2
Global Illumination Compendium
16
VIII. Bidirectional Reflectance Distribution Functions (BRDFs) A. GENERAL PROPERTIES dL ( x → Θ r ) dL ( x → Θ r ) (43) BRDF: f r ( x, Θ i → Θ r ) = ----------------------------- = ---------------------------------------------------dE ( x ← Θ i ) L ( x ← Θ i ) cos θ i d ω Θ i
nx
Θi
θi Θr
θr
dL ( x → Θ r )
dE ( x ← Θ i )
x BRDF is dimensionless but can be expressed as 1/sr (44) BRDF Reciprocity f r ( x, Θ i → Θ r ) = f r ( x, Θ r → Θ i ) = f r ( x, Θ i ↔ Θ r ) (45) BRDF Energy conservation
∀Θ :
∫ d ω Ψ fr ( x, Θ ↔ Ψ ) cos ( nx, Ψ ) ≤ 1
Ωx
(46) Biconical Reflectance
∫
d ωΘ
Ω
out
∫ d ωΘ
in
f ( Θ in ↔ Θ out ) cos θ out cos θ in
Ω
r
out in ρ ( Θ in → Θ out ) = -----------------------------------------------------------------------------------------------------------------------d ω cos θ ∫ Θin in
Ω in
Ωin and Ωout can be a single direction, a solid angle, or the hemisphere. Combine the words ‘directional’, ‘conical’ and ‘hemispherical’ to obtain the right adjective for the reflectance. E.g. Biconical reflectance; directionalhemispherical reflectance etc.1 (47) Lambertian Diffuse Reflection f r ( x, Θ i ↔ Θ r ) = f r, d = constant L ( x → Θ ) = f r, d
∫ d ωΘ
in
L ( x ← θ in ) cos θ in = f r, d E
Ω in
B Bihemispherical reflectance: ρ d = f r, d π and ρ d = --E 1. Definitions from Radiosity and Realistic Image Synthesis; M. Cohen and J. Wallace; Academic Press; p32 Global Illumination Compendium
17
B. BRDF MODELS General notations for BRDF models:
Θ r Outgoing direction of light. Θ i Incoming direction of light Θ s Perfect specular direction w.r.t. Θ i Θ h Halfway vector between Θ r and Θ i Spherical coordinates are using the same index. E.g. for the outgoing direction ( ϕ r, θ r ) Cartesian coordinates are also using the same index. E.g. for the outgoing direction ( x r, y r, z r ) . Normally, these will assumed to be normalized. In general, negative values for cosine-lobes are ignored and set to zero. (48) Modified Phong-BRDF1 a. f r ( Θ i ↔ Θ r ) = k d + k s cosn ( Θ r, Θ s ) 2π Energy conservation: π k d + ------------ k s ≤ 1 n+2 Proportional sampling: see 20 and 23. b. f r ( Θ i ↔ Θ r ) = k d + k s cosn θ h n
8π( 1 + n 2 ) Energy conservation: π k d + --------------------------------------------- k s ≤ 1 n (n + 2 )(n + 4) 2 (49) Ward-BRDF2 2
exp ( – tan2 θ h ⁄ α ) ρd 1 a. Isotropic Gaussian Model: f r ( Θ i ↔ Θ r ) = ----- + ρ s ⋅ -------------------------------- ⋅ -------------------------------------------2 π cos θ cos θ 4 πα i
r
α is standard deviation (RMS) of the surface slope. Energy conservation: ρ d + ρ s ≤ 1 ; Normalization 2
1 ⁄ 4 πα is accurate as long α is not much greater than 0.2 (surface is then mostly diffuse).
Proportional sampling of specular part (is already normalized as a pdf):
θ h = α – log ( r 1 ) ϕ = 2 π r2
1. The modified Phong-BRDF is very similar to the Phong shading function and was introduced as a BRDF in Making Shaderes More Physically Plausible, Robert R. Lewis, Computer Graphics Forum, 13 (2), 1994 (also in Proceedings of the 4th Eurographics Workshop on Rendering, 1993). 2. Measuring and Modeling Anisotropic Reflection, G. Ward, SIGGRAPH 92 Global Illumination Compendium
18
b. Anisotropic Elliptical Gaussian Model: 2
2
ρd exp ( – tan2 θ h ( cos2 ϕ h ⁄ α x + sin2 ϕ h ⁄ α y ) ) 1 f r ( Θ i ↔ Θ r ) = ----- + ρ s ⋅ -------------------------------- ⋅ ---------------------------------------------------------------------------------------------------4 πα x α y π cos θ cos θ i
r
α x and α y are are the standard deviation of the surface slope in the x and y direction at the tangent plane. 2
2
Energy conservation: ρ d + ρ s ≤ 1 and α x « 1 and α y « 1
θh = Proportional sampling of specular part (is already normalized as a pdf):
– log ( r 1 ) -------------------------------------------------------2 2 cos2 ϕ ⁄ α x + sin2 ϕ ⁄ α y
αx ϕ = atan ------ tan ( 2 π r 2 ) αy
(50) Lafortune-BRDF1 fr ( Θi ↔ Θ r ) =
∑ ( C x , k x i x r + C y , k y i y r + C z, k z i z r )
nk
k
which can also be written as: fr ( Θi ↔ Θ r ) =
∑ Ck ( Θ i ) ( Θ a ⋅ Θ r )
nk
k
where:
( C x, k x i, C y, k y i, C z, k z i ) Θ a = -----------------------------------------------------------------2 2 2 2 2 2 C x, k x i + C y, k y i + C z, k z i Ck ( Θi ) =
2 2 ( C x, k x i
+
2 2 C y, k y i
+
nk ---2 2 2 C z, k z i )
Therefore, the BRDF is a combination of cosine-lobes, each centered around a different axis Θ a Proportional sampling: 1. Integrate different cosine-lobes over spherical digons using (10b) 2. Select cosine-lobe proportional to the above computed values. 3. Generate direction according to this cosine-lobe (23)
1. Non-Linear Approximation of Reflectance Functions. E. Lafortune, S. Foo, K. Torrance, D. Greenberg. Proceedings of SIGGRAPH 97. Global Illumination Compendium
19
IX. Rendering Equation and Global Illumination Formulations (51) Rendering Equation (Radiance), integration over incoming hemisphere L ( x → Θ out ) = L e ( x → Θ out ) +
∫ d ωΘ L ( x ← Θ ) f r ( x, Θ ↔ Θout ) cos ( nx, Θ )
Ωx
(52) Rendering Equation (Radiance), integration over all surfaces L ( x → y ) = L e ( x → y ) + ∫ dA z L ( x ← z ) f r ( x, z ↔ y ) G ( x, z ) A
cos ( n x, Θ ) cos ( n z, – Θ ) V ( x, z ) G ( x, z ) = ------------------------------------------------------------------------2 r xz (53) Continuous Radiosity Equation, diffuse reflection, diffuse light sources, integration over surfaces B( x) = π L( x ) Be ( x ) = π L ( x )
ρ ( x ) = π fr ( x ) G ( x, z ) B ( x ) = B e ( x ) + ρ ( x ) ∫ dA z B ( z ) ----------------π A
(54) Participating Media1,2 Radiance along a path: dL ------ = – κ t L + κ a L e + κ s ∫ d ω Θ L i ( Θ ) f ( Θ ) ds Ω
or: s
L ( s ) = L ( 0 )τ ( 0, s ) + ∫ τ ( s’, s ) J ( s’)κt ( s’) ds’ 0
s2 τ ( s 1, s 2 ) = exp – ∫ κ t ( s ) ds : transmitttance function s1 κ t ( s ) : extinction coefficient. κ t = κ a + κ s . If isotropic, κt ( s ) is constant and τ ( s 1, s 2 ) = e
–κt s1 – s2
f ( Θ ) : phase function, describing in-scattering along the path 1 f isotropic = -----4π 1. Radiosity and Realistic Image Synthesis; M. Cohen and J. Wallace; Academic Press; p325 2. Radiosity & Global Illumination, F. Sillion and C. Puech; Morgan-Kaufmann Global Illumination Compendium
20
J ( s ) : source function, describing in-scattering and emission. J ( s ) = ( 1 – R ( s ) ) L e + R ( s ) ∫ d ω Θ Li ( Θ ) f ( Θ ) Ω
κs R ( s ) = ----- : scattering albedo of the medium κt
Global Illumination Compendium
21
X. Form Factors Notation: The ‘sender’ surface is always placed as the first index, the ‘receiver’ surface as the second. An extra arrow indicates the ‘energy flow’. This notation is consistent with other notations in literature, where the arrow usually is not used. (55) Differential Form Factor cos θ x cos θ y dFdA x → dA y = ----------------------------- dA y 2 π r xy With visibility term: cos θ x cos θ y dFdA x → dA y = ----------------------------- V ( x, y ) dAy 2 π r xy (56) Differential element to element Form Factor F dA x → j =
cos θ x cos θ y
- V ( x, y ) dA y ∫ ---------------------------2 πr
Aj
xy
(57) Differential element to polygon Form Factor; full visibility1 Vi E
FdA
x
→j
1 = -----2π
∑ nx ⋅ Γi
( E = number of edges or vertices of the polygon)
i=1
where Γ i = V i ⊗ V i + 1 and magnitude of Γ i = γ i .
nx
γi
Vi + 1
(58) Element to element Form Factor cos θ x cos θ y
1 F i → j = ----- ∫ Ai
- V ( x, y ) dA y dA x ∫ ---------------------------2 πr
1 F i → j = ----- ∫ Ai
- V ( x, y ) d ω Θ dA x ∫ ------------π
Ai Aj
xy
cos θ x
Ai Ωx
(59) Element to element Form Factor; full visibility; Stoke’s Theorem 1 F i → j = ------------ ∫ ∫ ( ln rdx i dx j + ln rdy i dy j + ln rdz i dz j ) 2 π Ai ° ° Ci Cj
An analytic solution for this integral, given any two general polygons, was derived by Schröder and Hanrahan2. 1. Improving Radiosity Solutions Through the Use of Analytically Determined Form-Factors, Daniel Baum, Holly Rushmeier, James Winget; Proceedings of SIGGRAPH 89; pp 325-334 2. On the Form Factor between Two Polygons, Peter Schröder, Pat Hanrahan; Proceedings of SIGGRAPH 93; pp 163-164. Global Illumination Compendium
22
(60) Properties of Form Factors Ai Fi → j = Aj Fj → i In a closed environment:
∑ Fi → j
= 1
j
Global Illumination Compendium
23
XI. Radiosity System & Algorithms The term ‘Radiosity’ is used in various ways in photorealistic image synthesis: as the radiometric quantity describing incident energy integrated over the hemisphere; but also to indicate a specific class of algorithms that compute an energy distribution in the scene. Although there is no formal definition of what a ‘radiosity algorithm’ actually is, it is usually assumed that one means a finite-element solution, computing diffuse light interaction only. Most radiosity literature uses Galerkin Radiosity, a projection method to transform the continuous radiosity equations (53) into a set of linear equations. Unless otherwise indicated, Galerkin radiosity is used in this section. (61) System of radiosity equations, constant basis functions
∀patches i:
B i = B ei + ρ i ∑ F i → j B j j
1 – ρ1 F1 → 1 –ρ1 F1 → 2 … –ρ1 F1 → n
B1
–ρ2 F2 → 1 1 – ρ2 F2 → 2 … –ρ2 F2 → n
B2
… –ρn Fn → 1
… … … … –ρn Fn → 2 … 1 – ρn Fn → n Bn
B e1 =
B e2
… B en
(62) System of power equations, constant basis functions Pi = Ai Bi
∀patches i:
P i = P ei + ρ i ∑ F j → i P j j
1 – ρ1 F1 → 1 –ρ1 F2 → 1 … –ρ1 Fn → 1
P1
–ρ2 F1 → 2 1 – ρ2 F2 → 2 … –ρ2 Fn → 2
P2
… –ρn F1 → n
… … … … –ρn F2 → n … 1 – ρn Fn → n Pn
Global Illumination Compendium
P e1 =
P e2
… P en
24
XII. Color & Display1 (63) Spectrum C ( λ ) to CIE XYZ Color matching functions x ( λ ), y ( λ ), z ( λ ) 2 1.8
z(λ)
1.6 1.4 1.2
y(λ) x(λ)
1 0.8 0.6 0.4 0.2 0 380
430
780nm
∫
X =
480
530
580
630
680
780nm
C ( λ ) x ( λ ) dλ
Y =
380nm
∫
Y y = ----------------------X+Y+Z
780
λ
780nm
C ( λ ) y ( λ ) dλ
∫
Z =
380nm
X x = ----------------------X+Y+Z
730
C ( λ ) z ( λ ) dλ
380nm
Z z = ----------------------X+Y+Z
(64) xYz to XYZ x X = Y -y
Y = Y
(1 – x – y) Z = Y ------------------------y
(65) CIE XYZ to Spectrum C ( λ ) 3 Choose 3 linearly independent functions F 1 ( λ ) , F 2 ( λ ) and F 3 ( λ ) . C ( λ ) can be writtten as aF 1 ( λ ) + bF 2 ( λ ) + cF 3 ( λ ) with a , b , c determined by:
X Y = Z
∫ F1 ( λ ) x ( λ ) dλ ∫ F2 ( λ ) x ( λ ) dλ ∫ F3 ( λ ) x ( λ ) dλ ∫ F1 ( λ ) y ( λ ) dλ ∫ F2 ( λ ) y ( λ ) dλ ∫ F3 ( λ ) y ( λ ) dλ ∫ F1 ( λ ) z ( λ ) dλ ∫ F2 ( λ ) z ( λ ) dλ ∫ F3 ( λ ) z ( λ ) dλ
a b c
1. A good source for color data: http://cvision.ucsd.edu/basicindex.htm 2. Tabular data for the color matching curves: Principles of Digital Image Synthesis, A. Glassner, p.1170 3. How to Derive a Spectrum from an RGB Triplet, A. Glassner, IEEE CG&A, 9(4):95-99, July 1989 Global Illumination Compendium
25
E.g. 1: Dirac-impulse functions at wavelengths λ u , λv and λ w . x ( λu ) x ( λv ) x ( λw ) X a Y = y ( λu ) y ( λv ) y ( λw ) b Z z ( λu ) z ( λv ) z ( λw ) c E.g. 2: First three Fourier basis functions defined on interval [ λ min, λ max ] = [ 380, 780 ] F 1 ( λ ) = 1.0
λ – 380 1 F 2 ( λ ) = --- 1 + sin 2 π ------------------ 2 400 λ – 380 1 F 3 ( λ ) = --- 1 + cos 2 π ------------------ 2 400 (66) CIE XYZ to/from NTSC standard RGB based on standard CIE phospors and D6500 white point. Scaling is such that RGB=[1,1,1] produces the chromaticity values of the white point with Y=1.0.1 x
y
r
0.670
0.330
g
0.210
0.710
b
0.140
0.080
w
0.313
0.329
X 0.5893 0.1789 0.1831 R = Y 0.2904 0.6051 0.1045 G Z 0.0000 0.0684 1.0202 B R 1.967 – 0.548 – 0.297 X G = – 0.955 1.938 – 0.027 Y B 0.064 – 0.130 0.982 Z * * *
(67) XYZ to/from L u v color space Defined w.r.t. white point ( X n, Y n, Z n ) , usually scaled such that Y n = 100 .
Y ⁄ Y n ≥ 0.008856 L = Y ⁄ Y n ≤ 0.008856 *
*
*
*
*
116 ( Y ⁄ Y n )
1⁄3
4X u’ = -------------------------------X + 15Y + 3Z – 16
9Y v’ = -------------------------------X + 15Y + 3Z
903.3 ( Y ⁄ Y n )
u = 13L ( u' – u' n ) v = 13L ( v' – v' n )
where
4X n u’n = ---------------------------------------X n + 15Y n + 3Z n 9Y n v’n = ---------------------------------------X n + 15Y n + 3Z n
1. Principles of Digital Image Synthesis, A. Glassner, p.104 Global Illumination Compendium
26
A X = – --- + 3Z R
*
*
L + 16 Y = Y n ------------------ 116
3
u Q = ------------ + u’n * 13L where
( Q – 4 ) A – 15QRY Z = ---------------------------------------------12R
*
v R = ------------ + v’n * 13L A = 3Y ( 5R – 3 )
* * *
(68) XYZ to/from L a b color space Defined w.r.t. white point ( X n, Y n, Z n ) , usually scaled such that Y n = 100 .
Y ⁄ Y n ≥ 0.008856 * L = Y ⁄ Y n ≤ 0.008856 *
*
*
*
116 ( Y ⁄ Y n )
1⁄3
903.3 ( Y ⁄ Y n )
a = 500L ( f ( X ⁄ Xn ) – f ( Y ⁄ Y n ) )
– 16
r ≥ 0.008856 where f ( r ) = r ≤ 0.008856
r
1⁄3
7.787r + 16 ⁄ 116
b = 200L ( f ( Y ⁄ Y n ) – f ( Z ⁄ Z n ) ) * Y 1⁄3 a X = X n ----- + --------------- * Y n 500L *
L + 16 Y = Y n ------------------ 116
3
3
* Y 1⁄3 b Z = Z n ----- + --------------- * Y n 200L
Global Illumination Compendium
3
27