Part I The Basic Algorithm 1 Principles of A two-pass global illumination method Pass I Computing the photon map A rough representation of the lighting in the scene Pass II rendering Regular (distributed) raytracing, optimized with the information in the photon map Solves the rendering equation! Every part of the equation (diffuse, specular, caustics etc.) is solved by different means. 2 From http://www.okino.com/conv/features/caustics Computer Science Dept. Technion Page 1
Pros: Easy to understand and implement Optimizes i rendering and produces most photorealistic ti effects View (Pass I) and geometry independent Cons: Memory consumption Computationally cumbersome (photon tracing) Some optimization techniques can speed up the algorithm significantly. 3 Photon Emission A light source has a given flux (power) P light Number of emitted photons: n e Plight Pphoton = n The distribution of directions depends on the shape of the light Point light sources distribute photons in an isotropic manner. e 4 Computer Science Dept. Technion Page 2
Photon Emission Algorithm Using simple rejection sampling emit photons from diffuse point light() { ne = 0 //number of emitted photons while (not enough photons) { do { x = random number between -1 and 1 y = random number between -1 and 1 z = random number between -1 and 1 } while ( x2 + y2 + z2 > 1 ) d = < x, y, z > p = light source position trace photon from p in direction d ne = ne + 1 } scale power of stored photons with 1/ne } 5 Photon Emission Cont d More photons should be emitted from brighter lights in a multiply-lighted scene Power of photons should be as close to even as possible. May use less photons because each light source contributes less illumination effects. Most photons are typically wasted! Using projection maps: projecting the scene unto each light source and determining the directions in which objects exist. Shooting photons only at these directions. Resulting in less photons on the scene. 6 Computer Science Dept. Technion Page 3
Photon Tracing A light-direction ray-tracing process Algorithm: Shoot photons from lights source When surface is hit, decide whether photon is absorbed\reflected\transmitted. If surface is diffuse, store photon in photon map. 7 Absorbed, Transmitted or Reflected? A surface with diffuse coefficient d and specular coefficient s is hit by a photon with power P s+d<=1, for energy conservation. Make a decision according to Russian Roulette : Randomize a uniform variable x x [0, d] Diffuse x ( d, s + d ] Specular x ( s + d,1] Absorption 8 Computer Science Dept. Technion Page 4
Photon Tracing with Color Bands Deciding using the maximum energy of any color band (RGB) For instance, the probability p d for diffuse reflection is now: p d = max{ dp, dp, dp} r r g g b b max{ P, P, P} r g b Where ( Pr, Pg, P) color bands. is the powers of the photon in the 9 Color Bands cont d The power of the photons need to be re-adjusted to ensure that low-power photons do not waste our time. P refl, c = P inc, c i( s/ d) p ( sd / ) c Why Use Russian Roulette? Photons of even power Controlling the amount of photons Caveat Increasing variance. 10 Computer Science Dept. Technion Page 5
The photon Map Photon is stored in the photon map when hitting a diffuse surface Why not on specular surfaces? Every time a surface is hit, the photon is stored A photon is stored as the number of times it bounces. 11 A Photon Data Structure The data structure for a stored photon contains Incoming direction Incoming power Position in space The photon map, in the most simple representation, is a list of all stored photons. 12 Computer Science Dept. Technion Page 6
Required Photon Maps In order for the rendering to be efficient and correct, we usually require the usage of three photon maps: Caustics photon map Contains photons of the type LS+D Global photon map Contains all types of photons L{S D V }*D Volume photon map Contains photon which participate in indirect illumination of participating media (another topic). 13 Querying the Photon Map Most queries on the photon map (usually to estimate the radiance on a surface) requires an efficient query of which are the nearest neighbors. Using A balanced Kd-Tree Queries are O(logN), where N is the size of the tree. 14 Computer Science Dept. Technion Page 7
Seen in the lecture: Radiance Estimation (, ) ( ) L x f x f x 2 n d Φ p x ω p Pi ω p r(, ω) = r(, ωp, ω) r(, ωp, ω) dap p= 1 A Ω x Algorithm: Search for n closest photons Sum up the contribution according to power Pi with surface BRDF Fr. 15 Density of Closest Photons Assuming the surface is locally flat, using a widening circle until n photons are within it. 2 If radius is r then A = π r Low density photons, edges, and corners make this approximation wrong! 16 Computer Science Dept. Technion Page 8
Filtering If number of photons is too low, edges and corners will become blurry. Solution: Assign weights to photons according to distance from x. Possibilities: d p Cone filter: wpc = 1, k 1 kr i Gaussian filter: w pg 1 e = 1 1 e β α β 2 d p 2 2r 17 Rendering A Scene A scene is composed of the following components Direct illumination Rendered using regular ray-casting Can be approximated using the radiance estimate t Specular and glossy reflection Rendering using standard monte-carlo ray tracing. Cannot be handled with the photon map. Caustics Radiance estimate from the caustics map. Diffuse interreflection (color bleeding) Approximate just using the radiance estimate Accurate tracing rays with the information about the flux as an optimizer. 18 Computer Science Dept. Technion Page 9
Examples Radiance estimates (number of photons in the estimate) 100 Photons 500 photons 19 Multiple Lights Example 100,000 photons from each light source, 100 photons in the estimate 20 Computer Science Dept. Technion Page 10
Subsurface Scattering 100,000 photons 21 Computer Science Dept. Technion Page 11