]> git.tdb.fi Git - libs/gl.git/blobdiff - builtin_data/_ambientocclusion.glsl
Take ambient occlusion samples only from the forward hemisphere
[libs/gl.git] / builtin_data / _ambientocclusion.glsl
index 81aac182acb4683412d429d7d33b58938bdd1722..4cc74e18c26962f5db7b10a238d38a9cf8f0ba36 100644 (file)
@@ -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);
+}