GPU Programming for Video Games
Homework #3: Stop and Reflect
Due: Thursday, July 9 at 23:59:59 (via T-square)
Late policy: The homework will be graded out of 100 points. We will
accept late submissions up to Friday, July 10 at 23:59:59; however,
for every day that is it is overdue (including weekend days),
we will subtract 30 points from the total.
(We understand that sometimes multiple assignments hit at once, or other
life events intervene, and hence you have to make some tough choices. We’d
rather let you turn something in
late, with some points off, than have a “no late assignments
accepted at all”
policy, since the former encourages you to still do the assignment
and learn something from it, while the latter just grinds down your soul.)
homework will guide you through a series of tasks that explore various
creative possibilities of shader programming. Each task will involve modifying
code from the “GPU15 Environment Mapping Demo”
and “GPU Projective Textuing Demo”
from Sessions 12 and 13
on the class website. (On one problem, you will also want to copy & paste some
code from the “GPU15 Introductory Shaders” from Session 9.)
For each problem, you will want to create
a duplicate of the shader you are modifying so you have the original
The problems are not meant to be cumulative; i.e. if two problems ask you to
add some effect to some shader, start with a fresh copy of
the original shader for each problem so you can study each effect individually.
Use a different free model downloaded from the Unity Asset Store for
each problem. Be sure you choose models that have “base” (aka “diffuse”)
textures (this will probably be most of the available models).
As you work through the problems, paste your code and screenshots into
single Microsoft Word or PDF document.
You only need to provide
the parts of code that you modify; i.e. you don’t necessarily have to paste
in an entire function. Include enough information so
that I can tell what part of the program the line
of code you show are
included in, perhaps including a few lines of code
after to provide context.
You may use something that isn’t
Microsoft Word as long as it can output PDF files.
the GPUXXEnvMapPerPixel demo so that each pixel is lit by a linear
interpolation between the base RGB texture and the reflected cubemap,
the amount of reflection controlled by the alpha component of the base
texture (alpha = 1 being pure reflection, alpha = 0 being pure base RGB).
For this problem, be sure to choose a model that includes a “gloss map”
(also known as a “specular map”) in the alpha channel of its “base bexture.”
Also, download a cube map from somewhere (typing “cube map” into google will
yield many sources.) You will probably need to download the images for the
individual faces of the cube, create a cube map, and drag & drop the images
into appropriate places.
Use your cube map for the skybox; a skybox component should already
be attached to the camera (and is easy enough to add if it’s not).
Strip out the code related to refraction, the fresnel effect, and the
various crossfade, etaRatio, and fresnel parameter sliders. (This is good
practice for shortening your shader programs, hence making them more
Include a suitably impressive screenshot.
2) This problem will explore
Modify the GPUXXEnvMapPerPixel demo
to include three etaRatio sliders, one for red, one
for green, and one for blue. Modify the refracted color computation to use
a different etaRatio for each channel. Keep the remaining Fresnel and
reflected computations and sliders intact.
Adjust the sliders to show some
reflection around the edge of the object and a drastic prismatic effect
inside the object.
3) Modify the “GPUXXProjTex”
demo to include specular lighting and normal
For this, you will want to adapt some code snippets from
“GPUXXSpecNormMap” shader in the GPU15 Introductory Shaders package.
I recommend using a different normal map than the one that comes with your
model to emphasize the normal mapping effect; it’s OK if it looks jarring.
Carefully arrange your object and spotlight to produce a
screenshot showing off the normal mapping and specular effects.
Deliverables: Assemble your shader code and screenshots in an orderly
fashion into a single Microsoft
Word document or PDF file (using whatever tools you wish to create a PDF).
For each problem above, give the code, then give the screenshot. You only
need to show code for shaders that you modified; i.e. if you had to modify
the vertex shader but not the fragment shader, you need only show the vertex
shader (and vice-versa).
Include “HW3” and as much
as possible of your full name in the
filename, e.g., HW3_Aaron_Lanterman.doc. (The upload
procedure should be reasonably self explanatory once
you log in to T-square.)
Be sure to finish sufficiently in
advance of the deadline that you will
be able to work around any troubles
T-square gives you to successfully
submit before the deadline. If you have
trouble getting T-square to work,
please e-mail your compressed
file to Prof. Lanterman at firstname.lastname@example.org,
with “GPU HW #3” and your full
name in the header line;
use this e-mail submission as a last resort if T-square isn’t working.