Sampling and Reconstruction of Visual Appearance CSE 74 [Winter 8], Lecture 3 Ravi Ramamoorthi http://www.cs.ucsd.edu/~ravir Motivation: Monte Carlo Rendering Key application area for sampling/reconstruction Modern methods for denoising now popular -3 order of magnitude speedups in mature area Denoising now standard in production rendering This week: Basic background in rendering Reflection and Rendering Equations Monte Carlo Integration Path Tracing (Basic Monte Carlo rendering method) A review for those who have taken CSE 68 Illumination Models Local Illumination Light directly from light sources to surface No shadows (cast shadows are a global effect) Global Illumination: multiple bounces (indirect light) Hard and soft shadows Reflections/refractions (already seen in ray tracing) Diffuse and glossy interreflections (radiosity, caustics) Caustics Caustics: Focusing through specular surface Major research effort in 8s, 9s till today Some images courtesy Henrik Wann Jensen Overview of lecture Theory for all global illumination methods (ray tracing, path tracing, radiosity) We derive Rendering Equation [Kajiya 86] Major theoretical development in field Unifying framework for all global illumination Introduced Path Tracing: core rendering method Discuss eisting approaches as special cases Outline Reflectance Equation Global Illumination Rendering Equation As a general Integral Equation and Operator Approimations (Ray Tracing, Radiosity) Surface Parameterization (Standard Form) Fairly theoretical lecture (but important). Not well covered in tetbooks (though see Eric Veach s thesis). See reading if you are interested.
Reflection Equation Reflection Equation ω i ω r ω i ω r L r (,ω r ) = L e (,ω r ) + L i (,ω i )f (,ω i,ω r )(ω i i n) Emission Incident BRDF Light (from light source) Cosine of L r (,ω r ) = L e (,ω r ) + L i (,ω i )f (,ω i,ω r )(ω i i n) Emission Incident BRDF Light (from light source) Sum over all light sources Cosine of dω i Reflection Equation ω i ω r L (, ω ) L (, ω ) L(, ω ) f(, ω, ω )cosθdω = + Replace sum with integral r r e r i i i r i i Emission Incident BRDF Cosine of Light (from light source) Environment Maps Light as a function of direction, from entire environment Captured by photographing a chrome steel or mirror sphere Accurate only for one point, but distant lighting same at other scene locations (typically use only one env. map) Blinn and Newell 976, Miller and Hoffman, 984 Later, Greene 86, Cabral et al. 87 The Challenge L (, ω ) L (, ω ) L(, ω ) f(, ω, ω )cosθdω = + r r e r i i i r i i Computing reflectance equation requires knowing the incoming radiance from surfaces But determining incoming radiance requires knowing the reflected radiance from surfaces Rendering Equation Surfaces (interreflection) da dω i ω i ω r L r (,ω r ) = L e (,ω r ) + L (, ω r i i r i i Emission Reflected Light BRDF Cosine of UNKNOWN KNOWN UNKNOWN KNOWN KNOWN
Outline Rendering Equation (Kajiya 86) Reflectance Equation (review) Global Illumination Rendering Equation As a general Integral Equation and Operator Approimations (Ray Tracing, Radiosity) Surface Parameterization (Standard Form) Rendering Equation as Integral Equation L r (,ω r ) = L e (,ω r ) + L (, ω r i i r i i Emission Reflected Light BRDF Cosine of UNKNOWN l(u) = e(u) + KNOWN UNKNOWN KNOWN KNOWN Is a Fredholm Integral Equation of second kind [etensively studied numerically] with canonical form l(v) K(u,v)dv Kernel of equation Linear Operator Theory Linear operators act on functions like matrices act on vectors or discrete representations ( ) hu ( ) = Mo f ( u) M is a linear operator. f and h are functions of u a and b are scalars Basic linearity relations hold f and g are functions M o( af + bg) = a( M of ) + b( M og) Eamples include integration and differentiation ( K o f )() u = k(,) u v f () v dv f ( Do f )( u) = ( u) u Linear Operator Equation lu () = eu () + lv () Ku (,) v dv Kernel of equation Light Transport Operator L = E + KL Can be discretized to a simple matri equation [or system of simultaneous linear equations] (L, E are vectors, K is the light transport matri) Solving the Rendering Equation Too hard for analytic solution, numerical methods Approimations, that compute different terms, accuracies of the rendering equation Two basic approaches are ray tracing, radiosity. More formally, Monte Carlo and Finite Element. Today Monte Carlo path tracing is core rendering method Monte Carlo techniques sample light paths, form statistical estimate (eample, path tracing) Finite Element methods discretize to matri equation 3
Solving the Rendering Equation General linear operator solution. Within raytracing: General class numerical Monte Carlo methods Approimate set of all paths of light in scene L = E + KL IL KL = E (I K)L = E L = (I K) E Binomial Theorem L = (I + K + K + K 3 +...)E L = E + KE + K E + K 3 E +... Term n corresponds to n bounces of light Ray Tracing L = E + KE + K E + K 3 E +... Emission directly From light sources Direct Illumination on surfaces Global Illumination (One bounce indirect) [Mirrors, Refraction] (Two bounce indirect) [Caustics etc] Ray Tracing L = E + KE + K E + K 3 E +... Emission directly From light sources Direct Illumination on surfaces OpenGL Shading Global Illumination (One bounce indirect) [Mirrors, Refraction] (Two bounce indirect) [Caustics etc] Outline Reflectance Equation (review) Global Illumination Rendering Equation As a general Integral Equation and Operator Approimations (Ray Tracing, Radiosity) Surface Parameterization (Standard Form) Rendering Equation Surfaces (interreflection) da ωi ω r ω i : L (, ω ) = L (, ω ) + L (, ω ) f(, ω, ω )cosθ dω r dω i UNKNOWN r e r r i i r i Emission Reflected BRDF Light Cosine of KNOWN UNKNOWN KNOWN KNOWN i 4
Change of Variables Lr(, r) = Le(, r) + Lr(, i) f(, i, r)cosθid i Integral over angles sometimes insufficient. Write integral in terms of surface radiance only (change of variables) ω ω ω ω ω ω Change of Variables Lr(, r) = Le(, r) + Lr(, i) f(, i, r)cosθid i Integral over angles sometimes insufficient. Write integral in terms of surface radiance only (change of variables) ω ω ω ω ω ω cosθi cosθo Lr(, ωr) = Le(, ωr) + Lr(, ωi) f(, ωi, ωr) all visible to θ o θ i ω i ω i dω i cosθo dωi = cosθo dωi = cosθicosθo G (, ) = G (, ) = Rendering Equation: Standard Form Lr(, ωr) = Le(, ωr) + Lr(, ωi) f(, ωi, ωr)cosθidωi Integral over angles sometimes insufficient. Write integral in terms of surface radiance only (change of variables) cosθi cosθo Lr(, ωr) = Le(, ωr) + Lr(, ωi) f(, ωi, ωr) all visible to Domain integral awkward. Introduce binary visibility fn V L (, ω) = L (, ω) + L (, ω) f(, ωω, ) G( V, ) (, ) r r e r r all surfaces i i r Same as equation.5 Cohen Wallace. It swaps primed And unprimed, omits angular args of BRDF, - sign. Same as equation above 9.3 in Shirley, ecept he has no emission, slightly diff. notation cosθo dωi = cosθicosθo G (, ) = G (, ) = Summary Theory for all global illumination methods (ray tracing, path tracing, radiosity) We derive Rendering Equation [Kajiya 86] Major theoretical development in field Unifying framework for all global illumination Discuss eisting approaches as special cases Motivation: Monte Carlo Integration Eample: Soft Shadows Rendering = integration Reflectance equation: Integrate over incident illumination Rendering equation: Integral equation Many sophisticated shading effects involve integrals Antialiasing Soft shadows Indirect illumination Caustics Most Sampling/Reconstruction treats actual rendering as a black bo. But still helpful to know some basics 5
Monte Carlo Algorithms based on statistical sampling and random numbers Coined in the beginning of 94s. Originally used for neutron transport, nuclear simulations Von Neumann, Ulam, Metropolis, Canonical eample: D integral done numerically Choose a set of random points to evaluate function, and then average (epectation or statistical average) Monte Carlo Algorithms Advantages Robust for comple integrals in computer graphics (irregular domains, shadow discontinuities and so on) Efficient for high dimensional integrals (common in graphics: time, light source directions, and so on) Quite simple to implement Work for general scenes, surfaces Easy to reason about (but care taken re statistical bias) Disadvantages Noisy Slow (many samples needed for convergence) Not used if alternative analytic approaches eist (but those are rare) Integration in D We can approimate f ()d =? f ()d g()d f() f() g() Standard integration methods like trapezoidal rule and Simpsons rule Advantages: Converges fast for smooth integrands Deterministic = = Disadvantages: Eponential compleity in many dimensions Not rapid convergence for discontinuities Slide courtesy of Peter Shirley Slide courtesy of Peter Shirley Or we can average f ()d = E(f ()) Estimating the average f ()d = N f ( ) i N i= f() = E(f()) f() N Monte Carlo methods (random choose samples) E(f()) Advantages: Robust for discontinuities Converges reasonably for large dimensions Can handle comple geometry, integrals Relatively simple to implement, reason about Slide courtesy of Peter Shirley Slide courtesy of Peter Shirley 6
f() Other Domains b a f ()d < f > ab = b a N N i= f ( i ) Multidimensional Domains Same ideas apply for integration over Piel areas Surfaces Projected areas Directions f ()d = N Eye N f ( ) i UGLY i= Camera apertures Time Paths Piel =a =b Slide courtesy of Peter Shirley Surface Random Variables Epected Value Describes possible outcomes of an eperiment In discrete case, e.g. value of a dice roll [ = -6] Probability p associated with each (/6 for dice) Continuous case is obvious etension Epectation For Dice eample: Discrete: E() = p i i n i= Continuous: E() = p()f () d n E() = 6 i = 6 + + 3 + 4 + 5 + 6 i= ( ) = 3.5 Sampling Techniques Problem: how do we generate random points/ directions during path tracing? Non-rectilinear domains Importance (BRDF) Stratified Eye Surface 7
Generating Random Points Uniform distribution: Use random number generator Generating Random Points Specific probability distribution: Function inversion Rejection Metropolis Probability Probability W W Common Operations Want to sample probability distributions Draw samples distributed according to probability Useful for integration, picking important regions, etc. Common distributions Disk or circle Uniform Upper hemisphere for visibility Area luminaire Comple lighting like an environment map Comple reflectance like a BRDF Generating Random Points Cumulative Probability W 8
Rejection Sampling Probability W More formally 9
Importance Sampling Put more samples where f() is bigger E(f()) f ()d = N Y i Y i = f ( i ) p( i ) N i= N Importance Sampling Importance Sampling This is still unbiased E(f()) N E Y i = Y()p()d = f () p() p()d = f ()d for all N Zero variance if p() ~ f() E(f()) N p() = cf () Y i = f ( i ) p( i ) = c Var(Y) = Less variance with better importance sampling
Stratified Sampling Estimate subdomains separately E k (f()) Arvo Stratified Sampling Less overall variance if less variance in subdomains E k (f()) Var F N = M N k= N i Var F i N N More Information Veach PhD thesis chapter (linked to from website) Course Notes (links from website) Mathematical Models for Computer Graphics, Stanford, Fall 997 State of the Art in Monte Carlo Methods for Realistic Image Synthesis, Course 9, SIGGRAPH