Mess with AO calc
This commit is contained in:
+17
-11
@@ -7,6 +7,8 @@
|
||||
|
||||
#define tau 6.28318530717958647692
|
||||
|
||||
#define AO_ENABLE 1
|
||||
|
||||
layout(location = 0) in vec2 v_pos;
|
||||
|
||||
layout(input_attachment_index = 0, set = 2, binding = 0) uniform usubpassInput u_material;
|
||||
@@ -95,16 +97,18 @@ const uint AO_MAX_ITER = 10;
|
||||
|
||||
float getOcclusion(vec3 p, vec3 n) {
|
||||
float ao = 0.0;
|
||||
//for (uint i = 1; i < AO_MAX_ITER; i++) {
|
||||
// hash = pcg4d(hash);
|
||||
// vec3 point = getPointOnSphere(vec2(floatConstruct(hash.x), floatConstruct(hash.y))) * AO_STEP;
|
||||
// float dist = dot(point, n);
|
||||
// if (dist < 0) {
|
||||
// dist = abs(dist);
|
||||
// point += n * dist * 2.0;
|
||||
// }
|
||||
// ao += max((dist - scene(vec4(p + point, camera_uniforms.campos_and_time.w))) / dist, 0.0);
|
||||
//}
|
||||
#if AO_ENABLE
|
||||
for (uint i = 1; i < AO_MAX_ITER; i++) {
|
||||
hash = pcg4d(hash);
|
||||
vec3 point = getPointOnSphere(vec2(floatConstruct(hash.x), floatConstruct(hash.y))) * AO_STEP * i;
|
||||
float dist = dot(point, n);
|
||||
if (dist < 0) {
|
||||
dist = abs(dist);
|
||||
point += n * dist * 2.0;
|
||||
}
|
||||
ao += max((dist - scene(vec4(p + point, camera_uniforms.campos_and_time.w))) / dist, 0.0);
|
||||
}
|
||||
#endif
|
||||
return 1.0 - ao * AO_INTENSITY;
|
||||
}
|
||||
|
||||
@@ -114,7 +118,9 @@ void main() {
|
||||
discard;
|
||||
}
|
||||
|
||||
//hash = uvec4(v_pos.x * 374799253, v_pos.y * 615653626, camera_uniforms.campos_and_time.w * 626228781, 713668633);
|
||||
#if AO_ENABLE
|
||||
hash = uvec4((v_pos.x + 1.0) * 374799253, (v_pos.y + 1.0) * 615653626, camera_uniforms.campos_and_time.w * 626228781, 713668633);
|
||||
#endif
|
||||
|
||||
float depth = subpassLoad(u_depth).x;
|
||||
if (depth == 1.0) {
|
||||
|
||||
Reference in New Issue
Block a user