3.1.4 Monte Carlo Path Tracing
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 35 Monte-Carlo path tracing
• Trace one secondary ray per recursion •Send manyprimaryrays
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 36 Monte-Carlo path tracing
• To shade visible object, – trace random ray to sample incoming light (not just light ray!) –useBRDF forshading
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 37 Monte-Carlo path tracing
•Result:
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 38 Monte-Carlo path tracing
• 10 paths/pixel
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 39 Monte-Carlo path tracing
• 10 paths/pixel
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 40 Monte-Carlo path tracing
• 100 paths/pixel
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 41 Monte-Carlo path tracing
• Why random scene? • Fixed random sequence produces structures in the error
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 42 3.1.5 Monte Carlo Integration
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 43 Monte-Carlo integration
• The sampling for both Monte-Carlo distribution ray tracing and Monte-Carlo path tracing is based on Monte-Carlo integration.
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 44 Monte-Carlo computation of π
• Take a unit square • Take a random point (x,y) in the square • Test whether (x,y) lies in the quarter disc x2+y2<1 • The probability is π/4
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 45 Monte-Carlo computation of π
• Iterate the process • π = 4 * (# inside trials) / (# total trials) • Error depends on the number of trials
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 46 Monte-Carlo computation of π
• Link to ray tracing: – occluder is a sphere – somepixelshaveexactlyπ/4 visibility
1 shadow ray
many shadow rays
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 47 Simplest Monte-Carlo integration
• Compute 0.5 by flipping a coin •1 flip: –0 or1 – average error = 0.5 •2 flips – 0, 0.5, 0.5, 1 – average error = 0.25 •4 flips – 1*0, 4*0.25, 6*0.5, 4*0.75, 1*1 – average error = 0.1875 • does not converge very fast
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 48 Simplest Monte-Carlo integration
•Variancedecreasesin 1/n
•Convergenceis
• Convergence is independent of dimension!
• Good choice to integrate high-dimensional functions
• Can integrate over any domain
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 49 Monte-Carlo integration •To evaluate
use uniform random variable xi
• better: use random variable xi with probability pi
• The trick is to choose good xi and pi
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 50 Sampling strategies
• Naive vs. optimal sampling
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 51 Sampling strategies
• Sampling directions vs. sampling light sources
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 52 Sampling strategies
• Sampling more the light vs. sampling more the BRDF
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 53 What can we integrate?
• Pixel: anti-aliasing • Light sources: soft shadows • Hemisphere: indirect lighting • BRDF: glossy reflection •Lens: depthof field •Time: motionblur
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 54 Ambient occlusion
• Illumination by an extremely large area light source • Outdoor light • Low and high ambient occlusion:
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 55 Ambient occlusion
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 56 Diffuse reflections
• Indirect diffuse light • Cast rays in all directions of hemisphere with a cosine weight that gives more weight towards the pole
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 57 Diffuse reflections
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 58 Glossy reflection • Shoot rays in direction within range of glossy reflection distribution.
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 59 Glossy reflection
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 60 Depth of field
• Real cameras have a finite aperture opening • This can be simulated by using slightly varying origin for the rays and using the following directions:
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 61 Depth of field
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 62 Motion blur
• In real cameras the shutter has to open a finite amount of time to capture enough light on the film or CCD chip. • If the object is moving when the shutter is open, it will appear blurred. • Shoot rays at different times during shutter opening. • For ray-object intersection, take the object at the respective point in time.
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 63 Motion blur
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 64 3.1.6 Radiance and Radiosity
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 65 The rendering equation
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 66 The rendering equation
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 67 The rendering equation
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 68 The rendering equation
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 69 The rendering equation
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 70 The rendering equation
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 71 The rendering equation
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 72 Computation of radiosity
•LetBi be the radiosity of surface patch i and Ei the amount of emitted light energy from surface patch i.
• The emitted light energy Ei is non-zero, iff. surface patch i belongs to a light source.
• Finally, let ρi be the (constant) diffuse reflection coefficient for surface patch i. •
outgoing light emitted light incoming light reflected light
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 73 Form factors
where
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 74 Solving radiosity equation
• The equations for radiosity for all patches lead to a system of n linear equations with n unknown:
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 75 Radiosity vs. Monte-Carlo ray tracing
• project onto finite • use probabilistic basis of functions sampling • linear system •view-independent •view-dependent • ideal diffuse surfaces •BRDFs
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 76 3.1.7 Irradiance Caching
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 77 Monte-Carlo ray tracing
• Computational bottleneck: –Weneedtonsof raysper pixel. •Question: –Canweusespatialcoherence?
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 78 Direct illumination
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 79 Radiance
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 80 Irradiance
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 81 Irradiance
• Observation: irradiance (= incident light) is smooth, i.e. changes slowly
• Idea: interpolation is possible
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 82 Irradiance sampling
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 83 Irradiance change
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 84 Irradiance interpolation
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 85 Irradiance caching
When computing the irradiance at a certain point x: • Search for all cached irradiance samples with w(x) > threshold. • If samples are found, interpolate irradiance E(x). • Otherwise, compute new irradiance sample at x and cache the result.
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 86 Irradiance caching • 1000 samples, threshold = 10:
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 87 Irradiance caching • 1000 samples, threshold = 20:
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 88 Irradiance caching • 5000 samples, threshold = 10:
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 89 Ray tracing with irradiance caching
• Perform irradiance caching • Compute direct illumination as before. • For indirect illumination: – Use interpolation of cached irradiances (over position and angle) to computeirradianceat thevisiblepoint. • Combine direct and indirect illumination
Jacobs University Visualization and Computer Graphics Lab
320491: Advanced Graphics - Chapter 3 90