@@ -290,6 +290,7 @@ void initialize()
|
|
290
290
|
changeScene("Ship");
|
291
291
|
//changeScene("Material Test");
|
292
292
|
//changeScene("Cube");
|
293
|
+
changeScene("Material Test");
|
293
294
|
}
|
294
295
|
|
295
296
|
void debugDrawLight(const glm::mat4& viewMatrix,
|
@@ -80,6 +80,17 @@ vec3 calculateDirectIllumiunation(vec3 wo, vec3 n, vec3 base_color)
|
|
80
80
|
// Task 2 - Calculate the Torrance Sparrow BRDF and return the light
|
81
81
|
// reflected from that instead
|
82
82
|
///////////////////////////////////////////////////////////////////////////
|
83
|
+
vec3 wh = normalize(wi + wo);
|
84
|
+
float ndotwh = max(0.0001, dot(n, wh));
|
85
|
+
float ndotwo = max(0.0001, dot(n, wo));
|
86
|
+
float wodotwh = max(0.0001, dot(wo, wh));
|
87
|
+
float D = ((material_shininess + 2) / (2.0 * PI)) * pow(ndotwh, material_shininess);
|
88
|
+
float G = min(1.0, min(2.0 * ndotwh * ndotwo / wodotwh, 2.0 * ndotwh * ndotwi / wodotwh));
|
89
|
+
float F = material_fresnel + (1.0 - material_fresnel) * pow(1.0 - wodotwh, 5.0);
|
90
|
+
float denominator = 4.0 * clamp(ndotwo * ndotwi, 0.0001, 1.0);
|
91
|
+
float brdf = D * F * G / denominator;
|
92
|
+
|
93
|
+
return brdf * dot(n, wi) * Li;
|
83
94
|
|
84
95
|
///////////////////////////////////////////////////////////////////////////
|
85
96
|
// Task 3 - Make your shader respect the parameters of our material model.
|