CMPS 160 -- Program 2
Due date: midnight Friday, April 29, 2016
Early if time stamp is before midnight April 28, 2016.
On time if time stamp is before midnight April 29, 2016.
Late if time stamp is after midnight April 29, 2016.
Submissions turned in after midnight April 30, 2016 will not be accepted/graded.
Objectives:
Learn perspective projection, specular reflection, and smooth shading.
Description:
-
Since we have an exam scheduled this week,
this program is a little easier (some improvements over lab2 assignment).
This assumes you have a functional lab2 program.
The new things are perspective projection, smooth shading, and
associated GUI to select amongst the option.
-
In lab2, you were using an orthographic projection.
For this assignment, add an option (e.g. via a toggle button)
to switch between orthographic and perspective projection.
The slightly tricky part is figuring out reasonable
parameters for each projection. Experiment with what parameters
provide a reasonable projection (object is still centered and not
too big nor too small, and is still entirely visible).
It is fine if you hard code these parameters for this program.
-
In lab2,
you only had diffused lighting.
Here, you will add specular lighting components.
Just as you specified a material color for an object,
you will also specify a specular color for an object.
Select a different color to help you see the effects of specular lighting --
which should be some combination of specular color and light color.
Add a GUI (e.g. slider) to allow users to vary how shiny the object is.
The range should go from 1 (dull) to 20 (shiny).
Add another GUI (e.g. toggle) to turn on specular lighting on/off.
-
In lab2,
object polygons were rendered using flat shading i.e. constant color for each polygon.
Here, object polygons will need to be rendered using Gouraud shading, a form of smooth shading.
This will require that you calculate a color for each vertex and use a varying
color variable for the fragment shader.
Add an option (e.g. via a toggle button) for the user
to switch between flat vs Gouraud shading.
-
Bonus - 10 points:
This is a 2 part bonus worth 5 points each -- you can do either one for 5 points or both for 10
points.
First bonus is to add an option for Phong shading --
in addition to specifying the color at each vertex,
the other main thing is for you to also specify the normal at each vertex.
Second bonus is to add an option to render the object as a wireframe without
any polygon shading.
User can select among: wireframe only, flat shading, Gouraud shading, or Phong shading.
Reference material:
Grading:
This program will form part of your CMPS 160 grade.
Here's what I told graders about grading this assignment:
10: separate html and javascript files, both well documented
30: orthographic and perspective projection
30: specular lighting and slider
30: Gouraud shading and GUI
5: Phong shading
5: wireframe
Revised version due to changes in requirements:
10: separate html and javascript files, both well documented
40: lab2 functionality -- flat shading, centered, scaled, etc.
30: Gouraud shading
20: toggle between flat/smooth
5: Phong shading
5: wireframe
Who graded your assignment:
Daniel: aassi - dtra24
Joseph: dwmarx - kmccotte
John (Andy): kyalopez - nshariat
David: nsievers - zpeterse
Submission:
Your WebGL code is contained in two files.
An index.html file and a SmoothShade.js.
A README file can be included if appropriate.
Put both of these in a folder called prog2.
Zip up prog2 before submitting.
Submission must be done using the "submit" command from unix.ic.ucsc.edu
- submit cmps160-ap.s16 prog2 prog2.zip
Issue this command from unix.ic.ucsc.edu.
Last modified
Sunday, 01-May-2016 23:05:46 PDT.