--- /dev/null
+import cubemap_effect;
+import _pbr_prefilter;
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec3 frag_color;
+void main()
+{
+ vec3 normal = normalize(texcoord);
+ vec3 tangent = normalize(abs(normal.x)>abs(normal.y) ? vec3(-normal.z, 0.0, normal.x) : vec3(0.0, -normal.z, normal.y));
+ mat3 orientation = mat3(tangent, cross(normal, tangent), normal);
+
+ vec3 sum = vec3(0.0);
+ for(int i=0; i<n_samples; ++i)
+ {
+ vec2 uv = hammersley(i, n_samples);
+ vec3 dir = orientation*uv_to_hemisphere(uv.x, sqrt(1.0-uv.y));
+ sum += textureLod(environment_map, dir, 0).rgb;
+ }
+
+ frag_color = sum/n_samples;
+}