/usr/class/cs248/assignments/assignment4/setup
Please do not change any of the source files for the viewer. The submit script will not be submitting any of the viewer's source files, so we will not see any changes you make. The file shader.c contains stub functions that you should replace with your own functions, as described below.
To start the viewer after making it, type:
./viewer [ -single | -double ] config-file
where config-file is the name of a configuration file. Specifying -single uses single buffering, and -double uses double buffering. On the machines in Sweet Hall, use -single if you plan to save the image you render, since your rendering will not appear in 24-bit color in double buffering mode.
The configuration file specifies the layout of the scene, including which object to display, the location of the viewer and the light sources, and any parameters you wish to specify to your shading functions. For now, use the sample configuration file, sample.cfg.
See the web page on configuration files for more information on the format and content of these files.
Once the viewer has started, the mouse buttons do the following:
Using the menu, you can select the lights and rotate those independently of the object.
Button Function Left Rotates the object Middle Scales the object Right Accesses the menu
Aside from the viewer itself, we provide a number of routines that you will almost certainly want to take advantage of:
As described earlier, the configuration file mechanism allows you to specify paramaters to your shading functions. We provide several routines for accessing the contents of the configuration files, and we strongly suggest that you make use of them. The routines will make it easy for you to change the parameters of your shading functions without recompiling. The file param.h contains descriptions of functions that you can use to retrieve parameters from these configuration files, and our example setup function shows how you might go about using a few of these routines. The shader.c file we provide to you also gives a few examples of how you might go about using these routines.
Don't forget to see the web page on configuration files, which includes a list of pre-defined variable names that can appear in the these files.
In order for your shaders to compute the color of each vertex, you'll need some information about the object at each of those vertices, as well as some information about the environment surrounding the object. This information is computed for you and stored into a set of global variables that are documented in shader.h.
Finally, to assist you with generating your wood texture, we provide you with an implementation of Perlin's noise function, FBm(). The FBm() function is described in the file mnoise.h.
Your shading function has access to the information about the scene specified in shader.h. The various information is documented in that file. Your shading function takes as a parameter a floating-point array of length 3, into which it should put the RGB color value it computes (minimum intensity is zero maximum intensity is one).
hanrahan@cs.stanford.edu