Homework 5

Due: May 17, 2001

The purpose of this assignment is to add support for direct lighting from area light sources to lrt. This involves integrating the reflection equation given the area light source. You will do this by Monte Carlo sampling. When you finish the assignment, you will be able to perform Monte Carlo integration for direct lighting in one of two ways:

The math behind the programming assignment was covered in the written homework 4. This assignment will be an adventure in probability and integration. It is also full of places where subtle mistakes will doom your code. We strongly suggest you finish the written homework before you begin programming!

You should also read the Chapters 9-13 in the book before you begin programming. These chapters cover the basic of materials and shading, reflection functions, textures (you will not use the material in this chapter), light sources and light transport. Look at the Monte Carlo integrator code in Chapter 13, The provided diffuse surface implementation should give you a good idea of what to do for the Sample() and Pdf() functions. You will also want to look at the class definitions for the surfaces to see what variables you have access to.

For extra credit, you should provide a third technique

If you decide to tackle the extra credit part of the assignment, you will want to read: Chapter 9 of Eric Veach's thesis. Eric, a former graduate student at Stanford, invented multiple importance sampling. I discussed multiple importance sampling briefly in my second lecture on Monte Carlo Techniques.

This homework will be graded according to the following system:


Copy the new version of lrt from /usr/class/cs348b/software/lrt/lrt.tar.gz to your directory.


The first thing you should implement is uniform area sampling. You are asked to implement spherical lights. They are assumed to be diffuse emitters. You have to figure out how to generate uniform random samples (with respect to area) given uniform random numbers. You also have to be able to return a probability density function (pdf) for a given ray. We have also provided stubs for cylinders and cones if you want to try those (but that is not part of the assignment).

After getting the spherical light done, you should be able to code the integrator to handle the case of evaluating a surface color based on sampling the area light source. If you do this right, you should be able to render a scene that has diffuse surfaces (implemented for you) or Blinn glossy surfaces, multiple area lights, and some blockers to produce something with soft shadows.

What to watch out for: Check to see what the fr() routine does to make sure you provide it the correct values.
What to watch out for: Make sure your code handles shadows properly. You should be able to generate soft shadows with nice penumbras. You should check the shadows on and shadows off flags.

You should then implement sampling of glossy surfaces using the Blinn microfacet distribution function. We know from class this is (N dot H)^k. You will have to generate a random H vector based on the Blinn distribution, then reflect your ray about this H to generate your light vector. You'll also have to come up with a pdf for a point on the surface.

What to watch out for: Make sure your microfacet distribution function is properly normalized, as was derived in class.

After doing the Blinn surface, you should add the appropriate code to the integrator and check to make sure everything works. You'll know it is working if you can get some shiny surfaces.

If you have area lights and the Blinn glossy surfaces working correctly, you may be ready to tackle multiple importance sampling as extra credit. This part adds the last bit of code to your integrator. Essentially this code will make use of the sampling and pdf functions you've written, and will make better decisions about what to do with each sample it is given.


Here is a skeleton test file: test1.rib. There is a shiny metal surface and one spherical light source.

We will post some sample images soon ...

Copyright © 2001 Pat Hanrahan