Click here to load reader

Global Illumination

  • View

  • Download

Embed Size (px)


Global Illumination. CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2006. Classic Ray Tracing. The ‘classic’ ray tracing algorithm shoots one primary ray per pixel - PowerPoint PPT Presentation

Text of Global Illumination

  • Global IlluminationCSE167: Computer GraphicsInstructor: Steve RotenbergUCSD, Fall 2006

  • Classic Ray TracingThe classic ray tracing algorithm shoots one primary ray per pixelIf 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 surfaceIf the ray hits a shiny reflective surface, a secondary ray is spawned in the reflection direction and recursively traced through the sceneIf a ray hits a transparent surface, then a reflection and a transmission (refraction) ray are spawned and recursively traced through the sceneTo 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 surfacesScenes with many lights and many inter-reflecting surfaces will require more raysImages 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

  • Classic Ray Tracing

  • Distribution Ray TracingDistribution 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 antialiasingWe can model area light sources, and achieve soft edge shadows by shooting several shadow rays distributed across the light surfaceWe can model blurry reflections and refractions by spawning several rays distributed around the reflection/refraction directionWe can also model camera focus blur by distributing our rays across a virtual camera apertureAs if that werent enough, we can also render motion blur by distributing our primary rays in timeDistribution 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 renderingHowever, it is, of course, much more expensive, as the average number of rays per pixel can jump to hundreds, or even thousands

  • Distribution Ray Tracing

  • Ray TracingThe classic and distribution ray tracing algorithms are clearly important steps in the direction of photoreal renderingHowever, they are not truly physically correct as they still are leaving out some components of the illuminationIn particular, they dont fully sample the hemisphere of possible directions for incoming light reflected off of other surfacesThis 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)

  • Hemispherical SamplingWe can modify the distribution ray tracing algorithm to shoot a bunch of rays scattered about the hemisphere to capture additional incoming lightWith some careful tuning, we can make this operate in a physically plausible wayHowever, 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 surfaces10 rays is definitely not enough to sample a hemisphere, but lets just assume for now that we will use 10 samples for each hemisphereIf 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)*105 = 4,800,000 rays traced to color a single pixelThis makes this approach pretty impracticalThe good news is that there are better options

  • Path TracingIn 1985, James Kajiya proposed the Monte Carlo path tracing algorithm, also known as MCPT or simply path tracingThe path tracing algorithm fixes many of the exponential ray problems we get with distribution ray tracingIt assumes that as long as we are taking enough samples of the pixel in total, we shouldnt have to spawn many rays at each bounceInstead, we can even get away with spawning a single ray for each bounce, where the ray is randomly scattered somewhere across the hemisphereFor example, to render a single pixel, we may start by shooting 16 primary rays to achieve our pixel antialiasingFor each of those samples, we might only spawn off, say 10 new rays, scattered in random directionsFrom 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 pixelWe 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 bounceTherefore, 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

  • Path Tracing

  • BRDFsIn a previous lecture, we briefly introduced the concept of a BRDF, or bidirectional reflectance distribution functionThe BRDF is a function that describes how light is scattered (reflected) off of a surfaceThe BRDF can model the macroscopic behavior of microscopic surface features such as roughness, different pigments, fine scale structure, and moreThe BRDF can provide everything necessary to determine how much light from an incident beam coming from any direction will scatter off in any other directionDifferent 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 moreBRDFs can also be measured from real world materials using specialized equipment

  • BRDF FormulationThe wavelength dependent BRDF at a point is a 5D functionBRDF = fr(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 colorBRDF = fr(i,i,r,r)

    Another option is to express it in more of a vector notation:BRDF = fr(i,r)

    Sometimes, it is also expressed as a function of position:BRDF = fr(x,i,r)

  • Physically Plausible BRDFsFor a BRDF to be physically plausible, it must not violate two key laws of physics:

    Helmholtz reciprocityfr(i,r) = fr(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 fr(i,r)(rn)dr < 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

  • BRDF EvaluationThe outgoing radiance along a vector r due to an incoming radiance (irradiance) from direction i:

    dLr(x,r)=fr(x,i,r)Li(x,i)(in)di To compute the total outgoing radiance along vector r, we must integrate over the hemisphere of incoming radiance:Lr(x,r)= fr(x,i,r)Li(x,i)(in)di

  • Rendering EquationLr(x,r)= fr(x,i,r)Li(x,i)(in)di

    This equation is known as the rendering equation, and is the key mathematical equation behind modern photoreal renderingIt describes the light Lr reflected off from some location x in some direction rFor 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 cameraThe 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 variablesWe integrate over the hemisphere of possible incident light directions iGiven a particular incident light direction i and our desired reflection direction r, we evaluate the BRDF fr() at location xThe 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 Li(), which involves solving an integral equation exactly like the one were already trying to solveThe rendering equation is unfortunately, an infinitely recursive integral equation, which makes it rather difficult to compute

  • Monte Carlo SamplingPath tracing is based on a mathematical concept of Monte Carlo samplingMonte 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 analyticallyFor 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 anywayWe 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 with any other reasonable way. It is often considered as a

Search related