From 6e8315d0c2f67964a9d1560176c2e9e8f871b027 Mon Sep 17 00:00:00 2001 From: thr3343 <125277899+thr3343@users.noreply.github.com> Date: Sun, 6 Oct 2024 20:38:56 +0100 Subject: [PATCH] Use FragCoord + texelFetch for blit shaders --- .../assets/vulkanmod/shaders/basic/blit/blit.fsh | 4 +--- .../assets/vulkanmod/shaders/basic/blit/blit.vsh | 9 --------- .../shaders/minecraft/core/blit_screen/blit_screen.fsh | 4 +--- .../shaders/minecraft/core/blit_screen/blit_screen.vsh | 6 ++---- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/main/resources/assets/vulkanmod/shaders/basic/blit/blit.fsh b/src/main/resources/assets/vulkanmod/shaders/basic/blit/blit.fsh index f0bcabf8e..55d2af278 100644 --- a/src/main/resources/assets/vulkanmod/shaders/basic/blit/blit.fsh +++ b/src/main/resources/assets/vulkanmod/shaders/basic/blit/blit.fsh @@ -2,12 +2,10 @@ layout(binding = 0) uniform sampler2D DiffuseSampler; -layout(location = 0) in vec2 texCoord; - layout(location = 0) out vec4 fragColor; void main() { - vec4 color = texture(DiffuseSampler, texCoord); + vec4 color = texelFetch(DiffuseSampler, ivec2(gl_FragCoord.xy), 0); // blit final output of compositor into displayed back buffer fragColor = color; diff --git a/src/main/resources/assets/vulkanmod/shaders/basic/blit/blit.vsh b/src/main/resources/assets/vulkanmod/shaders/basic/blit/blit.vsh index e0ca4b2fe..ddfd034f0 100644 --- a/src/main/resources/assets/vulkanmod/shaders/basic/blit/blit.vsh +++ b/src/main/resources/assets/vulkanmod/shaders/basic/blit/blit.vsh @@ -2,17 +2,8 @@ const vec4 pos[] = { vec4(-1, -1, 0, 1), vec4(3, -1, 0, 1), vec4(-1, 3, 0, 1) }; -#define INVERTED_UV - -#ifndef INVERTED_UV - const vec2 uv[] = { vec2(0, 1), vec2(2, 1), vec2(0, -1) }; -#else - const vec2 uv[] = { vec2(0, 0), vec2(2, 0), vec2(0, 2) }; -#endif - layout(location = 0) out vec2 outUV; void main() { - outUV = uv[gl_VertexIndex]; gl_Position = pos[gl_VertexIndex]; } \ No newline at end of file diff --git a/src/main/resources/assets/vulkanmod/shaders/minecraft/core/blit_screen/blit_screen.fsh b/src/main/resources/assets/vulkanmod/shaders/minecraft/core/blit_screen/blit_screen.fsh index be1711e59..7bcc99669 100644 --- a/src/main/resources/assets/vulkanmod/shaders/minecraft/core/blit_screen/blit_screen.fsh +++ b/src/main/resources/assets/vulkanmod/shaders/minecraft/core/blit_screen/blit_screen.fsh @@ -2,12 +2,10 @@ layout(binding = 1) uniform sampler2D DiffuseSampler; -layout(location = 0) in vec2 texCoord; - layout(location = 0) out vec4 fragColor; void main() { - vec4 color = texture(DiffuseSampler, texCoord); + vec4 color = texelFetch(DiffuseSampler, ivec2(gl_FragCoord.xy), 0); // blit final output of compositor into displayed back buffer fragColor = color; diff --git a/src/main/resources/assets/vulkanmod/shaders/minecraft/core/blit_screen/blit_screen.vsh b/src/main/resources/assets/vulkanmod/shaders/minecraft/core/blit_screen/blit_screen.vsh index e3dd01d3c..e81b09dfa 100644 --- a/src/main/resources/assets/vulkanmod/shaders/minecraft/core/blit_screen/blit_screen.vsh +++ b/src/main/resources/assets/vulkanmod/shaders/minecraft/core/blit_screen/blit_screen.vsh @@ -1,12 +1,10 @@ #version 450 layout(location = 0) in vec3 Position; -layout(location = 1) in vec2 UV; +//layout(location = 1) in vec2 UV; + -layout(location = 0) out vec2 texCoord; void main() { gl_Position = vec4(Position, 1.0); - - texCoord = UV; }