Anti-aliasing and Monte Carlo Path Tracing. Brian Curless CSE 557 Autumn 2017

Similar documents
Anti-aliasing and Monte Carlo Path Tracing

Anti-aliasing and Monte Carlo Path Tracing. Brian Curless CSE 457 Autumn 2017

Distribution Ray Tracing

Reading. Distribution Ray Tracing. BRDF, revisited. Pixel anti-aliasing. ω in. Required: Shirley, section Further reading:

Physically Realistic Ray Tracing

Distribution Ray Tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Reading. 8. Distribution Ray Tracing. Required: Watt, sections 10.6,14.8. Further reading:

Global Illumination The Game of Light Transport. Jian Huang

Distributed Ray Tracing

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics

Distribution Ray-Tracing. Programação 3D Simulação e Jogos

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Specular reflection. Lighting II. Snell s Law. Refraction at boundary of media

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

EECS 487: Interactive Computer Graphics

Monte-Carlo Ray Tracing. Antialiasing & integration. Global illumination. Why integration? Domains of integration. What else can we integrate?

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

distribution ray tracing

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

Visual cues to 3D geometry. Light Reflection and Advanced Shading. Shading. Recognizing materials. size (perspective) occlusion shading

Sung-Eui Yoon ( 윤성의 )

distribution ray-tracing

The Rendering Equation and Path Tracing

Ray Tracing. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

Global Illumination and Monte Carlo

Monte Carlo Integration

Sampling, Aliasing, & Mipmaps

Distributed Ray Tracing

Ray Tracing. Johns Hopkins Department of Computer Science Course : Rendering Techniques, Professor: Jonathan Cohen

13 Distribution Ray Tracing

Computer Graphics Project

COMP371 COMPUTER GRAPHICS

Monte Carlo Ray Tracing. Computer Graphics CMU /15-662

Path Tracing part 2. Steve Rotenberg CSE168: Rendering Algorithms UCSD, Spring 2017

Chapter 11 Global Illumination. Part 1 Ray Tracing. Reading: Angel s Interactive Computer Graphics (6 th ed.) Sections 11.1, 11.2, 11.

Local vs. Global Illumination & Radiosity

The Traditional Graphics Pipeline

Ray Tracing. CS334 Fall Daniel G. Aliaga Department of Computer Science Purdue University

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

Today. Anti-aliasing Surface Parametrization Soft Shadows Global Illumination. Exercise 2. Path Tracing Radiosity

MULTI-DIMENSIONAL MONTE CARLO INTEGRATION

The Traditional Graphics Pipeline

GAMES Webinar: Rendering Tutorial 2. Monte Carlo Methods. Shuang Zhao

Monte Carlo Integration

Other Rendering Techniques CSE 872 Fall Intro You have seen Scanline converter (+z-buffer) Painter s algorithm Radiosity CSE 872 Fall

A Brief Overview of. Global Illumination. Thomas Larsson, Afshin Ameri Mälardalen University

Advanced Ray Tracing

Ray Tracing. CSCI 420 Computer Graphics Lecture 15. Ray Casting Shadow Rays Reflection and Transmission [Ch ]

The Traditional Graphics Pipeline

Raytracing & Epsilon. Today. Last Time? Forward Ray Tracing. Does Ray Tracing Simulate Physics? Local Illumination

Shading. Brian Curless CSE 557 Autumn 2017

Motivation. Advanced Computer Graphics (Fall 2009) CS 283, Lecture 11: Monte Carlo Integration Ravi Ramamoorthi

In the real world, light sources emit light particles, which travel in space, reflect at objects or scatter in volumetric media (potentially multiple

Lecture 7: Monte Carlo Rendering. MC Advantages

Photon Maps. The photon map stores the lighting information on points or photons in 3D space ( on /near 2D surfaces)

CS559: Computer Graphics. Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Building a Fast Ray Tracer

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

Schedule. MIT Monte-Carlo Ray Tracing. Radiosity. Review of last week? Limitations of radiosity. Radiosity

Scalable many-light methods

Motivation: Monte Carlo Path Tracing. Sampling and Reconstruction of Visual Appearance. Monte Carlo Path Tracing. Monte Carlo Path Tracing

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

CS-184: Computer Graphics. Administrative

Project 3 Path Tracing

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

Numerical Integration

Theoretically Perfect Sensor

Ray Tracing. Last Time? Reading for Today. Reading for Today

The Rendering Equation. Computer Graphics CMU /15-662, Fall 2016

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

Sampling: Antialiasing - Intro

SAMPLING AND NOISE. Increasing the number of samples per pixel gives an anti-aliased image which better represents the actual scene.

Recent Advances in Monte Carlo Offline Rendering

Virtual Reality for Human Computer Interaction

The Rendering Equation. Computer Graphics CMU /15-662

Shading. Reading. Pinhole camera. Basic 3D graphics. Brian Curless CSE 557 Fall Required: Shirley, Chapter 10

Reading. 18. Projections and Z-buffers. Required: Watt, Section , 6.3, 6.6 (esp. intro and subsections 1, 4, and 8 10), Further reading:

SDK White Paper. Soft Shadows

Computer Graphics. Si Lu. Fall uter_graphics.htm 11/22/2017

MITOCW MIT6_172_F10_lec18_300k-mp4

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

MIT Monte-Carlo Ray Tracing. MIT EECS 6.837, Cutler and Durand 1

Advanced Graphics. Path Tracing and Photon Mapping Part 2. Path Tracing and Photon Mapping

Motivation. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing

Lecture 7 - Path Tracing

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

Monte Carlo Path Tracing. The Rendering Equation

Interactive Methods in Scientific Visualization

Homework #2. Shading, Ray Tracing, and Texture Mapping

Theoretically Perfect Sensor

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Global Illumination. CSCI 420 Computer Graphics Lecture 18. BRDFs Raytracing and Radiosity Subsurface Scattering Photon Mapping [Ch

Sampling, Aliasing, & Mipmaps

Anti-aliasing. Images and Aliasing

Transcription:

Anti-aliasing and Monte Carlo Path Tracing Brian Curless CSE 557 Autumn 2017 1

Reading Required: Marschner and Shirley, Section 13.4 (online handout) Pharr, Jakob, and Humphreys, Physically Based Ray Tracing: From Theory to Implementation, Chapter 13 (online handout) Further reading: A. Glassner. An Introduction to Ray Tracing. Academic Press, 1989. [In the lab.] Robert L. Cook, Thomas Porter, Loren Carpenter. Distributed Ray Tracing. Computer Graphics (Proceedings of SIGGRAPH 84). 18 (3). pp. 137-145. 1984. James T. Kajiya. The Rendering Equation. Computer Graphics (Proceedings of SIGGRAPH 86). 20 (4). pp. 143-150. 1986. 2

Aliasing Ray tracing is a form of sampling and can suffer from annoying visual artifacts... Consider a continuous function (x). Now sample it at intervals to give [i] = quantize[(i )]. Q: How well does [i] approximate (x)? Consider sampling a sinusoid: In this case, the sinusoid is reasonably well approximated by the samples. 3

Aliasing (con t) Now consider sampling a higher frequency sinusoid We get the exact same samples, so we seem to be approximating the first lower frequency sinusoid again. We say that, after sampling, the higher frequency sinusoid has taken on a new alias, i.e., changed its identity to be a lower frequency sinusoid. 4

Aliasing and anti-aliasing in rendering One of the most common rendering artifacts is the jaggies. Consider rendering a white polygon against a black background: We would instead like to get a smoother transition: Anti-aliasing is the process of removing high frequencies before they cause aliasing. In a renderer, computing the average color within a pixel is a good way to anti-alias. How exactly do we compute the average color? 5

Antialiasing in a ray tracer We would like to compute the average intensity in the neighborhood of each pixel. When casting one ray per pixel, we are likely to have aliasing artifacts. To improve matters, we can cast more than one ray per pixel and average the result. A.k.a., super-sampling and averaging down. 6

Antialiasing by adaptive sampling Casting many rays per pixel can be unnecessarily costly. If there are no rapid changes in intensity at the pixel, maybe only a few samples are needed. Solution: adaptive sampling. Q: When do we decide to cast more rays in a particular area? 7

Gloss and translucency The mirror-like form of reflection, when used to approximate glossy surfaces, introduces a kind of aliasing, because we are under-sampling reflection (and refraction). For example: Distributing rays over reflection directions gives: 8

Soft shadows Distributing rays over light source area gives: 9

Depth of field To simulate a camera, we can model the refraction of light through a lens. This will give us a depth of field effect: objects close to the in-focus plane are sharp, and the rest is blurry. 10

Depth of field (cont d) This is really similar to the pinhole camera model: But now: Put the image plane at the depth you want to be in focus. Treat the aperture as multiple COPs (samples across the aperture). For each pixel, trace multiple viewing/primary rays for each COP and average the results. 11

Motion blur Distributing rays over time gives: How can we use super-sampling and averaging down to get motion blur? 12

Naively improving Whitted ray tracing Consider Whitted vs. a brute force approach with anti-aliasing, depth of field, area lights, gloss Whitted ray tracing Brute force, advanced ray tracing Advanced ray tracing has: m x m pixels k x k supersampling a x a sampling of camera aperture n primitives l area light sources s x s sampling of each area light source r x r rays cast recursively per intersection (gloss/translucency) d is average ray path length Asymptotic # of intersection tests = For m =1,000, k = a = s = r = 8, n = 1,000,000, l 4, d = 8 very expensive!! 13

Penumbra revisited Let s revisit the area light source We can trace a ray from the viewer through a pixel, but now when we hit a surface, we cast rays to samples on the area light source. 14

Penumbra revisited We should anti-alias to get best looking results. Whoa, this is a lot of rays just for one pixel!! 15

Penumbra revisited We can get a similar result with much less computation: Choose random location within a pixel, trace ray. At first intersection, choose random location on area light source and trace shadow ray. Continue recursion as with Whitted, but always choose random location on area light for shadow ray. 16

Monte Carlo Path Tracing vs. Brute Force We can generalize this idea to do random sampling for each viewing ray, shadow ray, reflected ray, etc. This approach is called Monte Carlo Path Tracing (MCPT). Brute force, advanced ray tracing Monte Carlo path tracing 17

MCPT vs. Whitted Q: For a fixed number of rays per pixel, does MCPT trace more total rays than Whitted? Q: Does MCPT give the same answer every time? Whitted ray tracing Monte Carlo path tracing 18

Ray tracing as integration Ray tracing amounts to estimating a multidimensional integral at each pixel. The integration is over: the pixel area the aperture each light source all diffuse/glossy reflections (recursively) Integration over diffuse/glossy reflections is at the heart of rendering. Recall that the BRDF tells us how incoming light will scatter into outgoing directions: in f r ( in, out ) To compute the total light for an outgoing direction, we integrate all incoming directions: I( out ) H I( in ) f r ( in, out ) in N d in 19

Approximating integrals Let s say we want to compute the integral of a function: F b a f (x)dx If f(x) is not known analytically (or is not easy to integrate), but can be readily evaluated, then we can approximate the integral by sampling. Our approximate integral value is then something like: F where we have sampled N times at spacing x. Evaluating an integral in this manner is called quadrature. N i1 f (ix)x Q: How many samples do we need if we have integrals over d dimensions, and we sample N times in each dimension? 20

Approximating integrals (cont d) We can also do uneven sampling: Our approximate integral value is then something like: F where we have sampled N times at variable spacing x i. We can think of the x i as weights on the samples. Q: Which x i should we pick? N i1 f (x i )x i Q: When the x i are more closely spaced, do they get larger or smaller weight? 21

A stochastic approach A good approach to distributing samples unevenly across many dimensions is to do so stochastically. Quick review first For 1D, let s say the position in x is a random variable X, which is distributed according to p(x), a probability density function (non-negative, integrates to unity). Then: = E[X] = 2 = V[X] = Suppose we don t know p(x), but we can collect N samples {X i } drawn from p(x). How would we estimate the mean from the samples? Suppose we repeated the process, drawing N samples and re-computing the mean. Will we get the exact same answer? 22

Sample mean This sample mean is itself a new random variable: where each of the X i are independent with pdf p(x). Ideally, the expected value of this random variable actually is the expected value of the original one, X. It s easy to show that: E[cX] = ce[x] 1 N i1 E[X+Y] = E[X] + E[Y] N where X and Y are independent random variables. X i The {X i } are independent and identically distributed (i.i.d.) leading to expected sample mean: E 1 N N i1 X i 23

Sample variance We noted that the sample mean does not give the same answer every time it s a random variable. How much does the answer vary? We ll compute its variance. It s easy to show that: V[cX] = c 2 V[X] V[X+Y] = V[X] + V[Y] where X and Y are independent random variables. For i.i.d. variables {X i }, we can now compute the variance of the sample mean: V 1 N N i1 X i What parameter can we control to reduce the variance? How does standard deviation change when adjusting that parameter? 24

Stochastic sampling as integration Let s return to the integral we wish to compute: F b a f (x)dx Suppose now we use a uniform pdf to sample the range [a, b]: We can then compute the mean of these samples: 1 N Note that a function of a random variable is itself a random variable. So, we have created yet another random variable, which is an average of random variables { f (X i ) }. What is its expected value? N i1 f X i 25

Stochastic sampling as integration (cont d) We can compute the expected value as: E 1 N N i1 f X i But what is the expected value of f (X) where X is drawn from a uniform pdf over [a, b]: p(x) if a x b else Then we have: E f X f (x) p(x)dx The variance of our integral estimate is: V 1 N N i1 f X i 26

Monte Carlo integration Suppose we are integrating a function that has large values in some places but not others. How do we get more samples in the large value areas? Remember before that if our samples are more closely spaced, they should receive less weight. What function tells us how close spaced samples will be? We can now estimate the integral as: This is called Monte Carlo integration. 27

Monte Carlo integration (cont d) But is this sample mean really approximating the integral? Let s compute its expected value: E 1 N N i1 f (X i ) p(x i ) Now we need the expected value of f (X)/p(X): E f X / p(x ) Bingo! We can compute the variance of our integral estimator: V 1 N N i1 f (X i ) p(x i ) We want a low variance estimate. What variables and/or functions are under our control here? 28

Importance sampling To reduce variance, we can now choose p(x) to sample f (x) well. If f (x) is non-negative, the optimal choice would be to set p(x) ~ f (x). Why don t we just do that? Alternatively, we can use heuristics to guess where f (x) will be large and choose p(x) based on those heuristics. This approach is called importance sampling. 29

Stratified sampling Another source of variance is bad luck. Consider a uniform sampling of our function, where samples may clump: To reduce this problem, we can apply stratified sampling. The idea is that, given your probability function: You can break it up into bins of equal probability area (i.e., equal likelihood). Then choose a sample from each bin. 30

Importance sampling of reflection For a given BRDF: out f r ( in, out ) again the surface reflection equation is: I( out ) Without importance sampling: Cast a ray in a (uniformly) random direction Weight the result by f r ( in, out ) in N With importance sampling: H I( in ) f r ( in, out ) in N d in Cast a ray in a direction drawn from a distribution p( in ) that is large where the BRDF is large. Weight the ray by: f (, ) N / p Ideally, the distribution is proportional to the BRDF: p in ~ f r ( in, out ) in N in out in in See Pharr handout for cosine weighted sampling of the hemisphere, very useful for diffuse reflection. r 31

100 rays/pixel without importance sampling 32

100 rays/pixel with importance sampling 33

200 rays/pixel without importance sampling 34

900 rays/pixel with importance sampling 35

Penumbra revisited: clumped samples 36

Penumbra: stratified sampling Stratified sampling gives a better distribution of samples: Break pixel and light source into regions. Choose random locations within each region. Trace rays through/to those jittered locations. 37

Stratified sampling of a 2D pixel Here we see pure uniform vs. stratified sampling over a 2D pixel (here 16 rays/pixel): Random Stratified The stratified pattern on the right is also sometimes called a jittered sampling pattern. Similar grids can be constructed over the camera aperture, light sources, and diffuse/glossy reflection directions. 38

25 rays/pixel without stratified sampling 39

25 rays/pixel with stratified sampling 40

64 rays/pixel without stratified sampling 41

400 rays/pixel with stratified sampling 42