Skip to content

Commit

Permalink
Use FragCoord + texelFetch for blit shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
thr3343 committed Oct 6, 2024
1 parent 59ec81f commit 6e8315d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 6e8315d

Please sign in to comment.