]> git.tdb.fi Git - libs/gl.git/blobdiff - builtin_data/_ambientocclusion.glsl
Add support for integer vertex attributes
[libs/gl.git] / builtin_data / _ambientocclusion.glsl
index 81aac182acb4683412d429d7d33b58938bdd1722..ecdaed7a46256e1101cc5b332d8ad2001f6b499c 100644 (file)
@@ -1,4 +1,4 @@
-const int max_samples = 32;
+const int max_samples = 128;
 
 uniform CameraTransform
 {
@@ -35,3 +35,15 @@ vec3 unproject(vec3 position)
        vec4 upp = eye_clip_matrix*vec4(position, 1.0);
        return upp.xyz/upp.w;
 }
+
+vec3 get_fragment_position(vec2 tc)
+{
+       return unproject(vec3(tc*2.0-1.0, texture(depth, tc).r));
+}
+
+vec3 get_slope(vec3 a, vec3 x, vec3 b)
+{
+       float dz1 = abs(x.z-a.z);
+       float dz2 = abs(b.z-x.z);
+       return (dz1>2.0*dz2 ? b-x : dz2>2.0*dz1 ? x-a : b-a);
+}