2016-02-17 08:56:22 +11:00
|
|
|
#version 450
|
|
|
|
|
2016-03-26 03:34:21 +11:00
|
|
|
#include "common.inc"
|
2016-02-17 08:56:22 +11:00
|
|
|
|
|
|
|
#pragma stage vertex
|
|
|
|
layout(location = 0) in vec4 Position;
|
|
|
|
layout(location = 1) in vec2 TexCoord;
|
|
|
|
layout(location = 0) out vec2 vTexCoord;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2016-08-02 21:24:03 +10:00
|
|
|
gl_Position = MVP * Position;
|
2016-02-17 08:56:22 +11:00
|
|
|
vTexCoord = TexCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma stage fragment
|
|
|
|
layout(location = 0) in vec2 vTexCoord;
|
|
|
|
layout(location = 0) out vec4 FragColor;
|
2016-08-03 00:11:44 +10:00
|
|
|
layout(set = 0, binding = 1) uniform sampler2D Source;
|
2016-02-17 08:56:22 +11:00
|
|
|
|
|
|
|
#define PI 3.1415926535
|
|
|
|
|
|
|
|
float sinc(float x)
|
|
|
|
{
|
|
|
|
return sin(x) / x;
|
|
|
|
}
|
|
|
|
|
2018-07-15 08:40:56 +10:00
|
|
|
float kernel_(float x)
|
2016-02-17 08:56:22 +11:00
|
|
|
{
|
|
|
|
x = max(abs(x) * PI, 0.0001);
|
|
|
|
return sinc(x) * sinc(0.5 * x);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
float u = vTexCoord.x * global.SourceSize.x - 0.5;
|
|
|
|
float a = fract(u);
|
|
|
|
vec2 tex = vec2((floor(u) + 0.5) * global.SourceSize.z, vTexCoord.y);
|
|
|
|
|
2016-02-24 09:04:48 +11:00
|
|
|
#define TEX(x, y) textureLodOffset(Source, tex, 0.0, ivec2(x, y)).rgb
|
2016-02-17 08:56:22 +11:00
|
|
|
|
|
|
|
vec3 color =
|
2018-07-15 08:40:56 +10:00
|
|
|
kernel_(a + 1.0) * TEX(-1, 0) +
|
|
|
|
kernel_(a ) * TEX( 0, 0) +
|
|
|
|
kernel_(a - 1.0) * TEX( 1, 0) +
|
|
|
|
kernel_(a - 2.0) * TEX( 2, 0);
|
2016-02-17 08:56:22 +11:00
|
|
|
|
|
|
|
FragColor = vec4(color, 1.0);
|
|
|
|
}
|