+const int max_samples = 32;
+
+uniform mat4 projection_matrix;
+
uniform sampler2D depth;
uniform sampler2D occlusion;
uniform sampler2D rotate;
uniform AmbientOcclusionParams
{
- vec2 screen_size;
- vec2 depth_ratio;
+ mat4 inverse_projection;
float darkness;
+ vec3 sample_points[max_samples];
+ int n_samples;
+ float occlusion_radius;
+ float edge_depth_threshold;
};
+
+#pragma MSP stage(fragment)
+vec3 project(vec3 position)
+{
+ if(position.z>=0.0)
+ return vec3(0.0, 0.0, -1.0);
+ vec4 pp = projection_matrix*vec4(position, 1.0);
+ return pp.xyz/pp.w;
+}
+
+vec3 unproject(vec3 position)
+{
+ vec4 upp = inverse_projection*vec4(position, 1.0);
+ return upp.xyz/upp.w;
+}