Global Illumination CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005

Click here to load reader

  • date post

    14-Dec-2015
  • Category

    Documents

  • view

    219
  • download

    3

Embed Size (px)

Transcript of Global Illumination CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005

  • Slide 1

Global Illumination CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005 Slide 2 Classic Ray Tracing The classic ray tracing algorithm shoots one primary ray per pixel If the ray hits a colored surface, then a shadow ray is shot towards each light source to test for shadows, and determine if the light can contribute to the illumination of the surface If the ray hits a shiny reflective surface, a secondary ray is spawned in the reflection direction and recursively traced through the scene If a ray hits a transparent surface, then a reflection and a transmission (refraction) ray are spawned and recursively traced through the scene To prevent infinite loops, the recursion depth is usually capped to some reasonable number of bounces (less than 10 usually works) In this way, we may end up with an average of fewer than 20 or so rays per pixel in scenes with only a few lights and a few reflective or refractive surfaces Scenes with many lights and many inter-reflecting surfaces will require more rays Images rendered with the classic ray tracing algorithm can contain shadows, exact inter-reflections and refractions, and multiple lights, but may tend to have a rather sharp appearance, due to the limitation to perfectly polished surfaces and point light sources Slide 3 Classic Ray Tracing etc. Slide 4 Distribution Ray Tracing Distribution ray tracing extends the classic ray tracing algorithm by shooting several rays in situations where the classic algorithm shoots only one (or two) For example, if we shoot several primary rays for a single pixel, we can achieve image antialiasing We can model area light sources, and achieve soft edge shadows by shooting several shadow rays distributed across the light surface We can model blurry reflections and refractions by spawning several rays distributed around the reflection/refraction direction We can also model camera focus blur by distributing our rays across a virtual camera aperture As if that werent enough, we can also render motion blur by distributing our primary rays in time Distribution ray tracing is a powerful extension to classic ray tracing that clearly showed that the central concept of ray tracing was a useful paradigm for high quality rendering However, it is, of course, much more expensive, as the average number of rays per pixel can jump to hundreds, or even thousands Slide 5 Distribution Ray Tracing etc. Slide 6 Ray Tracing The classic and distribution ray tracing algorithms are clearly important steps in the direction of photoreal rendering However, they are not truly physically correct as they still are leaving out some components of the illumination In particular, they dont fully sample the hemisphere of possible directions for incoming light reflected off of other surfaces This leaves out important lighting features such as color bleeding also known as diffuse inter-reflection (for example, if we have a white light source and a diffuse green wall next to a diffuse white wall, the white wall will appear greenish near the green wall, due to green light diffusely reflected off of the green wall) It also leaves out complex specular effects like focused beams of light known as caustics (like the wavy lines of light seen at the bottom of a swimming pool) Slide 7 Hemispherical Sampling We can modify the distribution ray tracing algorithm to shoot a bunch of rays scattered about the hemisphere to capture additional incoming light With some careful tuning, we can make this operate in a physically plausible way However, we would need to shoot a lot of rays to adequately sample the entire hemisphere, and each of those rays would have to spawn lots of other rays when they hit surfaces 10 rays is definitely not enough to sample a hemisphere, but lets just assume for now that we will use 10 samples for each hemisphere If we have 2 lights and we supersample the pixel with 16 samples and allow 5 bounces where each bounce shoots 10 rays, we end up with potentially 16*(2+1)*10 5 = 4,800,000 rays traced to color a single pixel This makes this approach pretty impractical The good news is that there are better options Slide 8 Path Tracing In 1985, James Kajiya proposed the Monte Carlo path tracing algorithm, also known as MCPT or simply path tracing The path tracing algorithm fixes many of the exponential ray problems we get with distribution ray tracing It assumes that as long as we are taking enough samples of the pixel in total, we shouldnt have to spawn many rays at each bounce Instead, we can even get away with spawning a single ray for each bounce, where the ray is randomly scattered somewhere across the hemisphere For example, to render a single pixel, we may start by shooting 16 primary rays to achieve our pixel antialiasing For each of those samples, we might only spawn off, say 10 new rays, scattered in random directions From then on, any additional bounces will spawn off only 1 new ray, thus creating a path. In this example, we would be tracing a total of 16*10 paths per pixel We will still end up shooting more than 160 rays, however, as each path may have several bounces and will also spawn off shadow rays at each bounce Therefore, if we allow 5 bounces and 2 lights, as in the last example, we will have a total of (2+1)*(5+1) = 18 rays per path, for a total of 8*160=1280 rays per pixel, which is a lot, but far more reasonable than the previous example Slide 9 Path Tracing Slide 10 BRDFs In a previous lecture, we briefly introduced the concept of a BRDF, or bidirectional reflectance distribution function The BRDF is a function that describes how light is scattered (reflected) off of a surface The BRDF can model the macroscopic behavior of microscopic surface features such as roughness, different pigments, fine scale structure, and more The BRDF can provide everything necessary to determine how much light from an incident beam coming from any direction will scatter off in any other direction Different BRDFs have been designed to model the complex light scattering patterns from a wide range of materials including brushed metals, human skin, car paint, glass, CDs, and more BRDFs can also be measured from real world materials using specialized equipment Slide 11 BRDF Formulation The wavelength dependent BRDF at a point is a 5D function BRDF = f r ( i, i, r, r,) Often, instead of thinking of it as a 5D scalar function of , we can think of it as a 4D function that returns a color BRDF = f r ( i, i, r, r ) Another option is to express it in more of a vector notation: BRDF = f r ( i, r ) Sometimes, it is also expressed as a function of position: BRDF = f r (x, i, r ) Slide 12 Physically Plausible BRDFs For a BRDF to be physically plausible, it must not violate two key laws of physics: Helmholtz reciprocity f r ( i, r ) = f r ( r, i ) Helmholtz reciprocity refers to the reversibility of light paths. We should be able to reverse the incident and reflected ray directions and get the same result. It is this important property of light that makes algorithms like ray tracing possible, as they rely on tracing light paths backwards Conservation of energy f r ( i, r )( r n)d r < 1, for all i For a BRDF to conserve energy, it must not reflect more light than it receives. A single beam of incident light may be scattered across the entire hemisphere above the surface. The total amount of this reflected light is the (double) integral of the BRDF over the hemisphere of possible reflection directions Slide 13 BRDF Evaluation The outgoing radiance along a vector r due to an incoming radiance (irradiance) from direction i : dL r (x, r )=f r (x, i, r )L i (x, i )( i n)d i To compute the total outgoing radiance along vector r, we must integrate over the hemisphere of incoming radiance: L r (x, r )= f r (x, i, r )L i (x, i )( i n)d i Slide 14 Rendering Equation L r (x, r )= f r (x, i, r )L i (x, i )( i n)d i This equation is known as the rendering equation, and is the key mathematical equation behind modern photoreal rendering It describes the light L r reflected off from some location x in some direction r For example, if our primary ray hits some surface, we want to know the light reflected off of that point back in the direction towards the camera The reflected light is described as an integral over a hemispherical domain , which is really just shorthand for writing it as a double integral over two angular variables We integrate over the hemisphere of possible incident light directions i Given a particular incident light direction i and our desired reflection direction r, we evaluate the BRDF f r () at location x The BRDF tells us how much the light coming from direction i will be scaled, but we still need to know how much light is coming from that direction. Unfortunately, this involves computing L i (), which involves solving an integral equation exactly like the one were already trying to solve The rendering equation is unfortunately, an infinitely recursive integral equation, which makes it rather difficult to compute Slide 15 Monte Carlo Sampling Path tracing is based on a mathematical concept of Monte Carlo sampling Monte Carlo sampling refers to algorithms that make use of randomness to compute a mathematical result (Monte Carlo famous for its casinos) Technically, we use Monte Carlo sampling to approximate a complex integral that we cant solve analytically For example, consider computing the area of a circle. Now, we have a simple analytical formula for that, but we can apply Monte Carlo sampling to it anyway We consider a square area around our circle and choose a bunch of random points distributed in the square. If we count the number of points that end up inside the circle, we can approximate the area of the circle as: (area of square) * (number of points in circle) / (total number of points) Monte Carlo sampling is a brute force computation method for approximating complex integrals that cant be solved