From 93a5385cb03482d09108edef1433a9f470bf1e4a Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 5 Dec 2021 04:26:50 +0500 Subject: Added SSAO blur --- cwd/assets/altcraft/shaders/frag/blur.fs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 cwd/assets/altcraft/shaders/frag/blur.fs (limited to 'cwd/assets/altcraft/shaders/frag/blur.fs') diff --git a/cwd/assets/altcraft/shaders/frag/blur.fs b/cwd/assets/altcraft/shaders/frag/blur.fs new file mode 100644 index 0000000..b49032f --- /dev/null +++ b/cwd/assets/altcraft/shaders/frag/blur.fs @@ -0,0 +1,22 @@ +#version 330 core + +out vec4 fragColor; + +in vec2 uv; + +uniform sampler2D blurInput; +uniform int blurScale; + +void main() { + vec2 texelSize = 1.0f / vec2(textureSize(blurInput, 0)); + vec4 result = vec4(0.0f); + for (int x = -blurScale; x < blurScale; x++) + { + for (int y = -blurScale; y < blurScale; y++) + { + vec2 offset = vec2(float(x), float(y)) * texelSize; + result += texture(blurInput, uv + offset); + } + } + fragColor = result / pow(blurScale, 3); +} -- cgit v1.2.3 From 91afb55a58c4b27d0c746e64305dd1d9ad816d94 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Tue, 7 Dec 2021 21:53:02 +0500 Subject: Fixed SSAO normals --- cwd/assets/altcraft/shaders/frag/blur.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cwd/assets/altcraft/shaders/frag/blur.fs') diff --git a/cwd/assets/altcraft/shaders/frag/blur.fs b/cwd/assets/altcraft/shaders/frag/blur.fs index b49032f..89d4498 100644 --- a/cwd/assets/altcraft/shaders/frag/blur.fs +++ b/cwd/assets/altcraft/shaders/frag/blur.fs @@ -18,5 +18,5 @@ void main() { result += texture(blurInput, uv + offset); } } - fragColor = result / pow(blurScale, 3); + fragColor = result / pow(blurScale * 2.0f, 2); } -- cgit v1.2.3