Skip to content

Commit 52cc289

Browse files
committed
Use FragCoord + texelFetch for blit shaders
1 parent 10a71a5 commit 52cc289

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

src/main/resources/assets/vulkanmod/shaders/basic/blit/blit.fsh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
layout(binding = 0) uniform sampler2D DiffuseSampler;
44

5-
layout(location = 0) in vec2 texCoord;
6-
75
layout(location = 0) out vec4 fragColor;
86

97
void main() {
10-
vec4 color = texture(DiffuseSampler, texCoord);
8+
vec4 color = texelFetch(DiffuseSampler, ivec2(gl_FragCoord.xy), 0);
119

1210
// blit final output of compositor into displayed back buffer
1311
fragColor = color;
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#version 450
22

33
const vec4 pos[] = { vec4(-1, -1, 0, 1), vec4(3, -1, 0, 1), vec4(-1, 3, 0, 1) };
4-
const vec2 uv[] = { vec2(0, 1), vec2(2, 1), vec2(0, -1) };
54

65
layout(location = 0) out vec2 outUV;
76

87
void main() {
9-
outUV = uv[gl_VertexIndex];
108
gl_Position = pos[gl_VertexIndex];
119
}

src/main/resources/assets/vulkanmod/shaders/minecraft/core/blit_screen/blit_screen.fsh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
layout(binding = 1) uniform sampler2D DiffuseSampler;
44

5-
layout(location = 0) in vec2 texCoord;
6-
75
layout(location = 0) out vec4 fragColor;
86

97
void main() {
10-
vec4 color = texture(DiffuseSampler, texCoord);
8+
vec4 color = texelFetch(DiffuseSampler, ivec2(gl_FragCoord.xy), 0);
119

1210
// blit final output of compositor into displayed back buffer
1311
fragColor = color;
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#version 450
22

33
layout(location = 0) in vec3 Position;
4-
layout(location = 1) in vec2 UV;
4+
//layout(location = 1) in vec2 UV;
5+
56

6-
layout(location = 0) out vec2 texCoord;
77

88
void main() {
99
gl_Position = vec4(Position, 1.0);
10-
11-
texCoord = UV;
1210
}

0 commit comments

Comments
 (0)