Image Synthesis Assignment 1: Heightfield Intersection
Due: February 8
For this assignment, you will improve pbrt's support for rendering terrain in scenes like landscapes and seascapes. Terrain is often represented as an elevation map, or what we will call a heightfield: a 2D table indicating the height of a surface above each point of a uniform grid. In other words, a heightfield is tabulated form of a height function z(x,y) stored in a 2D array.
pbrt has no native support for rendering directly from heightfield data. Instead, it converts heightfields into triangle meshes by connecting adjacent height values in the array. This approach is general but relatively inefficient; by converting to triangles we lose the orderly structure of the heightfield, which can be exploited to render more efficiently. Your assignment is to apply techniques similar to those used for grid-based acceleration structures to develop a fast intersection routine for heightfields.
Click here to download a zip file containing several pbrt scene files, heightfield data, and textures. The UNIX version of pbrt should build the heightfield shape plugin by default. If you're using windows, copy the heightfield.vcproj file to pbrt/win32/Projects/ and add the project file in the pbrt solution. After you have built the heightfield plugin, run pbrt on scenes: hftest.pbrt and landsea-0.pbrt, and you should see output images (hftest.exr and landsea-0.exr) that look like this:

The 4x4 heightfield in hftest.pbrt (left image) is designed for debugging; use this file as you develop and test your intersection algorithm. The landsea-0.pbrt contains two 64x64 heightfields (land and sea) and there are several views of this scene (0-3). landsea-big.pbrt contains a 1000x1000 heightfield and will likely take a while to render and consume loads of memory in the process.
Write a new accelerator class that simply puts all primitives into a list and tests each ray against every primitive. Run a few sample scenes through your accelerator and report timing comparisons against the ones provided with pbrt. Present your results as a table of timings, but of course you should make sure that your "accelerator" produces correct images.
The purpose of this step is to provide a baseline for comparison; the provided accelerators in pbrt are already very fast. You should be able to do better than them by exploiting the special structure of heightfields, but nonetheless you should have something slow to compare against!
Your assignment is to write a fast heightfield intersection algorithm, which will allow you to render higher resolution terrains more quickly than the current implementation. You should do this by modifying the existing 'pbrt/shapes/heightfield.cpp' file; you do not need to change other pbrt files. Specifically, you need to:
Your implementation of Intersect() and IntersectP() will likely use an acceleration structure like a uniform grid or kd-tree. You should start by reading this paper on a fast method for marching rays through uniform grids. Also feel free to peruse the pbrt source for examples, but make sure you understand any code that you borrow.
Once you have the fast intersection routines working, add the following additional features:
Here are some example images of what you should see after completing the steps above:

Write a web page and mail the URL to the TA.. The page should contain the following:
This homework will be graded according to the following system:
0 - Little or no work was done
* - Significant effort was put into the assignment, but rendering does not
work fully
** - The intersection routine was functionally complete, but step 3 doesn't
work at all.
*** - Intersection and texture mapping worked, but normal interpolation
didn't.
**** - Intersection and normal interpolation worked, but texture mapping
didn't.
***** - All requirements satisfied, and the implementation is faster than the original
Note that only ONE star is available for intersection routines that aren't functional from all viewpoints, regardless of texture mapping and/or normal interpolation.