@@ -109,6 +109,15 @@ vec3 calculateIndirectIllumination(vec3 wo, vec3 n, vec3 base_color)
|
|
109
109
|
// Task 5 - Lookup the irradiance from the irradiance map and calculate
|
110
110
|
// the diffuse reflection
|
111
111
|
///////////////////////////////////////////////////////////////////////////
|
112
|
+
vec3 world_normal = vec3(viewInverse * vec4(n, 0.0));
|
113
|
+
float theta = acos(max(-1.0f, min(1.0f, world_normal.y)));
|
114
|
+
float phi = atan(world_normal.z, world_normal.x);
|
115
|
+
if(phi < 0.0f)
|
116
|
+
phi = phi + 2.0f * PI;
|
117
|
+
vec2 lookup = vec2(phi / (2.0 * PI), 1 - theta / PI);
|
118
|
+
vec3 Li = environment_multiplier * texture(irradianceMap, lookup).rgb;
|
119
|
+
vec3 diffuse_term = base_color * (1.0 / PI) * Li;
|
120
|
+
indirect_illum = diffuse_term;
|
112
121
|
|
113
122
|
///////////////////////////////////////////////////////////////////////////
|
114
123
|
// Task 6 - Look up in the reflection map from the perfect specular
|