CS 447/647: Image Synthesis
Assignment 1: Terrain Rendering
Due: February 6
For this assignment, you will improve lrt's support for rendering terrain - 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, we are tabulating the values of a height function z(x,y) in a 2D array. As you know from Section 3.7 of the lrt book, rudimentary support for heightfields is already provided - lrt can parse them, but it just turns them into triangle meshes for rendering.
Make sure to read section 3.7 carefully. Also make sure that you understand the behavior of the Refine method and the CanIntersect method. If you don't understand what's going on, it will be very hard to modify it to do what you want.
Heightfields have a very orderly structure which is lost when they are turned into general triangle meshes. This structure can be exploited to make intersection with heightfields very efficient. Your assignment is to apply techniques similar to those used for grid-based acceleration structures to develop a fast intersection routine for heightfields. Your solution should be substantially faster than the implementation in lrt.
Make sure that you still have a working version of lrt. If you have changed something, you might want to grab a fresh version of the code. Retrace your steps from assignment 0 if necessary.
There are several new scene files available for this assignment:
You should copy these three files from here to your working directory.
You will also need a sky texture. Download this file to your working directory.
When given multiple files on the command line, lrt reads and parses them one after another, as if they were one long file. Type lrt decls.rib hw1.rib sea1.rib land1.rib to begin rendering. This will generate hw1.tiff, a simple outdoor scene. You do still HAVE decls.rib from assignment zero, right? Make sure that you can generate this image before you continue. It should consist of a sky, some islands, and some (very coarsely sampled) reflecting waves.
You may find the rendered image seems a bit gray or dimly lit. You may wish to fine-tune the color-balance of your images in a post-process using an image manipulation tool like Photoshop.
The heightfields used for the land and water here are only 64x64 - as you can see, the low resolution is obvious in the resulting images. The "water" surface doesn't look very good with polygonal facets! After you have written a fast heightfield intersection routine, you'll be able to render much higher resolution heightfields, such as 1000x1000. To see examples of what is possible with higher resolution, take a look at the entry on rendering ocean scenes from the Stanford CS348b rendering contest last Spring. In addition to having a fast heightfield intersection routine, the authors also performed Phong interpolation of the normals for each triangle to make the water surface appear smooth.
As encouragement, there is a 1000x1000 ocean heightfield available here. There are also a number of other sky textures to choose from here.
To complete this project, you'll just need to modify the file shapes/heightfield.cc. Rather than refining a heightfield to a triangle mesh, you should provide an Intersect routine that will intersect rays directly with the heightfield. You should put some thought into how to do this efficiently. Note that the heightfield data is already basically in the form of a 2D uniform grid, so using a grid-based acceleration technique is probably a good idea. You should refer to your class notes on acceleration, and also to the paper by Amanatides and Woo for details about the algorithm.
Of course, your method must be robust - make sure it can work from a variety of viewpoints, and for any heightfields. You will NOT get more than one star (see grading scheme below) if your renderer fails from certain viewpoints.
Once you've got intersection working, add two additional features. In particular, you should:
We will be testing your software on Linux. Your software must work on Linux. Submissions that don't build or run on Linux will not be accepted.
Write a short web page describing your implementation. The web page should consist of:
Then, just mail the URL to the TA.
When submitting assignments, NEVER mail the TA anything other than a URL.
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 (i.e., we broke step 3)
** - The intersection routine was functionally complete, but step 4 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 substantially
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. Make SURE your intersector works; we will test it thorougly.
Also note that more points are awarded for normal interpolation than for texture mapping; this reflects our opinion of the relative difficulty of these two tasks. We will be PICKY about the quality of images with regards to normal interpolation. If you're not sure about your normal-interpolated images, consult the TA.