Assignment 4 is due at 5 p.m. Friday, October 12.
It is worth 20 points.
Procedures
E-mail
answers to the exercises below to
ggchappell@alaska.edu,
using the subject
“GA4”.
Your answers should consist of the source code for the
shaders for Exercise A and the application for Exercise B.
These should be attached to your e-mail message.
Send only the above!
I do not want project files or executables.
I also do not want things I already have, like glut.h.
Be sure to include your name in your e-mail.
I may not read your homework e-mail immediately.
If you wish to discuss the assignment (or anything else)
with me, send me a separate message with a different subject line.
Exercises (20 pts total)
Exercise A — Writing Shaders
Purpose
In this exercise, you will write a pair of shaders
in GLSL.
Instructions
Write a vertex shader and a fragment shader
for use with the application
useshaders.cpp
(this requires the header
glslprog.h
to be in your
lib381 subdirectory).
Store your vertex shader source in a file named
SOMETHING_v.glsl
and your fragment-shader should in a file named
SOMETHING_f.glsl,
where “SOMETHING” is chosen by you,
and is the same for both files.
Comment your shaders appropriately
(who wrote them, when were they written,
were they based on someone else’s code?).
Your shaders should do the following.
A fog effect:
change the color so that it becomes closer to the background color
the farther an object is from the camera.
The farthest cubes in the cube-array option
of the application should be invisible, or nearly so.
Hint: You will need to base your color change on the
\(z\)-coordinate in camera coordinates.
You want the \(z\)-coordinate after applying model/view
but before applying projection.
Further, this needs to be the \(z\)-component of a vec3,
not a vec4.
Some other significant effect.
What you do is up to you,
but it should be noticeable,
and it should not appear to be a bug.
Note: You do not need to be fancy here.
But of course, you can be if you want.
Do not modify useshaders.cpp.
Exercise B — Animated Hierarchical Object
Purpose
In this exercise, you will write an OpenGL/GLUT program
that allows interaction with an animated 3-D hierarchical object.
Instructions
Write an OpenGL program that meets the following requirements.
The program must be in C or C++ and produce graphical output using OpenGL.
The program must be GLUT-based, following the rules for callbacks discussed in class.
The program must render an interactive, animated 3-D scene,
viewed in perspective with proper HSR
(“done properly”, as always).
The scene must include at least one animated hierarchical object
at least three levels deep
(i.e., a moving object with moving parts that have moving parts).
For example, the arm in
arm.cpp
is three levels deep.
The user must be able to interact with the display
in some reasonably interesting way (manipulating objects,
moving through the scene, etc.).
Your program must include significant original content,
both in the scene displayed, and in the user interface.
(Note: “original” means that you designed wrote it yourself,
not that it is new & exciting.)
Notes
You are not expected to make use of shaders
in Exercise B.
Standards for code are as for
the first assignment
(must compile, readable, following conventions,
avoid extra output,
clear how program is used, not buggy-looking, give credit, etc.).