CS 348B - Computer Graphics: Image Synthesis Techniques
Homework - Environment Map Importance Sampling
© Matt Pharr and Greg
Humphreys
Assigned Tuesday, May 3. Due Tuesday, May 10.
Description
Environment lighting can greatly contribute to the realism and richness of
your renderings. However, since it involves integrating over the entire
hemisphere in the worst case, it is prone to be noisy, requiring many samples
for reasonable quality. In this project you will add support to pbrt for handling distant
environmental lighting more efficiently by using importance sampling.
This assignment is designed to be significantly shorter than Homework 2 and
3.
Step 1
Read chapters 13 (especially 13.5), 14 (especially 14.3.4) and 15 (especially
15.6) in the pbrt book.
Step 2
- Download this zip archive (Updated 5/7)
and unzip
it into your
working directory.
- Render an image of the killeroo scene. This uses pbrt's built-in implementation
of an infinite environment light (pbrtsrc/lights/infinite.cpp). It should look
something like this:
Step 3: Enhance environment map light implementation with importance
sampling
- Copy pbrt's standard environment map light plugin (src/lights/infinite.cpp)
to your working directory, and call it importance_infinite.cpp.
- Modify killeroo_imp.pbrt to render the scene using
your importance-sampled light.
- Design an unbiased importance-based sampling scheme for the the light that
uses the distant radiance defined by the environment as the probability
density function (pdf).
- Modify your importance_infinity.cpp to use this sampling scheme.
- Verify that your implementation produces the same image as the default
when a large number of samples are taken (i.e. that your Monte Carlo
estimator is indeed unbiased) and that your scheme produces less noise with
an equal number of samples (i.e. that your importance metric produces less
variance).
- Try out some of the other environments provided in the textures
directory. The grace environment is particularly colorful.
* As a general rule, use only the course notes and the pbrt book as references for this assignment.
Do not copy importance sampling code from the internet.
Hints:
- The environment map is in color, but your pdf is scalar-valued.
Convert the color radiance to a scalar value (the so-called luminance) by
using the Spectrum::y() function. Use this scalar value as the value
of your pdf.
- Sampling from 2D distributions is more complicated than sampling from 1D
distributions. For the 2D case you may need to review marginal
distributions. You may like to take a look at the description of how
to use the marginals in Section 2.3.1 (page 24) of the SIGGRAPH
course notes from 2001. This was on the assigned reading from the Monte
Carlo lectures.
- Given continuous theta and phi angles, the radiance value in that
direction is defined by bilinear interpolation from the nearest environment
image grid samples (see infinity.cpp). It can be challenging to define
a pdf based on that piecewise linear reconstruction. Instead,
we recommend that while designing your pdf, you assume a piecewise
constant (i.e. nearest neighbor) reconstruction of the image map.
This will make designing a sampling scheme easier, it will be close to using
the bilinear reconstruction, and it will still be unbiased (see the next
hint) and produce accurate final pictures. Be sure to use bilinear
interpolation in returning the value of the radiance however; this hint
applies only to the design of the pdf.
- Given the last hint, the only point to be careful about is how you handle
black pixels in the scene when designing your sampling scheme. You may need
to introduce some special handling of such pixels to ensure that your
estimator remains unbiased.
Step 4: Web page submission
- Document your work in a web page again.
- In the archive that you downloaded, there is a submission
directory. Edit index.html -- the items that you
have to replace are marked in green.
- 2 pbrt scene files to generate the required pictures are included in
the submission directory. Copy these to your 'hw4' base directory.
Modify the "nsamples" parameter associated with the light
source to choose the required numbers of samples as shown on the web
page.
- Make sure to convert your tiff images with maximum quality ('-quality
100' parameter if using the 'convert' utility) as they will be noisy.
- Note: please do not include your source code on the web page,
or link to it. You will email it to us (see below).
- Though it is not a requirement, feel free to append a discussion of
anything extra or novel that you did at the end of your web page.
- Please send an email to [email protected]
- Make the subject 'HW4 submission'. (Please don't send this email till
your web page is completely done, and please don't submit any other
emails with that subject title if you can help it. This helps us
keep everything in order.)
- In the body of your email, please include the URL for your web page as
the first line.
- Please attach to your email your source code, importance_infinity.cpp.
Misc Data
You can render an image of the car shown in chapter 13 of pbrt and at the top
of this page. The scene file to render is scene/tt.pbrt on the CD.
Be aware that this includes a very large scene file for the car (60 MB large),
and might be difficult to render on the raptors with only 256 MB of memory.
pbrt assumes environment maps use a latitude-longitude parameterization. The images we provide have this format, so make sure you convert to the same if you want to try using other environment maps. You can covert from various other parameterizations using the panoramic transformations in
HDRShop. Also, Paul Debevec's website is good resource for all things related to image-based lighting, and there you can also find more environment maps.
FAQ
Please check back here for updates before sending questions to the staff
list.
-
Q: How do I build my importance_infinity.cpp file?
A: In the first assignments we provided a Makefile for Linux and a Visual Studio
project file for Windows. In this assignment, please adapt one of these build configurations from an earlier assignment, or take a look at the versions
used to build the core pbrt system. This will be good practice for the
final project when you will likely have to make much larger changes to pbrt and
get it to build correctly. If you have questions about how to do this,
please send us email.
Grading
** The assignment passes all or almost all our tests.
* Substantial work was put in, but the assignment didn't pass all
our tests.
0 Little or no work was done on the assignment.
*** Extra credit may be given on a case-by-case basis for well done
extensions that produce superior results.
Copyright © 2005 Pat Hanrahan