Global IlluminationCSE167: Computer GraphicsInstructor: Steve RotenbergUCSD, Fall 2005Classic 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 sourcesClassic Ray Tracingetc.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 weren’t 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 Tracingetc.etc.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 don’t 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 let’s 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 shouldn’t 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 examplePath TracingBRDFsIn 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 equipmentBRDF 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 =
View Full Document