4 #pragma MSP stage(fragment)
5 layout(location=0) out vec3 frag_color;
8 vec3 normal = normalize(texcoord);
9 vec3 tangent = normalize(abs(normal.x)>abs(normal.y) ? vec3(-normal.z, 0.0, normal.x) : vec3(0.0, -normal.z, normal.y));
10 mat3 orientation = mat3(tangent, cross(normal, tangent), normal);
13 for(int i=0; i<n_samples; ++i)
15 vec2 uv = hammersley(i, n_samples);
16 vec3 dir = orientation*uv_to_hemisphere(uv.x, sqrt(1.0-uv.y));
17 sum += textureLod(environment_map, dir, 0).rgb;
20 frag_color = sum/n_samples;