Mess with AO calc

This commit is contained in:
2025-11-19 15:56:21 +01:00
parent 58cf0ad068
commit d3e3090cc5
+17 -11
View File
@@ -7,6 +7,8 @@
#define tau 6.28318530717958647692 #define tau 6.28318530717958647692
#define AO_ENABLE 1
layout(location = 0) in vec2 v_pos; layout(location = 0) in vec2 v_pos;
layout(input_attachment_index = 0, set = 2, binding = 0) uniform usubpassInput u_material; 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 getOcclusion(vec3 p, vec3 n) {
float ao = 0.0; float ao = 0.0;
//for (uint i = 1; i < AO_MAX_ITER; i++) { #if AO_ENABLE
// hash = pcg4d(hash); for (uint i = 1; i < AO_MAX_ITER; i++) {
// vec3 point = getPointOnSphere(vec2(floatConstruct(hash.x), floatConstruct(hash.y))) * AO_STEP; hash = pcg4d(hash);
// float dist = dot(point, n); vec3 point = getPointOnSphere(vec2(floatConstruct(hash.x), floatConstruct(hash.y))) * AO_STEP * i;
// if (dist < 0) { float dist = dot(point, n);
// dist = abs(dist); if (dist < 0) {
// point += n * dist * 2.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); }
//} ao += max((dist - scene(vec4(p + point, camera_uniforms.campos_and_time.w))) / dist, 0.0);
}
#endif
return 1.0 - ao * AO_INTENSITY; return 1.0 - ao * AO_INTENSITY;
} }
@@ -114,7 +118,9 @@ void main() {
discard; 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; float depth = subpassLoad(u_depth).x;
if (depth == 1.0) { if (depth == 1.0) {