# GPU 2016 — Homework #5

GPU 2016 — Homework #5

# GPU Programming for Video Games

## Due: Friday, July 22 at 5:00 PM (via T-square)

This assignment explores the specular Cook-Torrence model
consisting of a microfacet distribution term, the Fresnel term,
and a geometry term. We will leave out the diffuse term in this assignment
in order to focus on the specular term.

Many formulas have been proposed for distribution terms and
geometry terms. The differences between these different proposed terms
are usually subtle. We will begin by using various color schemes to visualize
the various terms; these will help give us a feel for how the terms
operate, and are not meant to create images shown to the player.

1)
Here, we will compare two microfacet distribution terms (usually
noted as D),
and
write a surface shader that computes those two terms, displaying
one of them as red and the other as blue.
Look at the
entries in the “Normal Disbribution Function (NDF)” section of
Brian
Karis’s Specular BRDF Reference
.
Let one of your terms
be the “Beckmann  distribution”;
you can pick between “Blinn-Phong ” (in class, we called this
“normalized modified Blinn-Phong”) and
“GGX (Trowbridge-Reitz) ” for your other term. (Note Brian uses “m”
instead of “H” for the half-vector.)

Create two roughness Range(0,1)
sliders in the Properties, one for each distribution term,
and compute alpha=roughness*roughness for each term.

Set one of your sliders somewhere near the middle, and adjust the
other slider so that most of the visible pixels are purple.
Pixels that are more reddish or bluish
then highlight the differences between the models.

Include a listing of your Surface Shader and a couple of screenshots
of your comparison shader in action. Include the slider settings in

2) Using a tool such as MATLAB, Mathematica, Excel, etc., make a plot
of your two distribution terms from Problem 1 (one Beckmann, the other
Blinn-Phong or GGX) as a function of the cosine of the
angle between the normal
vector and the half vector (i.e., n dot h, which ranges between 0 and 1).
Put both curves on the same plot
to aid in comparison.

3) Here, we will compare two visualization terms, which are geometric
distribution terms (usually denoted as G) divided by 4(n dot L)(n dot V).
Write a surface shader that computes those two terms, displaying
one of them as red and the other as blue.
Look up the
entries in the “Geometric Shadowing”
section of
Brian
Karis’s Specular BRDF Reference
. Let one of your visualization
terms
use the original “Cook-Torrence ” geometric term;
for the other visualization term,
chose the “Beckmann ” or the “GGX ”
geometric term (note that both of these
are given in terms of (n dot V); the actual G term consists of that multiplied
by a term of the same form with (n dot L) replacing (n dot V).

Create a Range (0,1)
slider in the Properties,
and compute alpha=roughness*roughness for use with your
“Beckmann ” or “GGX ” term. One criticism of the original
Cook-Torrance geometric term is that it doesn’t incorporate a roughness
parameter. Adjust your roughness slider so that most of the visible
pixels are purple.
Pixels that are more reddish or bluish
then highlight the differences between the models.

Include a listing of your Surface Shader and a couple of screenshots
of your comparison shader in action. Include the slider setting in

4) Comment on what differences you observe in the behavior of the different
models. Are they quite different, or is the differnce
barely noticable? If one took more
computations than the other, would it be worth the extra computation?

5) OK, let’s put this all together to make a metal shader.
Write a surface shader the implements the specular Cook-Torrance
model consisting of a microfacet distribution term, the Fresnel term,
and a geometry term. For your distribution term, choose from among
the terms you experimented with in Problem 1.
For the geometry term,
use either
the “Beckmann ” or “GGX ” term, whichever one you used in Problem 3.
You will have a single Roughness slider parameterizing
both the D and G expressions.
For the Fresnel term, use the Schlick approximatino from Slide 32
of the Session 16 slides. For F_0, choose one of the more “colorful”
metals on Slide 38. Don’t forget to include the
cos(n dot L) factor that arises from using a point light.

Include a listing of your Surface Shader and a couple of screenshots

Deliverables:
Assemble your answers to 1 through 5 above
into a single Microsoft Word document or PDF file
(using whatever tools you wish to create a PDF).
Include “HW5” and as much
as possible of your full name in the
filename, e.g., HW5B_Aaron_Lanterman.doc. (The upload
procedure should be reasonably self explanatory once