Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
Direct Illumination &Monte Carlo Integration
CS295, Spring 2017
Shuang Zhao
Computer Science Department
University of California, Irvine
CS295, Spring 2017 Shuang Zhao 1
Announcement
• Homework 1 will be out on Thursday, Apr 13
• Check course website for additional readings
CS295, Spring 2017 Shuang Zhao 2
Last Lecture
• Radiometry• Physics of light
• BRDFs• How materials reflects light
CS295, Spring 2017 Shuang Zhao 3
Today’s Lecture
• Direct illumination
• Monte Carlo integration I
CS295, Spring 2017 Shuang Zhao 4
Direct IlluminationCS295 Realistic Image Synthesis
CS295, Spring 2017 Shuang Zhao 5
Direct and Indirect Illumination
CS295, Spring 2017 Shuang Zhao 6
[scratchpixel.com]Today’s focus
Recap: BRDF
• The Bidirectional Reflectance Distribution Function (BRDF)
CS295, Spring 2017 Shuang Zhao 7
Convention: all vectors point away from x
Reflected Radiance
CS295, Spring 2017 Shuang Zhao 8
Convention: all vectors point away from x
Exitant Incident
Incident and Exitant Radiance
• Lr(x, ωo): all reflected light leaving x (exitant)
• Li(x, ωi): all light entering x (incident)
• Other exitant quantities• Le(x, ωo): all emitted light leaving x
(nonzero for light sources)
• L(x, ωo): all light leaving x
CS295, Spring 2017 Shuang Zhao 9
Incident and Exitant Radiance
• In general:
• y is computed by tracing a ray from x in direction ω
• Recap: invariant of radiance (in vacuum)
CS295, Spring 2017 Shuang Zhao 10
Direct Illumination
CS295, Spring 2017 Shuang Zhao 11
Example: Uniform Spherical Light
CS295, Spring 2017 Shuang Zhao 12
Diffuse surface
fr(ωi↔ωo) ≡ kd/π
Spherical light source with
radius r and Le(x,ω) ≡ L0
Recall:
Example: Uniform Spherical Light
• For a spherical light source with fixed radiant power Ф0 (i.e., ):
• Further, when r goes to zero (point source):
CS295, Spring 2017 Shuang Zhao 13
Recall:
Computing Direct Illumination
• Challenges• y changes discontinuously with ωi due to occlusion
• fr can be complicated (e.g., microfacet BRDFs)
CS295, Spring 2017 Shuang Zhao 14
Object 1
Object 2
Monte Carlo Integration ICS295 Realistic Image Synthesis
CS295, Spring 2017 Shuang Zhao 15
Monte Carlo Integration
• A powerful framework for computing integrals
• Numerical
• Nondeterministic (i.e., using randomness)
• Scalable to high-dimensional problems
CS295, Spring 2017 Shuang Zhao 16
Recap: Random Variables
• (Discrete) random variable X
• Possible outcomes: x1, x2, …, xn
• with probabilities p1, p2, …, pn such that
• E.g., “fair” coin• Outcomes: x1 = “head”, x2 = “tail”
• Probabilities: p1 = p2 = ½
CS295, Spring 2017 Shuang Zhao 17
Recap: Random Variables
• (Continuous) random variable X
• Possible outcomes: [a, b]• with probability density p(x) such that
CS295, Spring 2017 Shuang Zhao 18
Recap: Expected Value & Variance
• Expected value:
• Variance:
CS295, Spring 2017 Shuang Zhao 19
Recap: Expected Value & Variance
Let X and Y be two random variables, then:
CS295, Spring 2017 Shuang Zhao 20
Today’s focus
Recap: Strong Law of Large Numbers
Let x1, x2, …, xn be n independent observations (aka. samples) of X
CS295, Spring 2017 Shuang Zhao 21
Sample mean “Actual” mean
Example: Evaluating π
• Let X be a point uniformly distributed in the square
• Probability for X inside S:π/4
• Let
• Then
CS295, Spring 2017 Shuang Zhao 22
Unit circle
S
Circle area = π
Square area = 4
Example: Evaluating π
• (Simple) solution forcomputing π:
• Generating n independent samples of Y based on ni.i.d. X samples
• Computing their mean
CS295, Spring 2017 Shuang Zhao 23
Unit circle
S
Circle area = π
Square area = 4
Example: Evaluating π
CS295, Spring 2017 Shuang Zhao 24
Unit circle
S
Circle area = π
Square area = 4
Integral
• f(x): one-dimensional function
CS295, Spring 2017 Shuang Zhao 25
Deterministic Integration
• Quadrature rules:
• Problem:• Scales poorly with high
dimensionality (more on this in the next lecture)
CS295, Spring 2017 Shuang Zhao 26
Monte Carlo Integration: Overview
• Goal: Estimating
• Idea: Constructing random variable
• Such that
• is called an unbiased estimator of
• But how?
CS295, Spring 2017 Shuang Zhao 27
Monte Carlo Integration
• Let p() be any probability density function over[a, b] and X be a random variable with density p
• Let , then:
• To estimate : strong law of large numbers
CS295, Spring 2017 Shuang Zhao 28
Monte Carlo Integration
• Goal: to estimate
• Pick a probability density function
• Generate n independent samples:
• Evaluate for j = 1, 2, …, n
• Return sample mean:
CS295, Spring 2017 Shuang Zhao 29
How to pick density function p()?
• In theory
• (Almost) anything
• In practice:
• Uniform distributions (almost) always work
• As long as the domain is bounded
• Choice of p() greatly affects the effectiveness (i.e., convergence rate) of the resulting estimator
• More in later lectures
CS295, Spring 2017 Shuang Zhao 30
Monte Carlo Integration “Hello World”
• Estimating
• Algorithm:• Draw x1, x2, …, xn from U[0, 1) independently
• Return
CS295, Spring 2017 Shuang Zhao 31
Monte Carlo Integration “Hello World”
• Estimating
CS295, Spring 2017 Shuang Zhao 32