From 42bd29a989316751d96db4064559c2d4d32a06e7 Mon Sep 17 00:00:00 2001 From: CodingJellyfish Date: Sat, 18 Jan 2025 14:33:06 +0800 Subject: [PATCH] Stronger bias when resolution is lower --- data/shaders/ssao.frag | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/data/shaders/ssao.frag b/data/shaders/ssao.frag index 0efc43acc3..6b3b3b86f3 100644 --- a/data/shaders/ssao.frag +++ b/data/shaders/ssao.frag @@ -8,9 +8,7 @@ uniform float k; uniform float sigma; out float AO; -const float bias = .0005; const float thickness = 10.0; -const float horizon = 0.1; #define SAMPLES 4 const float invSamples = 0.25; // 1. / SAMPLES @@ -50,6 +48,10 @@ void main(void) float peak2 = peak * peak; float intensity = 2.0 * 3.14159 * sigma * peak * invSamples; + // Apply stronger bias when the resolution is lower. + float horizon = min(100. / min(u_screen.x, u_screen.y), 0.3); + float bias = min(1. / min(u_screen.x, u_screen.y), 0.003); + float theta = phi * 2.0 * 2.4 * 3.14159; vec2 rotations = vec2(cos(theta), sin(theta)) * u_screen; vec2 offset = vec2(cos(invSamples), sin(invSamples));