Assignment 4: Investigating Importance Sampling

Due: Tuesday May 16th, 11:59PM

Questions? Need help? Post them on the Assignment4Discussion page so everyone else can see!

Please add a link to your final writeup on Assignment4Submission. Since there is very little coding to be done on this assignment, please give extra attention to the quality of the answers in your writeup.


Rendering requires the computation of many different types of integrals. In the last assignment we numerically integrated over the back element of the realistic camera lens to compute the irradiance indicent on each pixel of the camera's film. As you are now well aware, the variance of a monte carlo estimator manifests itself as noise in a rendered image. Thus, when integrating a function, it is important to choose samples from the domain of integration such that variance in the integral estimate is minimized. Importance sampling is a variance reduction technique that draws samples using a distribution that is proportional to the value of the function over the domain. In this assignment you will explore various approaches for sampling irradiance on scene objects due to an infinite area light source (environment light) and explain when certain approaches are preferrable to others.

We are happy to inform you that this assignment is designed to be significantly shorter than Homework 2 and 3.

Step 1: Background Reading

Read chapters 13 (especially 13.5), 14 (especially 14.3.4) and 15 (especially 15.6) in the pbrt book. This assignment will require a solid understanding of importance sampling, so please read the these chapters carefully.

Additionally, you may want to take a closer look at the Monte Carlo integration your performed in assignment 3. Read this document to see why.

Step 2: Importance Sampling an Infinite Area Light

In the scenes we've rendered in this class so far, objects were lit using a small number of spotlight or area light sources. In the real world, light incident on an object comes not just from light emitters, but from all directions. One way of approximating this effect in pbrt is to use an environment light (infinite area light in pbrt), which is used to define light entering the scene from all directions due the surrounding environment. Environment lighting can greatly contribute to the realism and richness of your renderings, however, since computing environment lighting involves integrating incoming radiance over the entire hemisphere, in the worst case, Monte Carlo estimates are prone to be noisy, and require many samples to produce images of reasonable quality. In the scene below, images of the killeroo scene are rendered with 4, 8, and 128 samples per pixel.

killeroo_view1_grace_mis_irr_4 killeroo_view1_grace_mis_irr_8 killeroo_view1_grace

Importance sampling the environment map can make an enormous difference in the quality of the rendered image. Both images below are rendered using the same number of samples. In the image below at left, samples are drawn from a cosine-weighted distribution centered about the normal of the surface being shaded (see lights/infinite.cpp). At right, samples are drawn using a probability distribution that is proportional to the luminance of the environment map (see lights/infinitesample.cpp).

killeroo_view1_grace_light_cos_16 killeroo_view1_grace_light_irr_16

Question 1. As an exercise, assume that you are given an environment map with luminance L(phi, theta) = cos(theta)  for theta > PI/2 and L(phi, theta) = 0 otherwise. Write down a pdf that could be used to sample the environment with respect to luminance. Use the inversion method to find expressions for phi and theta in terms of uniform random variables x1 and x2 so that a direction on the sphere is chosen randomly according to your pdf.

Note in simple cases such as this, integrating the pdf analytically is possible. In practice, radiance from each position is defined by a texture map and the pdf is determined numerically. This is precisely what is done by lights/infinitesample.cpp.

Step 3: Multiple Importance Sampling

When computing reflected surface radiance due to direct lighting, pbrt computes a Monte Carlo estimate of the integral of incoming light over all directions modulated by the surface's BSDF. To improve the quality of this estimate, it is desirable to use importance sampling when choosing a direction in which to sample indicent radiance. The integrand consists of two terms, one related to the surface BSDF and the second related to radiance from light sources, and pbrt samples incoming radiance by drawing samples according to pdfs associated with each of the terms. This technique is called multiple importance sampling. It is implemented in pbrt in the file core/transport.cpp.

1. We would like to you add support for a 'sample' parameter to the 'directlighting' integrator that allows you to select between using the default importance sampling implementation, or sampling only according to either the light's or BSDF's pdf. Possible values of this parameter are 'bsdf', 'light', and 'mis'. This parameter controls whether the samples are drawn from BSDF, light source, or both distributions. Set the default value to be 'mis'.

2. The scene mis.pbrt defines the scene that is shown on page 677 of pbrt. Render mis.pbrt with each of the 3 sampling schemes. You should get images similar that on page 676 in the textbook.

Question 2.

4) Render killeroo_view1.pbrt with grace_latlong.exr as the environment map texture

5) Compare the overall noises, parital noises on the glossy surfaces (i.e. the red killeroo and front two balls) and the diffuse surfaces among 3 images. Identify which image has the least amount of noise, and which one has the most. Explain the reason.

6) Explain why it is important to use half number of samples for MIS

Step 5: Shortcoming of illuminated based sampling

So far, we have deomstrated using the intensity function of the environment map for importance sampling can significantly reduce the variance, using same number of light samples. Is this always true? Describe a situation that this sampling strategy may not be effective. Modify the killeroo scene or create a scene such that using 'infinitesample' light source produce an image with similar amount of noise as using lihgt source 'infinite.' Set the 'sample' option in step 4 to 'light,' how are the images affected?

Step 5: Short Questions

1) Explain why for the same scene setup and same number of samples,

Assignment4 (last edited 2006-05-17 04:14:17 by KayvonFatahalian)