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