mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-25 08:51:32 +11:00
52 lines
1.3 KiB
Plaintext
52 lines
1.3 KiB
Plaintext
#version 450
|
|
|
|
layout(push_constant) uniform Push
|
|
{
|
|
vec4 OutputSize;
|
|
vec4 SourceSize;
|
|
vec4 OriginalSize;
|
|
float video_scale;
|
|
float border_texture_scale;
|
|
} params;
|
|
|
|
#pragma parameter video_scale "Video Scale" 3.0 2.0 20.0 1.0
|
|
#pragma parameter border_texture_scale "Border Scale" 4.0 1.0 20.0 0.005
|
|
|
|
vec2 middle = vec2(0.5, 0.5);
|
|
vec2 border_scale = vec2(3200, 1600) * params.video_scale / params.border_texture_scale;
|
|
|
|
layout(std140, set = 0, binding = 0) uniform UBO
|
|
{
|
|
mat4 MVP;
|
|
} global;
|
|
|
|
#pragma stage vertex
|
|
layout(location = 0) in vec4 Position;
|
|
layout(location = 1) in vec2 TexCoord;
|
|
layout(location = 0) out vec2 vTexCoord;
|
|
layout(location = 1) out vec2 tex_border;
|
|
|
|
void main()
|
|
{
|
|
gl_Position = global.MVP * Position;
|
|
|
|
vTexCoord = TexCoord.xy;
|
|
|
|
vec2 diff = TexCoord.xy - middle;
|
|
tex_border = middle + diff * params.OutputSize.xy / border_scale;
|
|
}
|
|
|
|
#pragma stage fragment
|
|
layout(location = 0) in vec2 vTexCoord;
|
|
layout(location = 1) in vec2 tex_border;
|
|
layout(location = 0) out vec4 FragColor;
|
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
|
layout(set = 0, binding = 3) uniform sampler2D BORDER;
|
|
|
|
void main()
|
|
{
|
|
vec4 frame = texture(Source, vTexCoord).rgba;
|
|
vec4 border = texture(BORDER, tex_border).rgba;
|
|
FragColor = vec4(mix(frame, border, border.a));
|
|
}
|