improve ssao

This commit is contained in:
MihailRis 2025-07-03 20:12:11 +03:00
parent 96a94aa33c
commit a9652327f1

View File

@ -1,11 +1,15 @@
vec4 effect() { vec4 effect() {
float ssao = 0.0; float ssao = 0.0;
for (int y = -1; y <= 1; y++) { float z = texture(u_position, v_uv).z;
for (int x = -1; x <= 1; x++) { for (int y = -2; y <= 2; y++) {
for (int x = -2; x <= 2; x++) {
vec2 offset = vec2(x, y) / u_screenSize; vec2 offset = vec2(x, y) / u_screenSize;
ssao += texture(u_ssao, v_uv + offset * 2.0).r; if (abs(z - texture(u_position, v_uv + offset * 2.0).z) > 0.05)
ssao += 1.0;
else
ssao += texture(u_ssao, v_uv + offset * 2.0).r;
} }
} }
ssao /= 9.0; ssao /= 24.0;
return vec4(texture(u_screen, v_uv).rgb * mix(1.0, ssao, 1.0), 1.0); return vec4(texture(u_screen, v_uv).rgb * mix(1.0, ssao, 1.0), 1.0);
} }