# GPU Programming for Video Games

## Summer 2016

## Homework #5: Physically-Based Rendering

## 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 [3] distribution”;

you can pick between “Blinn-Phong [2]” (in class, we called this

“normalized modified Blinn-Phong”) and

“GGX (Trowbridge-Reitz) [4]” 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

your screenshot.

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 [11]” geometric term;

for the other visualization term,

chose the “Beckmann [4]” or the “GGX [4]”

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 [4]” or “GGX [4]” 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

your screenshot.

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 [4]” or “GGX [4]” 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

showing your shader in action.

**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

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 #5B” 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.