250 likes | 430 Views
Last Time. Raytracing and PBRT Structure Radiometric quantities. Today. Radiometric Integrals Monte Carlo integration Section 5.3 and Chapter 14 of PBR. Irradiance from Radiance (PBR Sect. 5.3). Integrate radiance over directions in the upper hemisphere:
E N D
Last Time • Raytracing and PBRT Structure • Radiometric quantities © 2005 University of Wisconsin
Today • Radiometric Integrals • Monte Carlo integration • Section 5.3 and Chapter 14 of PBR © 2005 University of Wisconsin
Irradiance from Radiance (PBR Sect. 5.3) • Integrate radiance over directions in the upper hemisphere: • cos term deals with projected solid angle. is angle between and n (the normal) • We are converting “per unit solid angle per unit projected area” into “per unit solid angle per unit area” and then integrating over solid angle to get “per unit area” • Today: solving integrals like this © 2005 University of Wisconsin
Integration Methods • Analytic: not tractable for most functions you want to integrate • (Numerical) Quadrature: • Break the domain of integration into pieces, evaluate the function once in each piece, and sum up value for all pieces, weighted by the “size” of each little area • A very poor strategy for high-dimensional integrals – we will have lots of these, even infinite dimensional • Monte Carlo integration: • Evaluate the function at random points in the domain, and sum up the answers • Error independent of dimensionality of problem © 2005 University of Wisconsin
Probability Theory Overview • The aim is to give you enough to survive, for more see a probability (not statistics) textbook • A random variable X is a value chosen by some random process • Rolling dice, nuclear decay, pseudo random number generator, … • We are interested in the properties of random variables © 2005 University of Wisconsin
Discrete Random Variables • Consider rolling a die • Possible values for random variable are Xi={1,2,3,4,5,6} • Probability of seeing some value is pi=1/6 • Sampling x according topimeans choosing a value for x such that the probability that x=Xi is pi • In rendering, the most common discrete case is choosing a light, Li{L1,…,Ln}, according to the power output: © 2005 University of Wisconsin
Discrete Sampling (1) • Always assume we can sample a canonical uniform random variable[0,1) • In PBRT, function: genrand_real1() • Always get same sequence, which can be annoying • We want to use this to choose a light according to pi • Choose light Li if © 2005 University of Wisconsin
Discrete Sampling (2) • Define • The cumulative distribution function, the probability that a variable chosen according to the distribution pi will be less than Li • To sample according to pi, sample then choose Li such that • Build an array of Pi values (sorted), and then search it to find the index such that above equation is true (binary search for large arrays) © 2005 University of Wisconsin
Continuous Random Variables • A random variable, X • Takes values from some domain, • Has an associated probability density function (pdf), p(x) • Methods for sampling continuous random variables according to various distributions on various domains are discussed in PBR Sect 14.3-14.5 • Again, useful to know what is available and how to use it, but not strictly necessary to understand how they work © 2005 University of Wisconsin
Expected Value • The expected value of a random variable, x, is defined as: • The expected value of a function, f(x), is defined as: • The sample mean, for samples xi is defined as: © 2005 University of Wisconsin
Variance and Standard Deviation • The variance of a random variable is defined as: • The standard deviation of a random variable is defined as the square root of its variance: • The sample variance is: © 2005 University of Wisconsin
Sampling • A process samples according to the distribution p(x) if it randomly chooses a value for x such that: • Weak Law of Large Numbers: If xi are independent samples from p(x), then in the limit of infinite samples, the sample mean is equal to the expected value: © 2005 University of Wisconsin
Monte Carlo Integration • Say we wish to integrate • Choose some pdf, p(x) • If we sample xi, i{1,…,N}, according to p(x), then: © 2005 University of Wisconsin
Simple Example • Compute • Sample xi uniform on interval [1,5), so p(x)=1/4 • Sample canonical i then xi=4i + 1 • Monte Carlo Estimate is © 2005 University of Wisconsin
Output © 2005 University of Wisconsin
Standard Deviation of the Estimate • Expected error in the estimate after N samples is measured by the standard deviation of the estimate: • Note that error goes down with • Often, p(x) is the uniform distribution over the domain • If p(x) is something else, the technique is called importance sampling and p(x) is the importance function • p must be >0 whenever f>0, and should be as close as possible to f • Same principle for high dimensional integrals © 2005 University of Wisconsin
Radiometric Integrals (PBR 5.3) • Physically-Based rendering is all about solving integral equations involving radiometric terms • The domains of integration are areas, or regions of solid angle, or even more abstract spaces • Choosing the right domain is one consideration • The challenge is finding a way to reduce variance, which manifests itself as noise in images • More on this later, after we have some more background © 2005 University of Wisconsin
Computing Irradiance • This integral is expressed in terms of solid angle within the upper hemisphere • To solve it, we need to sample directions • We can’t represent with just one number • It’s a multi-dimensional integral • How do we parameterize directions? © 2005 University of Wisconsin
In Spherical Coordinates • Note that =0 is normal vector direction • We need a basis to define • The tangent vectors • How do we convert an angle expressed in terms of solid angle, to one in terms of spherical coordinates? • Convert domain to range of , • Convert d to dd © 2005 University of Wisconsin
Solid angle to Spherical • d is projected area • Recall the definition of solid angle • What area goes with dd? © 2005 University of Wisconsin
Irradiance Integral in Spherical Coords • In general, the incoming radiance varies over the scene • It depends on what is “seen” in each direction • If incoming radiance is constant, then • Conversion functions for unit vectors =(x,y,z) to spherical coordinates are available in PBRT © 2005 University of Wisconsin
Solid Angle to Area • Solid angle is defined in terms of area projected onto the unit sphere © 2005 University of Wisconsin
Irradiance Arriving From Surface • We want to integrate the irradiance due to an area light source • Note there are two now • Convert integral over area into integral over (s,t) (parameters for surface) © 2005 University of Wisconsin
Next Time • Cameras and Film Plane Sampling © 2005 University of Wisconsin