CMPS 160 -- Programming Assignment 2 (shader graphics)
Due date:
12 midnight, Friday, 5/3/12
Objectives:
This assignment covers the following components:
normal calculations, lighting, diffuse and specular reflections, and shaders
Description:
This assignment will enhance your fractal terrain program.
In program 1, your fractal terrain was rendered as a wireframe.
In this program, you will get to add "skin" or surface to the terrain.
Requirements:
-
10% of functionality:
Combine lab3 and lab4 so that you can render your fractal terrain
using ambient lighting or flat shading.
Add GUI to allow user to switch between the two.
-
30% of functionality:
Implement smooth shading. With flat shading (from lab4) you
can see individual triangles when you look closely.
If we want to create an illusion of a smooth surface,
we can do so without adding geometry, but simply fooling
the eyes with smooth shading.
Smooth shading works by assigning a color to each vertex
(rather than each polygon), and interpolating the vertex colors.
To do this, you need to calculate a vertex normal (which is
averaged from adjacent surface normals sharing that vertex).
The perceived color due to diffuse reflections
at the vertices is calculated in the same
manner as the method
used for the polygon faces.
This is called smooth or Gouraud shading.
Be sure to update your GUI so that users can switch among the
different lighting options.
-
40% of functionality:
Aside from diffuse reflections,
you can make the fractal terrain appear shiny including specular reflections.
Specular reflections will very over the terrain depending on the relationships between
the surface normal, light direction, and eye direction.
You can use the Halfway Vector approach.
Include option to turn specular reflections on or off in your GUI.
Note that it's possible to have flat shading with specular reflections also.
That is, lighting calculations (ambient, diffuse or specular) is independent
from shading calculations (flat or smooth).
-
20% of functionality:
Instead of having the entire terrain have the same color (but different
shading), vary the color of the terrain by elevation.
For example, lower elevation could be green to represent vegetation.
Mid-elevations would be brown, while higher elevation could be white.
You will probably want to include some element of randomness so your
terrain doesn't end up looking like some weird 3-layer cake.
Note that this functionality is independent of lighting calculations.
That is, you can turn this height-based coloring on or off independently
of whether you are using constant or smooth shading.
-
10% bonus:
You can earn some bonus points (in addition to early bonus points)
if you implement Phong shading.
This requires interpolating vertex normals
and calculating normals at every point on the polygon.
Resource:
Grading:
This program nominally accounts for 8% of your final grade. We must
be able to compile/test your code. Make sure that the code and accompanying
make/project files, etc. are tested for successful compilation at least on
the PCs in the lab.
Also be sure to include the statically linked executable and a README file
in your submission as to which platform to use.
Programs turned in at least a full day early will earn 1% bonus credit. Late
programs will be charged a 1% late point. In addition, late programs will not
be accepted 24 hours past due date.
The bonus credits may be accumulated up to a
total of 50% toward program and final project credits. Programs are graded 80%
for functionality and correctness and 20% for style, readability,
documentation/writeup, and efficiency. Additional points may also be earned
for extra features.
Submission:
Submission must be done using the "submit" command from CATS.
- submit cmps160-ap.s13 prog2 prog2.tar, or
- submit cmps160-ap.s13 prog2 prog2.zip
This command should work from unix.ic.ucsc.edu.
Create and submit a subdirectory called prog1.
It should contain a statically linked executable and
all the files you have to make your program compile/run.
Tar or zip up prog1 before submitting.
Last modified
Thursday, 11-Apr-2013 12:18:23 PDT.