]> git.tdb.fi Git - libs/gl.git/blob - builtin_data/_ambientocclusion.glsl
Add extension file for NV_half_float
[libs/gl.git] / builtin_data / _ambientocclusion.glsl
1 const int max_samples = 32;
2
3 uniform mat4 projection_matrix;
4
5 uniform sampler2D depth;
6 uniform sampler2D occlusion;
7 uniform sampler2D rotate;
8 uniform AmbientOcclusionParams
9 {
10         mat4 inverse_projection;
11         float darkness;
12         vec3 sample_points[max_samples];
13         int n_samples;
14         float occlusion_radius;
15         float edge_depth_threshold;
16 };
17
18 #pragma MSP stage(fragment)
19 vec3 project(vec3 position)
20 {
21         if(position.z>=0.0)
22                 return vec3(0.0, 0.0, -1.0);
23         vec4 pp = projection_matrix*vec4(position, 1.0);
24         return pp.xyz/pp.w;
25 }
26
27 vec3 unproject(vec3 position)
28 {
29         vec4 upp = inverse_projection*vec4(position, 1.0);
30         return upp.xyz/upp.w;
31 }