const int max_samples = 32; uniform mat4 projection_matrix; uniform sampler2D depth; uniform sampler2D occlusion; uniform sampler2D rotate; uniform AmbientOcclusionParams { mat4 inverse_projection; float darkness; vec3 sample_points[max_samples]; int n_samples; float occlusion_radius; }; #pragma MSP stage(fragment) vec3 project(vec3 position) { 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; }