15-462 Computer Graphics I
Assignment 1 - Height Fields
100 points

Overview

Height fields are commonplace in computer graphics, from scientific visualization to terrain in video games. In this assignment, you will implement a program that loads in heightfield data from an image supplied on the command line and allows the user to view it interactively by rotating/translating/scaling it.

Background

A height field is a function that takes as input a two dimensional point and returns a value representing the orthagonal distance to a surface.

z = f(x,y)

In the general case, this is a rather tricky rendering problem. We will simplify the problem by defining the function in a piece-wise linear fashion. With one dimension as input, this would be akin to "connecting the dots" while moving along an axis:


Piecewise linear approximation of a sine wave

With two dimensions as input, we approximate our surface with triangles in 3D space. See the following examples for some source images and rendering results.

The image data loaded from the JPEG will have three intensity values for each pixel, representing red, green and blue, respectively. You may convert from color to height in any manner that you like, but be sure that all grey values (all three components have the same value) convert monotonically. The easiest way to do this is to simply pick one channel and scale it linearly, ignoring the other two.

Logistics

The goal of this assignment is to get you comfortable with working in GL, as well as get you familiar with some basic 3D programming. Our starter code is exceedingly bare, and only provides you with the basic functionality to load a JPEG image and a rudimentary implementation of the mouse control we would like you to have. You must write the code to open up a window and begin rendering, as well as setup the proper camera transformations. We recommend that you do so through GLUT, and in particular by following the information provided in your copy of OpenGL: A Primer. You are free to use any other library you choose in lieu of GLUT (fltk,gtk,etc etc), but we will likely be unable to provide any support.

Our starter code for C is available at /afs/cs.cmu.edu/academic/class/15462/src/heightfield/. If you prefer to use C++, you can find starter code at /afs/cs.cmu.edu/academic/class/15462/src/heightfield-cc/. You should make sure you can log in to the graphics cluster and compile the starter code sometime soon.

You are also free to use any language you like, but we will only actively support C and C++, and we will require that your code compile and run in the graphics cluster.

Tips

  • You should become familiar with GL's viewing transformations before you attempt to solve the rendering problem. Try with a cube or some other simple object first.
  • Don't try to do this at the last minute. This assignment is supposed to be fun and relatively easy, but time pressure has a way of ruining that notion.
  • Make sure you can log in.

Grading

Functionality Requirements:

  • Handle at least a 256x256 image for your height field at interactive frame rates (>15fps with a window size of at least 640x480).
  • Ability to render as points, lines, or filled triangles.
  • Your code must render as a perspective view, and it must utilize GL's depth buffer for hidden surface removal.
  • Use input from the mouse to spin the heightfield around using glRotate.
  • Use input from the mouse to move the heightfield around using glTranslate.
  • Use input from the mouse to change the dimensions of the heightfield using glScale.
  • Color the vertices using some smooth gradient.

Extras:

  • Experiment with material and lighting properties.
  • Allow the user to interactively deform the landscape.
  • Color the vertices based on color values taken from another image of equal size.
  • Texturemap the surface with an arbitrary image.

For the very brave:

  • Level of detail (mip mapping/trilinear) to allow heightfields of significantly higher resolution.
  • Non-rectilinear geometry (not just by wiggling the points side to side).

[ Home | Schedule | Assignments | Software | Resources ]

fp@cs
Frank Pfenning