
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

This assignment involves familiarization with illumination and shading. The assignment web-page is at www.cs.umd.edu/class/fall2004/cmsc427/assg4/.
(a) Set up a directional light source to represent the Sun at any point in the sky. The Sun should illuminate all geometry except for the sky box. Set up the material parameters for the Humvee so that it has both specular and diffuse colors. The trees and the terrain only need diffuse colors. Have OpenGL do specular and diffuse lighting on the Humvee using the per-vertex normals given with the
normalize all the normals you give it. Have the lighting and the textures blend using OpenGL’s GL_MODULATE function. You can get better-looking specular highlights on textured Humvee by using GL_SEPARATE_SPECULAR_COLOR. Point distribution: 1 point for any kind of lighting, 1 point for per-vertex lighting, 2 points for normal-based per-vertex lighting, 1 point for blending textures with lighting. (5 points)
(b) Next have the Sun continuously rotate about the origin of the sky box. Set up the speed of rotation to be slow but perceptible (say, once every 60 seconds). Have the intensity of the Sun and the brightness of the sky box increase the closer it is to being noon. (2 points)
(c) Implement headlights for the Humvee using spotlights. Allow the user to toggle the headlights on and off using the
(d) Implement Humvee and tree shadows on the terrain as follows. Use a shadow-projection matrix to cast the shadows on the x-z plane. Remember that OpenGL stores its matrices in the column major
Pressing the key should toggle the display of the shadow back buffer. For every pixel of the 64
covered by a shadow triangle. Use this weighted average value to darken the corresponding vertex of the terrain accordingly. Simplify the casting of shadows by ignoring the effects of the terrain height. During shadow determination, simply assume that the terrain height and the geometry is at y = 0 , determine the terrain vertices covered by the shadow, and then darken them at the appropriate height during final rendering. Point distribution: 3 points for displaying shadow back buffer; 2 points for displaying shadows. (5 points)
(e) Randomly distribute 20 or so spheres (you can use gluSphere here) over the terrain. Initially make the spheres red and large. Every time the Humvee hits a red sphere, the sphere should turn blue and shrink. Show the score at the top of the window. You can use a glutBitmapCharacter or a glutStrokeCharacter to display fonts in a GLUT window. Every time the Humvee hits a sphere the user gets 5 points and every time a tree is hit, the user loses 5 points. For the purposes of this assignment you can do the collisions by a simple distance check along the x-z plane between the origin of the Humvee and the origin of the tree or sphere. Point distribution: 1 point for placing and drawing the spheres, 2 points for collisions and having the trees fall and spheres change, 2 points for showing the score. (5 points)