CS 655 Computer Graphics Photon Mapping Photon Mapping

  • Slides: 21
Download presentation
CS 655 – Computer Graphics Photon Mapping

CS 655 – Computer Graphics Photon Mapping

Photon Mapping • Photon mapping is a a technique for simulating global illumination. •

Photon Mapping • Photon mapping is a a technique for simulating global illumination. • There are combined radiosity/ray tracing approaches to global illumination, as well as stochastic techniques (e. g. path tracing): § Ray tracing extended with Monte Carlo techniques: § Very time consuming. Noisy results. Radiosity extended with directional capabilities: - Requires too much storage. Doesn’t handle specular reflections correctly.

Photon Mapping • Idea: § Photons are emitted from light sources. § Each photon

Photon Mapping • Idea: § Photons are emitted from light sources. § Each photon is traced through the scene using path tracing. Every time a photon hits a surface it is stored in the photon map. Photons are either absorbed or reflected. Reflected photon directions are computed using the BRDF of the surface. After the photon map is created, the scene is ray traced. The photon map information is used by the ray tracer. § § §

Photon Mapping • Constructing the Photon Map § The photon map is created in

Photon Mapping • Constructing the Photon Map § The photon map is created in the first pass. § Two photon maps are kept – the caustics photon map and the global photon map. • The Caustics Photon Map § § § Used to store photons corresponding to caustics. Created by emitting photons toward specular objects and storing these as they hit diffuse surfaces. Requires a high density of photons.

Photon Mapping • The Global Photon Map § Created by emitting photons towards all

Photon Mapping • The Global Photon Map § Created by emitting photons towards all objects. § Doesn’t require as much precision as caustics map. Shadow photons are created by tracing rays from the light source through the scene, and keeping track of shadow information. The shadow photons are later used to reduce shadow rays. Photons are stored in a balanced kd-tree. This provides efficiency (O(M log 2 N) to locate M photons in a tree with N photons). Each photon is represented with 20 bytes. § §

Photon Mapping • Pass 2: Rendering § Rendering is done using Monte Carlo ray

Photon Mapping • Pass 2: Rendering § Rendering is done using Monte Carlo ray tracing. § Pixel intensities are the average of the sample rays sent through the pixel. The radiance returned by each ray is computed at the first surface intersected, and is equal to Ls(x, Yr), the surface radiance leaving point x in the direction of the ray Yr. §

Photon Mapping • Pass 2: Rendering (cont) § Ls(x, Yr) is computed using the

Photon Mapping • Pass 2: Rendering (cont) § Ls(x, Yr) is computed using the rendering equation: where: - Le is the radiance emitted by the surface and is taken directly from the surface definition. - Li is the incoming radiance in the direction Yi. fr is the BRDF. Lr is the integral portion of the equation.

Photon Mapping • Pass 2: Rendering (cont) § § The value of the integral,

Photon Mapping • Pass 2: Rendering (cont) § § The value of the integral, Lr, can be solved using path tracing, but this is expensive. Instead, the photon map is used. Lr is split into several components: where: - Li, 1 represents contributions from the light sources. Li, c represents contributions from the light sources via specular reflection (caustics). Li, d represents light which has been reflected diffusely at least once (indirect soft illumination). Li = Li, 1 + Li, c + Li, d.

Photon Mapping • Pass 2: Rendering (cont) The BRDF is separated into diffuse and

Photon Mapping • Pass 2: Rendering (cont) The BRDF is separated into diffuse and specular components: § § fr, s represents the specular component of the BRDF. fr, d represents the diffuse component of the BRDF. fr = fr, s + fr, d. The integral is computed in two different ways: 1. Accurate computation used: a. When the surface is seen directly by the eye. b. Within a few specular reflections. c. When the distance between the ray origin and intersection point is small. 2. Approximate evaluation used: a. When the ray has been reflected diffusely. b. If the weight of the ray is low.

Photon Mapping • Pass 2: Rendering (cont) The pieces of the equation: § -

Photon Mapping • Pass 2: Rendering (cont) The pieces of the equation: § - The contribution via direct illumination by the light sources. Computed by using the shadow information in the shadow map. - The radiance reflected off specular surfaces. Computed using standard Monte Carlo ray tracing. - Caustics on diffuse surfaces. Computed using the caustic photon map.

Photon Mapping • Pass 2: Rendering (cont) The pieces of the equation (cont): §

Photon Mapping • Pass 2: Rendering (cont) The pieces of the equation (cont): § - Incoming light which has been reflected diffusely at least once. Computed using the global photon map.

Photon Mapping • Pass 2: Rendering (cont) Estimating Radiance using the Photon Map: §

Photon Mapping • Pass 2: Rendering (cont) Estimating Radiance using the Photon Map: § - The photon map can be used to compute the radiance leaving a surface in a given direction. - Works well with diffuse to slightly glossy surfaces. For highly glossy surfaces, lots of photons would be needed. To compute the radiance, Lr, leaving an intersection point x at a surface with BRDF fr: o Find the N photons with the shortest distance to x. o Each photon p represents flux DFp arriving at x from direction Yi, p. o Putting this into the rendering equation we get: - Center a sphere at x and expand until it contains N photons and has radius r. The area is then approximated with pr 2.

Photon Mapping • Data structure: § Struct photon { long energy; // packed energy

Photon Mapping • Data structure: § Struct photon { long energy; // packed energy (RGB) float position[3]; // photon position float theta, phi; // photon direction char normal[3]; // surface normal char key; // kd-tree parameter struct photon *left, *right; // rest of kd-tree }

Photon Mapping • Advantages of Photon Mapping: § § § Can be implemented into

Photon Mapping • Advantages of Photon Mapping: § § § Can be implemented into traditional ray tracers by adding an additional module to the existing code. Photon maps are geometry independent. Calculation time for the maps is generally low, allowing an efficient method to recalculate maps during animated scenes. Results are comparable to or better than combination radiosity/ray tracing methods, and it is much more efficient. Photon mapping also reduces shadow ray computation by marking shadow photons. Caustics can be realized directly by using a separate photon map with higher density.

Photon Mapping

Photon Mapping

Photon Mapping • An example Museum: § - 5000 polygons and spheres. 1 procedural

Photon Mapping • An example Museum: § - 5000 polygons and spheres. 1 procedural object. Two small spherical area light sources. 390, 000 caustic photons. 165, 000 global photons (9 MB). 298 seconds for 1 st pass, 51 minutes for 2 nd. Contains: Caustics from glass onto rough surface. Caustics from cylinder to wall. Color bleeding between walls.

Photon Mapping

Photon Mapping

Photon Mapping

Photon Mapping

Photon Mapping

Photon Mapping

Photon Mapping

Photon Mapping

Photon Mapping

Photon Mapping