-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move texel shift logic from fragment shader to vertex shader.
Separate checkerboard and blur quad shaders. Add specialization to vertex shader.
- Loading branch information
Showing
11 changed files
with
111 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#version 450 | ||
|
||
#define N 15 // odd | ||
|
||
layout(constant_id = 0) const bool c_horzPass = true; | ||
|
||
layout(binding = 0) uniform sampler2D img; | ||
|
||
layout(location = 0) out vec4 oTexCoord; // u, v, du, dv | ||
out gl_PerVertex { | ||
vec4 gl_Position; | ||
}; | ||
|
||
void main() | ||
{ | ||
vec2 quad[4] = vec2[]( | ||
// top | ||
vec2(-1.,-1.), // left | ||
vec2( 1.,-1.), // right | ||
// bottom | ||
vec2(-1., 1.), // left | ||
vec2( 1., 1.) // right | ||
); | ||
gl_Position = vec4(quad[gl_VertexIndex], 0., 1.); | ||
oTexCoord.xy = gl_Position.xy * .5 + .5; | ||
oTexCoord.zw = 1./textureSize(img, 0); | ||
const int n = N >> 1; | ||
if (c_horzPass) | ||
{ | ||
oTexCoord.x -= n * oTexCoord.z; | ||
oTexCoord.w = 0.; // dv | ||
} | ||
else | ||
{ | ||
oTexCoord.y -= n * oTexCoord.w; | ||
oTexCoord.z = 0.; // du | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#version 450 | ||
|
||
layout(constant_id = 0) const bool c_ping = true; | ||
|
||
layout(binding = 0) uniform sampler2D img; | ||
|
||
layout(location = 0) out vec2 oTexCoord; | ||
out gl_PerVertex { | ||
vec4 gl_Position; | ||
}; | ||
|
||
void main() | ||
{ | ||
vec2 quad[4] = vec2[]( | ||
// top | ||
vec2(-1.,-1.), // left | ||
vec2( 1.,-1.), // right | ||
// bottom | ||
vec2(-1., 1.), // left | ||
vec2( 1., 1.) // right | ||
); | ||
const vec2 off = 0.5/textureSize(img, 0); // half texel offset | ||
gl_Position = vec4(quad[gl_VertexIndex], 0., 1.); | ||
oTexCoord = gl_Position.xy * .5 + .5; | ||
oTexCoord += c_ping ? off : -off; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters