GPU 2014 — Homework #3

GPU 2014 — Homework #3

GPU Programming for Video Games

Summer 2014

Homework #3: Stop and Reflect

Due: Tuesday, July 1 at 23:59:59 (via T-square)


Late policy: The homework will be graded out of 80 points. We will
accept late submissions up to Wednesday, July 2 at 23:59:59; however,
for every day that is it is overdue (including weekend days),
we will subtract 20 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.)



This
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 “GPUXXEnvMapShaders” and “GPUProjTexShaders” demos
under Sessions 11 and 12
on the class website. (On one problem, you will also want to copy & paste some
code from the “GPUXXIntroShaders” demo.)


For each problem, you will want to create
a duplicate of the shader you are modifying so you have the original
shader available.
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
a
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
before or
after to provide context.
You may use something that isn’t
Microsoft Word as long as it can output PDF files.


1) (20 points)
Modify the GPUXXEnvMapPerPixel demo so that each pixel is lit by a linear
interpolation between the base RGB texture and the reflected cubemap,

with
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 (found under the “camera”).


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
efficient).


Include a suitably impressive screenshot.


2) (20 points)
This problem will explore
chromatic dispersion.

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) (40 points)
Modify the “GPUXXProjTex”
demo to include specular lighting and normal
mapping.

For this, you will want to adapt some code snippets from
“GPUXXSpecNormMap” shader in the GPUXX Intro 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 lanterma@ece.gatech.edu,
with “GPU HW #3” and your full
name in the header line;
please only
use this e-mail submission as a last resort if T-square isn’t working.