Diffuse image-based lighting

 Image-based lighting is a technique that involves using an image as a light source.  The image represents an omni-directional view of the environment of the scene. With image-based lighting, the image itself is treated as a highly detailed light source that surrounds the scene completely. Objects in the scene are illuminated by the content of the image, making it possible to have a very complex lighting environment and/or to simulate a real world setting. Often, these images are produced using a special camera or special photographic techniques, and are recorded in high dynamic range. An example of one such image is shown here (image courtesy of USC Institute for Creative Technologies and Paul Debevec): 

These images may be provided as a cube map (set of six images), or some other type of environment map such as a equirectangular panoramic map (the type shown previously). Conversion between the two is straightforward.

Since each texel in the equirectangular map represents a direction, the same is true for a cube map. To convert from one to the other, we just need to convert directions in one map to directions in the other.

In this recipe, we'll go through the process of using an image as a light source for diffuse reflection. Most of the effort here is involved in the creation of the diffuse convolution map. The diffuse convolution is a transformation of the environment map into a form that can be used directly when computing the diffuse reflection. In the following images, the original environment map is shown on the left, and the right side is the diffuse convolution (image courtesy of USC Institute for Creative Technologies and Paul Debevec):

To understand the diffuse convolution map, lets review the reflectance equation (presented in A Physically-based reflection model in Chapter 3, The Basics of GLSL Shaders):

This equation represents the integral over all directions of incoming light (l) on the hemisphere above the surface. The f term in the preceding equation is the Bidirectional Reflectance Distribution Function (BRDF). It represents the fraction of light that is reflected from a surface point given the incoming (l) and outgoing (v) directions. If we only consider diffuse reflection (Lambertian), we can use the following constant term for the BRDF:

Which gives us the following for the reflectance equation:

Since the BRDF is just a constant, it can be factored outside of the integral. Note that there is nothing in this equation that depends upon the outgoing direction (v). That leads us to the following insight. The environment map that we discussed previously represents the amount of incoming radiance for a given direction, which is the Li(l) term in the preceding equation. We could estimate the value of this integral for a given value of n using the Monte Carlo estimator:

In the preceding equation, lj represents a pseudo-random direction sampled uniformly from the hemisphere above the surface (around n), and N is the number of samples. The constant factor of comes from the probability density function for uniform samples as a function of solid angle.  

Sampling the directions uniformly over the hemisphere is not quite as straightforward as you might think. Common practice is to sample directions in a system where the z axis is aligned with the vector n, and then transform the sample into world coordinates. However, we have to be careful to pick directions uniformly. For example, suppose we just pick random values between -1 and 1 for x and y, and 0 and 1 for z and then normalize. That would give us directions that are biased or "clumped" around the z axis and are not uniform over the hemisphere. To get uniform directions, we can use the following formulae:

The values ξ1 and ξ2 are uniform pseudo-random values in the range [0, 1]. For a derivation of this, see Physically Based Rendering, third edition, Chapter 13, Monte Carlo Integration.

Now that we have a way to estimate the integral for a given value of n, we can convolve the original environment map in the following way. We'll create a new environment map (the diffuse convolution map), where each texel represents a direction of n in world coordinates.  The value of the texel will be the estimated value of the preceding integral (except for the cdiff term) by taking a number of random samples (lj) from the original environment map. We can do this offline and pre-compute this diffuse convolution. It is a somewhat slow process, but we don't need a lot of detail. The diffuse convolution is usually fairly smoothly varying, so we can use a small resolution without sacrificing much quality.

I've admittedly glossed over some of the math here. For a very good introduction to Monte Carlo integration for graphics, please see Physically Based Rendering, third Edition by Pharr, Jakob, and Humphreys, Chapter 13, Monte Carlo Integration.

Once we have the pre-computed diffuse convolution, we can use that as a lookup table to give us the value of our diffuse integral (again, without cdiff) using the normal vector. We can multiply the value retrieved by our material's diffuse color cdiff to get the outgoing radiance. In other words, the diffuse convolution represents the outgoing radiance for a given value of n, rather than the incoming radiance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.213.128