CPSC 4050 / 6050

Spring 2014

Looking a Bit Shady

Homework Assignment 3

Due: Thursday, February 20, 2014

        ortho side view of spheres

Orthographic Side View of the Spheres with Shading

Problem Description:

You are to upgrade your raycasting renderer from Programming Project 2 by including lighting, shading, and camera control. All of the sphere positions and sizes should be the same as in the previous assignment, but now your scene should have two lights. One should be a parallel light source, simulating the sun, as if it were at 60o from the horizontal (the x-z plane), shining into the scene from right to left at 45o from the z-axis. The second should be a point light source, simulating a light bulb, located at (-1, 1, 0.25). Make the sun pale yellow of color (0.8, 0.8, 0.2), and make the light bulb pale blue of color (0.4, 0.4, 0.8).

The five spheres should be the same color as in the previous homework, but each should have different material characteristics. Make the red and purple balls completely matte, with no specular. Make the green ball very shiny with a small specular highlight, and very little diffuse. And, make the blue and orange balls intermediate between shiny and matte and with a broad specular highlight. Once you get the program working, experiment with different values for your material characteristics until you get a picture that you think looks interesting.

The program should read camera parameters from a parameter file camera.txt. This file should contain the viewpoint, view direction, and up direction. It should also contain viewing parameters focal length (distance to viewscreen), screen aspect ratio (width/height), and screen width (in modeling coordinates). This can be a simple text file with the 12 required numbers in a fixed order.

Basic Requirements:

Your program should be named shady. The program should be able to render and display a projection of the scene, and should allow a variable pixmap size for rendering the scene. The program command line should have the format (note: the square brackets denote optional arguments; they should not be included on the command line.):

shady [l|v][pixwidth][filename.ext]

where l indicates parallel projection viewing, v indicates perspective projection viewing, and pixwidth is a positive integer denoting the width of the pixmap in pixels. The default viewing option is v and the default pixel width is 250. If filename is provided, the image should be saved to an image file with this name, when the user presses the w key, using the filename extension given by ext to determine image file type. Pressing the w key should do nothing if no filename is provided. The program should quit when the user presses either the q or the ESC key.

You should test your program by rendering very small images. Once the program is working try a higher resolution of at least 750 x 600 pixels and save this image.

Advanced Extensions:

1. Antialias the rendered scene by adaptively supersampling pixels. This will require that you shoot multiple rays per pixel, adding additional rays when required.

2. Include rectangular solids in the scene that can be oriented arbitrarily, and compute shading for these also.

Expected Output:

Here is what the output of the basic assignment should look like in perspective view, using the camera parameters from the previous assignment. This includes five planes to make an open box, and uses nine samples per pixel to achieve antialiasing:

example image


Please write the program in C++ , using OpenGL and GLUT graphics routines for the display. Make sure to put a header in each file of your code that gives a description of the program or object, your name, the date, and instructions on how it is used.