Biased Monte Carlo Ray Tracing: Filtering, Irradiance Caching and Photon Mapping Dr. Henrik Wann Jensen Stanford University May 24, 2001
Unbiased and consistent Monte Carlo methods Unbiased estimator: E{X} =... Consistent estimator: lim E{X} N... Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 2
Unbiased and consistent: A very simple example Unbiased estimator: 1 N N i=1 f(ξ i ) Consistent estimator: 1 N + 1 N i=1 f(ξ i ) Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 3
Path tracing (unbiased) 10 paths/pixel Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 4
Path tracing (unbiased) 10 paths/pixel Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 5
Path tracing (unbiased) 100 paths/pixel Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 6
How can we remove this noise?)
How can we remove this noise?) More samples (slow convergence, σ 1/ N)
How can we remove this noise?) More samples (slow convergence, σ 1/ N) Better sampling (stratified, importance, qmc etc.)
How can we remove this noise?) More samples (slow convergence, σ 1/ N) Better sampling (stratified, importance, qmc etc.) Adaptive sampling
How can we remove this noise?) More samples (slow convergence, σ 1/ N) Better sampling (stratified, importance, qmc etc.) Adaptive sampling Filtering
How can we remove this noise?) More samples (slow convergence, σ 1/ N) Better sampling (stratified, importance, qmc etc.) Adaptive sampling Filtering Caching and interpolation Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 7
Stratified sampling 10 paths/pixel Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 8
Quasi Monte-Carlo (Halton sequence) 10 paths/pixel Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 9
Fixed (Random) Sequence 10 paths/pixel Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 10
Filtering: idea Noise is high frequency
Filtering: idea Noise is high frequency Remove high frequency content Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 11
Unfiltered image 10 paths/pixel Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 12
3x3 lowpass filter 10 paths/pixel Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 13
3x3 median filter 10 paths/pixel Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 14
Energy preserving filters
Energy preserving filters Distribute noisy energy over several pixels
Energy preserving filters Distribute noisy energy over several pixels Adaptive filter width Diffusion style filters Splatting style filters Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 15
Problems with filtering Everything is filtered (blurred) Textures Highlights Caustics...
Problems with filtering Everything is filtered (blurred) Textures Highlights Caustics... Solution: Try to filter the noisy part of the illumination Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 16
Caching Techniques
Caching Techniques Irradiance caching : Compute irradiance at selected points and interpolate. Photon mapping : Density estimation and importance sampling using a precomputed flux representation. Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 17
Box: direct illlumination Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 18
Box: global illlumination Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 19
Box: indirect irradiance Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 20
Irradiance caching: idea Greg Ward, Francis Rubinstein and Robert Clear: ``A Ray Tracing Solution for Diffuse Interreflection''. Proceedings of SIGGRAPH 1988. Idea: Irradiance changes slowly interpolate. Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 21
Irradiance sampling E(x) = 2π L (x, ω ) cos θ dω
Irradiance sampling E(x) = = L (x, ω ) cos θ dω 2π 2π π/2 0 0 L (x, θ, φ) cos θ sin θ dθ dφ
Irradiance sampling E(x) = = 0 L (x, ω ) cos θ dω 2π 2π π/2 π T P θ t = sin 1 ( 0 T t=1 t ξ T ) L (x, θ, φ) cos θ sin θ dθ dφ P p=1 L (θ t, φ p ) and φ p = 2π p ψ P Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 22
Irradiance change ɛ(x) E x (x x 0) + E θ (θ θ 0) } {{ } } {{ } position rotation
Irradiance change ɛ(x) E x (x x 0) + E θ (θ θ 0) } {{ } } {{ } position rotation ( ) 4 x x 0 E 0 + 2 2N(x) π x N(x 0 ) avg } {{ } } {{ } position rotation Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 23
Irradiance interpolation w(x) = 1 ɛ(x) 1 x x 0 1 N(x) N(x 0 ) x avg + E i (x) = i w i (x)e(x i ) w i (x) i Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 24
Irradiance caching algorithm Find all irradiance samples with w(x) > q if (samples found) interpolate else compute new irradiance sample Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 25
Box: irradiance gradients 1000 sample rays, w>10 Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 26
Box: irradiance cache positions 1000 sample rays, w>10 Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 27
Box: irradiance gradients 1000 sample rays, w>20 Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 28
Box: irradiance cache positions 1000 sample rays, w>20 Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 29
Box: irradiance gradients 5000 sample rays, w>10 Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 30
Box: irradiance cache positions 5000 sample rays, w>10 Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 31
Photon Mapping Two-pass method: Pass 1 : Build a photon map using photon tracing Pass 2 : Render the image using the photon map Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 32
A simple test scene Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 33
Building the Photon Map: Photon Tracing Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 34
Photons Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 35
The photon map datastructure The photons are stored in a left balanced kd-tree struct photon = { float position[3]; rgbe power; char phi, theta; short flags; } // power packed as 4 bytes // incoming direction Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 36
Radiance estimate L(x, ω) = Ω f r (x, ω, ω)l (x, ω ) cos θ dω
Radiance estimate L(x, ω) = = Ω Ω f r (x, ω, ω)l (x, ω ) cos θ dω f r (x, ω, ω) dφ2 (x, ω ) dω cos θ da cos θ dω
Radiance estimate L(x, ω) = = = Ω Ω Ω f r (x, ω, ω)l (x, ω ) cos θ dω f r (x, ω, ω) dφ2 (x, ω ) dω cos θ da cos θ dω f r (x, ω, ω) dφ2 (x, ω ) da
Radiance estimate L(x, ω) = = = f r (x, ω, ω)l (x, ω ) cos θ dω Ω f r (x, ω, ω) dφ2 (x, ω ) Ω dω cos θ da cos θ dω f r (x, ω, ω) dφ2 (x, ω ) Ω da n f r (x, ω p, ω) Φ p(x, ω p) πr 2 p=1 Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 37
Radiance estimate L Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 38
Reflection inside a metal ring 50000 photons / 50 photons in radiance estimate Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 39
Caustics on glossy surfaces 340000 photons / 100 photons in radiance estimate Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 40
Cognac glass Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 41
Cube caustic Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 42
Caustic from a glass sphere 10000 photons / 50 photons in radiance estimate Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 43
Caustic from a glass sphere Path tracing 1000 paths/pixel Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 44
Caustic from a glass sphere in Grace Cathedral Using lightprobe from www.debevec.org Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 45
Direct visualization of the radiance estimate 100000 photons / 50 photons in radiance estimate Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 46
Direct visualization of the radiance estimate 500000 photons / 500 photons in radiance estimate Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 47
Fast estimate 200 photons / 50 photons in radiance estimate Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 48
Only use photons for indirect irradiance 10000 photons / 500 photons in radiance estimate Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 49
Two photon maps global photon map caustics photon map Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 50
Rendering Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 51
Rendering: direct illumination Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 52
Rendering: specular reflection Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 53
Rendering: caustics Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 54
Rendering: indirect illumination Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 55
Two-pass method Radiance = direct illumination + specular reflection/transmission + caustics + soft indirect irradiance Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 56
Rendering Equation Solution L r (x, ω) = = f r (x, ω, ω)l i (x, ω ) cos θ i dω i Ω x Ω x f r (x, ω, ω)l i,l (x, ω ) cos θ i dω i + Ω x f r,s (x, ω, ω)(l i,c (x, ω ) + L i,d (x, ω )) cos θ i dω i + Ω x f r,d (x, ω, ω)l i,c (x, ω ) cos θ i dω i + Ω x f r,d (x, ω, ω)l i,d (x, ω ) cos θ i dω i. Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 57
Box 200000 global photons, 50000 caustic photons Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 58
Fractal box 200000 global photons, 50000 caustic photons Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 59
Sphereflake caustic Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 60
Little Matterhorn Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 61
Mies house (swimmingpool) Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 62
Mies house (3pm) Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 63
Mies house (6pm) Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 64
Mies house (7pm) Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 65
Participating media Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 66
Participating media: photon tracing Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 67
The volume photon map Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 68
The volume radiance estimate L ( ω )L(x, ω) = n p=1 p(x, ω p, ω) Φ p(x, ω p) 4 3 πr3 Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 69
Rendering participating media Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 70
Volume caustic Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 71
Rising smoke Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 72
Rising smoke Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 73
Subsurface scattering Skin Marble Actually most materials Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 74
Subsurface scattering Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 75
David (subsurface scattering) Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 76
David (subsurface scattering) Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 77
Diana the Huntress
Diana the Huntress
Diana the Huntress Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 78
Diana the Huntress Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 79
Diana the Huntress: no subsurface scattering Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 80
Diana the Huntress: subsurface scattering Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 81
More information http://graphics.stanford.edu/~henrik/ henrik@graphics.stanford.edu Biased Monte Carlo ray tracing: filtering, irradiance caching and photon mapping 82