Homework 3

Assigned: May 4, 2000Due: May 16, 2000Note: Be sure to check back to this assignment page often for
updates, explanations, and examples

The purpose of this assignment is to add Monte Carlo sampling to
lrt. When you finish the assignment, you will be able to
specify integration for a surface in one of three ways:

Randomly sample a rough surface microfacet distribution function

Randomly sample an area light source

Importance sample both at the same time

As a reference for this assignment, you will want to read:
Chapter
9 of Eric Veach's thesis.

Background

These images and equations are as presented in Eric Veach's thesis
chapter 9 on multiple importance sampling and from class.

Remember from class the basic reflection (or scattering) equation:
You'll need to use this form of the equation for sampling the surface
microfacet distribution function.

Another useful form of this function is the three-point form of the
equation (also talked about in class):
This is the same as the original reflectance equation, only we've
changed variables to integrate over area just the area of the light
source. Remember that V(x->x') is the visibility term. This is the
equation you'll need to use for performing your calculations based on
randomly sampling the light source.

Setup

Copy the new version of lrt from
/usr/class/cs348b/software/lrt/lrt-hw3.tar.gz to your
directory. This distribution includes stubs for
quadrics.cc, projections.cc, and mc.cc so
you may want to begin a new project directory so you don't clobber your quadrics and
projection solutions! You'll then want to replace the provided
quadrics.cc and projections.cc files with your
solutions from hw1 and hw2 respectively. You will be filling in the
code for mc.cc this time around.

Note that like other assignments, it is possible that we will update
the lrt release before the assignment is due. Be sure to update your
files if we announce a new release is out.

Coding

This assignment will be an adventure in probability and integration.
It is also full of places where subtle mistakes will doom your code.
Existing code will help you understand the mechanics for adding these
new techniques to lrt. Look at the existing integrator code,
particularly the Whitted integrator, to see how blockers and secondary
rays are handled. 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.

The first thing you should implement is the area light sources. You
are asked to implement disk and triangle area lights. They are
assumed to be diffuse emitters. You have to figure out how to
generate uniform random samples on these shapes (with respect to area)
given two uniform random numbers. You also have to be able to return
a probability density function (pdf) for a given ray.

What to watch out for: sampling the light uniformly in area. As an
example, think about the disk light source. Given two random numbers,
u1 and u2, a random sample on the disk is not simply u1*radius,
u2*theta. This will cluster the samples too close to the center of
the disk.

After getting the area lights 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.

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 normalized, as was derived
in class. Also, generating a
random H is not trivial. You first should generate an H value in the
plane with the eye and surface normal. Then rotate it a random amount
about the surface normal to produce your final H used in the
calculations.

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.

The last part of the assignment is to get multiple importance sampling
to work. You have to have the area lights and the Blinn glossy
surfaces working correctly to do this part. 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.

Samples

All of these images were generated from test1.rib (different from my original file).
They are all a diffuse surface, and all use 4 samples per pixel (2 x
2), and one light source sample.

Sampling Method

Light Source

BRDF

Combination

Remember, these images are provided for reference, not as debugging
tools. I may need to update these as I debug my software for the
project. Your images should look very close to these, but they depend
on how you choose to multi-sample your BRDF (I used 1 sample per pixel
sample), and how you choose to do
your multiple importance sampling (I chose the balance heuristic).

And, in case you're wondering, here's the same file rendered using
a glossy surface sampling the light. I've turned up the light source intensity, and set
it to be a shiny metal surface with roughness of 0.2. This one
doesn't have the PI correction factor mentioned in the email either.
But, you get the idea. Increasing the roughness will make the shiny
patch larger and larger.