Upload
gavin-carson
View
225
Download
3
Tags:
Embed Size (px)
Citation preview
© Machiraju/Möller
Rendering EquationUnbiased MC Methods
CMPT 461/770Advanced Computer Graphics
Torsten Möller
© Machiraju/Möller
Reading
• Chapter 16 of “Physically Based Rendering” by Pharr&Humphreys
• Chapter 19, 20 in “Principles of Digital Image Synthesis,” by A. Glassner
© Machiraju/Möller
Direct Light
• General equation of existant radiance:
• Account only for direct light sources, i.e. Replace Li(p,i) with Li(p,i):
– Most simple form of equation
– Somewhat easy to solve! (but a gross simplification)
– Kinda what we do in Whitted Ray-tracing
– Not too bad - most energy comes from direct lights
Lo p,o Le p,o f r p,o, i Li p, i cosi d iS 2
Lo p,o Le p,o f r p,o, i Ld p, i cosi d iS 2
© Machiraju/Möller
Direct Light
• MC sampling to solve integral
• (A)
– pick one light as representative for all lights– Distribute N samples for this light
– Use multiple importance sampling for fr and Ld
– Scale the result by the total number of lights NL
f r p,o, i Ld p, i cosi d iS 2
1
N
fr p,o, j Ld p, j cosi
p j j1
N
© Machiraju/Möller
Multiple Importance Sampling
o
Weight according to f
light
o
Weight according to Ld
light
1
N
fr p,o, j Ld p, j cosi
p j j1
N
© Machiraju/Möller
Direct Light
• (B) uniformly sample all lights
– Do (A) for each light source
– Sum the result
– Smarter approach - non-uniform sampling of light sources: prefer lights with has higher power
f r p,o, i Ld j p, i cosi d iS 2ji
NL
© Machiraju/Möller
Light Transport Equation
• Incident radiance effected by all geometry and scattering within a scene (colour bleeding)
• Global illumination
• Principle– Ignore wave optics– Energy balance (radiance is in equilibrium)
o i e aPowerleaving
Powerentering
Poweremitted
Powerabsorbed
© Machiraju/Möller
Light Transport Equation
• If no participating media - express incoming in terms of outgoing radiance:
• Need to solve for L (only one unknown)
o i e a
o e i a Lo p,o Le p,o f r p,o, i Li p, i cosi d iS 2
Li p, Lo t p, ,
L p,o Le p,o f r p,o, i L t p, i , i cosi d iS 2
Lo p ,
Li p,
© Machiraju/Möller
Example - lambertian light
• One spherical light source on the outside
• No scene geometry
• Lambertian BSDF, fr=c
• Emitted radiance Le in constant
• is the same, no matter which point on the light. Hence:
L p,o Le c L t p, i , i cosi d iH 2
L L t p, i , i cosi d iH 2
L p,o Le cL
© Machiraju/Möller
Example cont.
• Let’s solve the lastequation a little weirdly:
• These are basically the number of bounces
• hh is the reflectance
• von Neumann series - principle solution method
L p,o Le cL
Le c Le cL Le c Le c Le c ... Le c i
i0
L p,o Le
1 c
Le
1 hh
© Machiraju/Möller
Example - direct lighting
• Using recursion for direct lighting:
• The last term is being ignored; represents secondary (bounced) light
L p,o Le p,o f r p,o, i Ld t p, i , i cosi d iS 2Ld t p, i , i Le t p, i , i
f r t p, i , i, Ld t t p, i , , cos d S 2
© Machiraju/Möller
• Expressing LTE in terms of geometry within the scene
• Replacing the integrand (di)with an area integrator over the whole scene geometry and remembering:
• - visibility term (either one or zero)
LTE - Geometric Formulation
o
i
p
p
p
L p , L p p f p ,o, i f p p p
d i cos p p
2
V p p
© Machiraju/Möller
• Geometry coupling term
• New (geometric) formulationof the Light Transport Equation (LTE)
• Randomly pick points in the scene and create a path vs. (previously)
• randomly pick directions over a sphere
G p p V p p cos cos p p
2
L p p Le p p f r p p p L p p G p p dA p A
o
i
p
p
p
LTE - Geometric Formulation
© Machiraju/Möller
L p1 p0 Le p1 p0 Le p2 p1 f p2 p1 p0 G p2 p1 dA p2
A
Le p3 p2 f p3 p2 p1 G p3 p2 A
f p2 p1 p0 G p2 p1 dA p2 dA p3
...
G p2 p1
p1
p2
p0
p3
G p3 p2
f p3 p2 p1
f p2 p1 p0
LTE - Geometric Formulation
• Recursive evaluation
© Machiraju/Möller
• compact formulation:
• For a path
• Where p0 is thecamera and pi isa light source
L p1 p0 P p i i1
LTE - Geometric Formulation
p i p0 p1...pi
G p2 p1
p1
p2
p0
p3
G p3 p2
f p3 p2 p1
f p2 p1 p0
© Machiraju/Möller
• with:
• Where
• Is called the throughput
• Special case:
P p i ... Le pi pi 1 T p i dA p2 ...dA pi A
A
A
LTE - Geometric Formulation
G p2 p1
p1
p2
p0
p3
G p3 p2
f p3 p2 p1
f p2 p1 p0
T p i j1
i 1
f p j1 p j p j 1 G p j1 p j
P p 1 Le p1 p0
© Machiraju/Möller
• Again - handle with care (e.g. point light):
• E.g. Whitted raytracing only usesspecular BSDF’s
P p 2 Le p2 p1 f p2 p1 p0 G p2 p1 dA p2 A
plight p2 Le p2 p1
p plight f p2 p1 p0 G p2 p1
Le plight p1 f plight p1 p0 G plight p1
Specular distributions
G plight p1
p1
plight
p0
f plight p1 p0
© Machiraju/Möller
Solving the LTE
• Many different algorithms proposed to deal with
• Most energy in the first few bounces:
• emitted radiance at p1
• one bounce to light (direct lighting)
P p i i0
L p1 p0 P p 1 P p 2 P p i i3
P p 1
P p 2
© Machiraju/Möller
Solving the LTE
• Simplify according to small and large light sources:
• Can be handled separatly (different number of samples)
Le Le,s Le,l
P p i ... Le pi pi 1 T p i dA p2 ...dA pi A
A
A
... Le,s pi pi 1 T p i dA p2 ...dA pi A
A
A
... Le,l pi pi 1 T p i dA p2 ...dA pi A
A
A
© Machiraju/Möller
Solving the LTE
• Similarly, we can split BxDF into delta and non-delta distributions:
• This creates many factors that cannot be ignores
f f f
T p i j1
i 1
f f G p j1 p j
© Machiraju/Möller
Measuring over a pixel
• Integrating over pixel j:
• Where We is the filter function around a pixel:
I j We p film, Li p film, cos ddA p film S 2
A film
We p0 p1 Li p1 p0 G p1 p0 dA p0 dA p1 S 2
A film
We p0 p1 f j p0 t p0,camera p0 p1
© Machiraju/Möller
Integrating over a pixel
• And hence the integral:
• A - light bounces around until it hits the camera• B - a quantity from the sensor bounces around and
only makes a contribution if it hits a light
I j We p0 p1 Li p1 p0 G p1 p0 dA p0 dA p1 S 2
A film
We p0 p1 P p i G p1 p0 dA p0 dA p1 S 2
A film
i1
... We p0 p1 T p i Le pi1 pi dA p0 ...dA pi A
A
A
i1
© Machiraju/Möller
Path Tracing
• Kajiya 1986; solution to
A. How to deal with infinite sum?
B. For a particular i - how to generate one or more paths to estimate
L p1 p0 P p i i1
P p i
© Machiraju/Möller
A) Infinite Sum
• In general => the longer the path the less the impact
• Use Russian Roulette after a finite number of bounces– always compute first few terms– Stop after that with probability q
L p1 p0 P p 1 P p 2 P p 3 1
1 qP p i
i4
© Machiraju/Möller
A) Infinite Sum
• Use probability qi after each
L p1 p0 1
1 q1
P p 1 1
1 q2
P p 2 1
1 q3
P p 3 ...
p i
© Machiraju/Möller
B) Path Generation
• Pick a surface in the scene at random (I.e. uniform probability distribution):
• Pick a point on this surface at random (uniform) with probability 1/Ai
• Overall probability of picking a random surface point in the scene:
pi Ai
A jj
pA pi Ai
A jj
1
Ai
1
A jj
© Machiraju/Möller
B) Path Generation
• This is repeated for each point on the path• Last point should be sampled on a light source• If we know things about the scene (which objects
are contributing most indirect lighting to the scene) we can sample more smartly
• Problems:– High variance - only few points are mutually visible
– Incorrect integral - for delta distributions
© Machiraju/Möller
• For path– At each pj find pj+1 according to BSDF
– At pi-1 find pi by multiple importance sampling of BSDF and Ld
• This algorithm distributes samples according to solid angle () instead of area
• Hence prob. Distribution pA needs to be adjusted:
p i p0 p1...pi
B) Incremental Path Generation
pA pi ppi pi1
2
cosi
© Machiraju/Möller
• MC estimator:
• Implementation:– Re-use path for new path
• Introduces correlation, but speed makes up for it
B) Incremental Path Generation
Le pi pi 1 pA pi j1
i 1
f p j1 p j p j 1 cosi
p p j1 p j
p i 1
p i
© Machiraju/Möller
Path Tracing
© Machiraju/Möller
Path Tracing
Direct lighting only
1024 samples per pixel 8 samples per pixel
© Machiraju/Möller
Pure Path Tracing
• Best for bigluminaires.
• If lights small,few hits andlarge variance.
© Machiraju/Möller
Results
• Objects are gray,except forspheres and base.– Color bleeding– Caustics
© Machiraju/Möller
Results
401 minutes 533 minutes
256 x 256 image
Ray Traced(no ambient)
Path Traced
Light scatteredby sphere
© Machiraju/Möller
Bi-directional path tracing
• Compose one path from two paths– started at the camera p0 and
– started at the light source q0
• Modifications for efficiency:a) Use all i+j paths:
b) For all pathsreplace q1 with directlighting computationlike normal path tracing
q jq j 1...q1
p p1p2...pi,q jq j 1...q1
p1p2...pi
p
p1...pi,q j ...q1
p1...pi 1,q j ...q1
p1...pi 2,q j ...q1
M
p1,q j ...q1
p1...pi,q j ...q1
p1...pi,q j 1...q1
p1...pi,q j 1...q1
M
p1...pi,q1
p1p2...pi,q1
© Machiraju/Möller
Bi-directional path tracing
• When useful?– Light sources difficult to reach– Specific BSDF evaluations (caustics)
© Machiraju/Möller
Bi-direct RT : Pseudo-Code
© Machiraju/Möller
Pure Bi-Directional: Analysis
• Advantages:– Each ray cast contributes to many paths– Building from both ends can catch difficult cases
• All specular paths• Caustics
– Extends to participating media (anisotropic, heterogeneous)
• Disadvantages:– Still using lots of effort to catch slow varying diffuse
components– May not sample difficult to find paths– Does allow for much noise to be present
© Machiraju/Möller
Still Tough Cases
• Caustics– How do you know which
direction to cast eye rays toreach the interesting light?
• Bleeding– How do you know which
rays to reflect to reach theinteresting parts of diffusereflections?
© Machiraju/Möller
MC Algorithms Revisited
• Provide ability to sample light transport paths.
• MC algorithms studied so far sample a function to compute the value of an integral.
• Problems:– Many of the paths are unimportant.– Pure Bi-Directional Path algorithm does not
reject.– It may weigh down some paths.
© Machiraju/Möller
Metropolis’s Idea
• Circa 1953• Generate a distribution of samples proportional to
the unknown function• For rendering –
– sample image with ray density proportional to radiance
– random walk through path space
• Eric Veach’s PhD thesis and Veach&Guibas paper in Siggraph introduced work of Metropolis to Graphics
© Machiraju/Möller
Why Does It Make Sense ?
• In the final image: – More detail in brighter areas– Value of a pixel will be proportional to the
number of times it was sampled in a path
© Machiraju/Möller
Metropolis sampling
Metropolis Light Transport
• Generate a random walk through path space
• For each path deposit a constant amount of energy at the corresponding pixel
• Obtain desired image by distributing paths according to image contribution
x p0 p1...pi
© Machiraju/Möller
• Propose a mutation of current path
• Compute acceptance probability
• Choose as new sample if
• Samples are correlated
• we can exploit coherence
y x
)()(
)()(,1min),(
yxTxf
xyTyfxy
y
Metropolis Sampling
© Machiraju/Möller
• Where is the image contribution function (contribution made to the image by light flowing through )
• tentative transition function - probability of given
T(x y )y
Metropolis Sampling
f (y )
y
x
© Machiraju/Möller
Metropolis light transport
Le
Mutations
pixel
© Machiraju/Möller
MLT: Pseudo-Code
© Machiraju/Möller
Scattering Perturbations Propagation Perturbations
Sensor Perturbations Caustic Perturbations
Mutation Strategies
• Bidirectional Mutations– large changes to the current path– ensures ergodicity
• Perturbations– high acceptance probability– changes to image location– low cost
© Machiraju/Möller
Bidirectional Mutations
• Given a path
1. Choose a random subpath to delete.
2. Add random numbers of new vertices to the new interior endpoints of X.
3. Try to connect up the two innermost vertices.
4. Test for acceptance of the new path.
x p0 p1...pi
© Machiraju/Möller
x1
x2
x0
Mutations – Step 1
© Machiraju/Möller
Mutations – Step 1
• Random subpath to delete.
• Weigh probability so that smaller subpaths are chosen more frequently.
x1
x2
x0
© Machiraju/Möller
Mutations – Step 2
• Add random numbers of new vertices.• Choose number to add from a distribution
centered around old number.• Choose where to put the break (i.e. how
many to add at end of first segment vs. beginning of last segment).
• Add each vertex by sampling a direction according to a BRDF, and then casting a ray.
© Machiraju/Möller
x2
Mutations – Step 2
• Chose to add 2 vertices, with the break between them.
x0
© Machiraju/Möller
x2
x1
Mutations – Step 3
• Connect two innermost vertices
• Test if two new endpoints are visible
• If the path is obstructed, reject the mutation
x0
x3
© Machiraju/Möller
• Test for acceptance of the new path Y over old path X.
• Use
• Note that much of this can be pre-computed.
Mutations – Step 4
)()(
)()(,1min),(
yxTxf
xyTyfxy
© Machiraju/Möller
Good Mutations
• Don’t make changesthat are too small
• Don’t get stuck
© Machiraju/Möller
Perturbations
• Are needed when bidirectional mutations will nearly always be rejected.
• When there are small regions of the path space in which paths contribute much more than average.– Lenses– Caustics
• Smaller mutations keep them within high contribution region
© Machiraju/Möller
Propagation Perturbations
image plane
medium
light sourceeye
© Machiraju/Möller
Perturbations
• Move the pixel location (i.e. the path’s endpoint) by a random distance in a random direction.
• Recast rays through all the specular bounces so that it retains the same length.
• Mutation strategy depends on what is encountered• For example in the caustic LS+DE case make
small change in ray connecting the diffuse and specular surface
© Machiraju/Möller
Caveat
• Run several copies of the algorithm in parallel.– Helps to remove startup bias.– Helps to test for convergence.
• Ignore the first several path samples.– Helps to remove startup bias.
• Don’t bother with MLT for the direct lighting in an image.– Standard techniques for direct lighting usually provide
better quality at lower cost.– This way MLT can devote more effort to the indirect
lighting.
© Machiraju/Möller
© Machiraju/Möller
Results
• Light for thisexample comesonly throughcrack in doorway
© Machiraju/Möller
Results
• There are specificmutations tocapture caustics.
© Machiraju/Möller
Good For
• Portions of space where light comes through
• hole in the wall kinds – mutations will explore new paths once it finds a
path through the hole– Bi-directional
and Plain PathTracing userandom directions
© Machiraju/Möller
Not Good For
• Cornell Box scenes will not benefit
• Caustics will certainly help.
• Too many holes does not help
• Also caustics from mirror reflections
© Machiraju/Möller
Results
© Machiraju/Möller
Results
© Machiraju/Möller
Results