Random-walk solution of the global illumination problem László Szirmay-Kalos.

Slides:



Advertisements
Similar presentations
Computer graphics & visualization Global Illumination Effects.
Advertisements

Ch 11. Sampling Models Pattern Recognition and Machine Learning, C. M. Bishop, Summarized by I.-H. Lee Biointelligence Laboratory, Seoul National.
Photorealistic Rendering. Ray tracing v. photorealistic rendering What illumination effects are not captured by ray tracing? What illumination effects.
Path Differentials for MC Rendering Frank Suykens Department of Computer Science K.U.Leuven, Belgium Dagstuhl 2001: Stochastic methods in Rendering.
黃聰賢.  Render Equation  BRDF  Importance Sampling  Implementation.
Advanced Computer Graphics (Spring 2005) COMS 4162, Lectures 18, 19: Monte Carlo Integration Ravi Ramamoorthi Acknowledgements.
CSCE 641: Photon Mapping Jinxiang Chai. Outline Rendering equation Photon mapping.
Photon Tracing with Arbitrary Materials Patrick Yau.
Advanced Computer Graphics (Fall 2009) CS 294, Rendering Lecture 5: Monte Carlo Path Tracing Ravi Ramamoorthi
Machine Learning CUNY Graduate Center Lecture 7b: Sampling.
Final Gathering on GPU Toshiya Hachisuka University of Tokyo Introduction Producing global illumination image without any noise.
Everything on Global Illumination Xavier Granier - IMAGER/UBC.
Advanced Computer Graphics (Spring 2006) COMS 4162, Lecture 20: Monte Carlo Path Tracing Ravi Ramamoorthi Acknowledgements.
1 Monte Carlo Global Illumination Brandon Lloyd COMP 238 December 16, 2002.
Paper by Alexander Keller
Monte Carlo Integration I Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.
Monte Carlo Methods in Partial Differential Equations.
Monte Carlo Integration Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.
Topics in Algorithms 2007 Ramesh Hariharan. Random Projections.
Global Illumination. Direct Illumination vs. Global Illumination reflected, scattered and focused light (not discreet). physical-based light transport.
© Machiraju/Möller Rendering Equation Unbiased MC Methods CMPT 461/770 Advanced Computer Graphics Torsten Möller.
Presentation by Dr. David Cline Oklahoma State University
02/11/05© 2005 University of Wisconsin Last Time Direct Lighting Light Transport Equation (LTE) Intro.
01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities.
Selected Topics in Global Illumination Computation Jaroslav Křivánek Charles University, Prague
02/25/05© 2005 University of Wisconsin Last Time Meshing Volume Scattering Radiometry (Adsorption and Emission)
-Global Illumination Techniques
Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.
The Fundamentals of Ray-Tracing Szirmay-Kalos László Dept. of Control Engineering and Information Technology Budapest University of Technology
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
7821 Monte Carlo Techniques Basic Concepts Chapter (13)14, 15 of “Physically Based Rendering” by Pharr&Humphreys.
02/10/03© 2003 University of Wisconsin Last Time Participating Media Assignment 2 –A solution program now exists, so you can preview what your solution.
Computer graphics & visualization Photon Mapping.
Computer Graphics Global Illumination: Photon Mapping, Participating Media Lecture 12 Taku Komura.
Monte Carlo Methods So far we have discussed Monte Carlo methods based on a uniform distribution of random numbers on the interval [0,1] p(x) = 1 0  x.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Hybrid Algorithms K. H. Ko School of Mechatronics Gwangju Institute.
Rendering Problem László Szirmay-Kalos. Image synthesis: illusion of watching real world objects Le(x,)Le(x,) pixel f r (  ’, x,  ) S We(x,)We(x,)
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Stochastic Path Tracing Algorithms K. H. Ko School of Mechatronics Gwangju.
111/17/ :21 Graphics II Global Rendering and Radiosity Session 9.
Announcements Office hours today 2:30-3:30 Graded midterms will be returned at the end of the class.
Iteration Solution of the Global Illumination Problem László Szirmay-Kalos.
Instant Radiosity Alexander Keller University Kaiserslautern Present by Li-Fong Lin.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Surface Rendering Methods 고려대학교 컴퓨터 그래픽스 연구실.
BRDF models and their use in Global Illumination Algorithms László Szirmay-Kalos.
Monte-Carlo Ray Tracing and
02/12/03© 2003 University of Wisconsin Last Time Intro to Monte-Carlo methods Probability.
Computer Graphics III – Monte Carlo integration Direct illumination
Numerical quadrature for high-dimensional integrals László Szirmay-Kalos.
© Machiraju/Möller Rendering Equation Various Solutions cis782 Advanced Computer Graphics Raghu Machiraju.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Stochastic Path Tracing Algorithms K. H. Ko School of Mechatronics Gwangju.
Slide 1Lastra, 2/14/2016 Monte-Carlo Methods. Slide 2Lastra, 2/14/2016 Topics Kajiya’s paper –Showed that existing rendering methods are approximations.
Monte Carlo Techniques Basic Concepts
Fast Global Illumination Including Specular Effects Xavier Granier 1 George Drettakis 1 Bruce J. Walter 2 1 iMAGIS -GRAVIR/IMAG-INRIA iMAGIS is a joint.
Global Illumination (3) Photon Mapping (1). Overview Light Transport Notation Path Tracing Photon Mapping –Photon Tracing –The Photon Map.
01/26/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities.
Global Illumination (2) Radiosity (3). Classic Radiosity Algorithm Mesh Surfaces into Elements Compute Form Factors Between Elements Solve Linear System.
Global Illumination (3) Path Tracing. Overview Light Transport Notation Path Tracing Photon Mapping.
CS552: Computer Graphics Lecture 33: Illumination and Shading.
Computer graphics III – Multiple Importance Sampling Jaroslav Křivánek, MFF UK
Computer graphics III – Monte Carlo integration II Jaroslav Křivánek, MFF UK
Monte Carlo Integration Digital Image Synthesis Yung-Yu Chuang 12/3/2008 with slides by Pat Hanrahan and Torsten Moller.
Computer graphics III – Rendering equation and its solution
Monte Carlo Integration
Sampling and Reconstruction of Visual Appearance
Sampling and Reconstruction of Visual Appearance
Path Tracing (some material from University of Wisconsin)
Monte Carlo Rendering Central theme is sampling:
OPTICS III, IV: Global Illumination
Metropolis Light Transit
Monte Carlo Integration
Presentation transcript:

Random-walk solution of the global illumination problem László Szirmay-Kalos

Expansion solution of the global illuminaton problem ’’ L(x,  ) x   LeLe R(    2 ) =1/S p f r (  ,x,  )cos  ’  f r (  ,y,   )cos  ’ 2 ’2’2  y M (  n L e )   R(    n )L e (    n ) d    d  n

Expansion  =  n   R(    n, x)L e (    n, x) d    d  n dx  1/M  i M S(   (i)  n (i), x (i) ) R(    n,x) = w 1 w 2 …w n w i = f r cos  ’     L e pixel

Why Monte-Carlo expansion? l Avoid the exponential core: –Monte-Carlo or quasi-Monte Carlo integration –Intuitive: R(    n,x)· L e (    n,x) integrand= probability · emission l Integrand is –L 2 : MC finite variance –Not of finite variation, but finite length of discontinuities: QMC

Importance Sampling:  =  M  n L e = =  n  R(    n )L e (    n ) d    d  n dp R(    n, p) = 1/S p w 1 w 2 …w n, w i =f r cos  ’  = M (L e +   L e +   L e + … ) )) = = M (L e +  w 1  L e +  w 2  L e +  L e … ) d   ) d   )

Iterative importance sampling Pr(  i )  w i  L e +  … ) – reflection prob x (direct lighting + indirect lighting) BRDF sampling: Pr(  i )  w i Direct lighting: Pr(  i )  L e Global imp. sampling: Pr(  i )  w i  L in estimate) Adaptive imp. sampling: find a process that converges to Pr(  i )  w i  L e +  … )

BRDF sampling: Pr(  in |  out )  w =f r (  in,  out )cos  ’ l Transformation of random variables: –1. use spherical coordinates: w(  in |  out )d  =w( ,  ’)sin  ’d  d  ’ –2. normalization: p( ,  ’) d  d  ’ = w d  /  f r (  in,  out )cos  ’d  scale: a (  out ) =  f r (  in,  out )cos  ’d  –3. decomposition: p( ,  ’) = p  (  ) p  ’ (  ’) –4. probability distributions: P  ’ (  ’)=   ’ p  ’ (  ) d , P  (  )=   p  (  ) d  –5. Generation of uniform random variables r 1, r 2. –6. Find ,  ’ sample by transforming r 1, r 2 by the inverse probability distributions l  ’= P  ’ -1 ( r 1 ),  = P  -1 ( r 2 )

Diffuse BRDF sampling Diffuse BRDF sampling 1. use spherical coordinates: w(  in |  out )d  = k d cos  ’sin  ’d  d  ’ 2. normalization: albedo= k d   p( ,  ’) = cos  ’sin  ’/  3. decomposition: p( ,  ’) = 1/2  · 2 cos  ’sin  ’= 1/2  · sin 2  ’ 4. probability distributions: P  (  )=  /2 , P  ’ (  ’)= sin 2  ’ 5. Generation of uniform random variables r 1, r Find ,  ’ samples  = 2  r 2,  ’= arcsin  r 1

Diffuse BRDF class class Diffuse { Color Kd; public: SColor BRDF(Vec& L, Vec& N, Vec& V) { return Kd; } double NextDir(Vec& L, Vec& N, Vec& V) { double theta = asin(sqrt( rand() )); double phi = M_PI * 2.0 * rand(); Vec O = N % Vec(0.0, 0.0, 1.0), P = N % O; // cheat !!! L = N*cos(theta)+O*sin(theta)*cos(phi)+P*sin(theta)*sin(phi); return (cos(theta)/M_PI); } };

Diffuse BRDF sampling: geometric approach Diffuse BRDF sampling: geometric approach 1. Generate a uniformly distributed point in a square 2. Reject and generate new if not in the base circle do { x = r 1, y = r 2 } while (x 2 + y 2 > 1) 3. Map to the sphere to find the direction z =  1 - x 2 - y 2 dAdA  dA/cos  rejected samples dd d  cos 

Specular BRDF sampling 1.use spherical coordinates: w(  in |  out ) d  = k s cos n  cos  ’ sin  d  d  2. compromise: p( ,  ’)  k s cos n  sin  3. normalization:  k s cos n  sin  d  d  2  k s /(n+1) p( ,  ) = (n+1)/2  cos n  sin  3. decomposition: p( ,  ) = 1/2  · (n+1) cos n  sin  4. probability distributions: P  (  )=  /2 , P  (  )= 1- cos n+1  5. Generation of uniform random variables r 1, r Find ,  ’ samples:  = 2  r 2,  = arccos r 1 1/(n+1) 7. Radiance is 0 if  ’( ,  degrees

Specular BRDF class class Phong { Color Ks; double shine; public: double NextDir(Vec& L, Vec& N, Vec& V) { u = rnd(), v = rnd(); double cos_V_R = pow(u, 1.0/(shine+1) ); double sin_V_R = sqrt(1.0-cos_V_R*cos_V_R ); Vec O = V % Vec(0.0, 0.0, 1.0), P = O % V; Vec R = O*sin_V_R*cos(2.0*M_PI*v) + P*sin_V_R * sin(2.0*M_PI*v) +V*cos_V_R; L = N * (N * R) * R; if (N * L < 0) return 0; return (shine+1)/2/M_PI * pow(cos_V_R, shine); } };

Ideal reflection sampling w(  in |  out ) is non-zero just for the reflection direction l Select the reflection direction with probability 1.

Infinite dimensional integrals: Russian roulette 1. MC integral of a bounce:  w i  L e +...) d  i = E[w i  L e +...) /p(  i )] = E[ L refl ] 2. Compute the reflected radiance with probability s, otherwise assume that it is 0 3. Compensate the error by dividing the radiance by s Expected value is still correct: E[ L refl* ] = s E[ L refl /s ] + (1-s) 0 = E[ L refl ] Variance is increased D 2 [ L refl* ] = s E[ (L refl /s) 2 ] + (1-s) 0 - E 2 [ L refl ]= (1/s - 1) E[(L refl ) 2 ] + D 2 [ L refl ]

Selection of the termination probability: albedo  BRDF  importance sampling:  w i  L e +...) d  i = E[w i (  i,  i-1 )/p(  i )  L e +...) ] = E[a(  i-1 )  L e +...) ] 2. Continuation with the probability of the albedo: if rnd() < a(  i-1 ) return  L e +... else return 0

Russian roulette with QMC Using less number of samples if the integrand is smaller:  w L in d  ’ Adding an indicator (0/Const) function C(  ’, r): w =  C(  ’, r) dr l Substitution : –  w L in d  ’ =  r   ’  C(  ’, r) L in d  ’ dr

Combined BRDF sampling 1.BRDF is a sum of elementary BRDFs: f r = f 1 + f 2 + … + f n, w = w 1 + w 2 + … + w n 2.  w  L in d  =  w 1  L in d   w n  L in d  3. Evaluate this sum randomly: probability of terms: s1, s2, … sn, probability of no term: (1- s1- s2 - …- sn) if term i is selected it is divided by si Expected value: s1  w 1  L in d  s sn  w n  L in d  sn +(1-..)0=  w  L in d 

Low variance estimator l si is the albedo of the BRDF –1. Select reflection model: l probabilities: a1, a2, … an, l stop with (1-a1-a2-…an) –2. Generate the direction using the reflection model –3. L refl  L in from the selected direction or 0 if stopped  w  L in d  w1  L in d   wn  L in d   w1/p1  L in ]+...+  wn/pn  L in ]   a1  L in ]+...+  an  L in ]

Combined BRDF class class CombMat : Diffuse, Phong, Reflector, Refractor { enum {NO, DIFF, PHONG, REFLECT, REFRACT} selected; public: double SelectModel(Vec& L, Vec& N, Vec& V); double NextDir(Vec& L, Vec& N, Vec& V, BOOL out); Color BRDF(Vec& L, Vec& N, Vec& V); };

SelectModel double CombMat:: SelectModel(Vec& L, Vec& N, Vec& V) { double akd =Diffuse::Albedo(N,V), aks =Phong::Albedo(N,V), akr = Reflector::Albedo(N,V), akt = Refractor::Albedo(N,V); double r = rnd(); if ((r -= akd) < 0) { selected = DIFF; return akd; } if ((r -= aks) < 0) { selected = PHONG; return aks; } if ((r -= akr) < 0) { selected = REFLECT; return akr; } if ((r -= akt) < 0) { selected = REFRACT; return akt; } selected = NO; return 0.0; // Russian roulette }

CombMat::Reflect double CombMat::NextDir(Vec& L, Vec& N, Vec& V, BOOL out) { switch (selected) { case DIFFUSE: return Diffuse :: NextDir(L, N, V); case PHONG: return Phong :: NextDir(L, N, V); case REFLECT: return Reflector :: NextDir(L, N, V); case REFRACT: return Refractor :: NextDir(L, N, V, out); }

CombMat::BRDF Color CombMat :: BRDF(Vec& L, Vec& N, Vec& V) { switch (selected) { case DIFF: return DiffuseMaterial :: BRDF(L, N, V); case PHONG: return SpecularMaterial :: BRDF(L, N, V); case REFLECT: return (N*L>0): kr() / (N*L): Color(0); case REFRACT: return (-N*L>0): kt() / (-N*L): Color(0); }

Requirements of BRDF models l Local illumination and ray-tracing: –Calculation of the L out radiance from L in l Random walk global illumination: –Generation of a random  ’ : –Computation of the albedo l diffuse, ideal reflection: yes l Phong, Ward, Schlick, ideal refraction: almost l Cook-Torrance, He-Torrance: no

Colored scenes Rendering or potential equation should be solved on wavelengths: 1, 2,…, m –Solving on each wavelength separately: l waste of visibility computation –Solving on all wavelength simultaneosly l scalar importance should be defined on the radiance vector Luminance: e.g.: kd eff =  kd  i  weigth( i )

Global importance sampling l Two-pass methods (estimation+random walk) l Preprocessing: photon shooting l Data structure about the radiance (4 5D-table) –5D adaptive tree –photon map –links –wavelets l On the fly importance generation from the data structure

Photon shooting + Importance generation   2 4 Photon shooting Looking the photon impact from a patch Dicretising the hemisphere ,, Dicrete pdf 2/6 4/6 ,, 2/6 1 Dicrete CDF Random variable

Adaptive importance sampling l Single pass methods l Use previous walks to guide the importance of the future walks –explicit storage of importance: VEGAS sampling: approximate high-D importance functions by the product of 1D functions –implicit: use a process that converges to the desired probability density: Metropolis

Metropolis sampling zizi ztzt f(zi)f(zi) z i+1 f(zt)f(zt) acceptance probability: f(z t ) / f(z i ) T Adaptation is guided by a Markov chain

Design of a Metropolis l “Arbitrary” mutation function T(z i  z t ) l Construct the acceptance a(z i  z t ) so that the limiting probabilities: p(z)  f(z) z1z1 z2z2 z3z3 p(z 1 ) T(z 1  z 2 ) a(z 1  z 2 ) a(z 1  z 2 ) a(z 2  z 1 ) f (z 2 ) T(z 2  z 1 ) f (z 1 ) T(z 1  z 2 ) = Detailed balance

Metropolis algorithm FOR i=1 TO M DO Using z i choose another random, tentative point z t a(z i  z t ) = (f (z t ) T(z t  z i )) /((f (z i ) T(z i  z t )) IF a(z i  z t ) > 1 THEN accept z i+1 = z t ELSE // accept with probability a(z i  z t ) Generate random number r in [0,1] IF r < a(z i  z t ) THEN z i+1 = z t ELSE z i+1 = z i ENDIF ENDFOR

Convergence of the probability density z0z0 f(z)f(z) p1p1 p2p2 pp

Definition of a Metropolis algorithm l Perturbation (mutation) strategy: –how to find a new tentative sample in the neightborhood of the actual samples. –Req: any state can be reached l Benefits: adaptive, exact importance sampling l Drawbacks: adaptation phase: start-up bias

Metropolis method for the rendering equation L e Mutations: perturbing the directions, adding and deleting steps pixel