diff --git a/handheld/console-border/shader-files/border-auto-scale.slang b/handheld/console-border/shader-files/border-auto-scale.slang new file mode 100644 index 0000000..b76fbb1 --- /dev/null +++ b/handheld/console-border/shader-files/border-auto-scale.slang @@ -0,0 +1,46 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 OutputSize; + vec4 SourceSize; + vec4 OriginalSize; +} params; + +vec2 middle = vec2(0.5, 0.5); +vec2 screen_scale = params.OutputSize.xy * params.SourceSize.zw; +vec2 border_scale = vec2(800, 400) * (params.SourceSize.y / params.OriginalSize.y); + +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; + + vec2 diff = TexCoord.xy - middle; + vTexCoord = middle + diff * screen_scale; + 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)); +} diff --git a/handheld/console-border/shader-files/gb-pass-5.slang b/handheld/console-border/shader-files/gb-pass-5.slang index 8311469..74c6aa5 100644 --- a/handheld/console-border/shader-files/gb-pass-5.slang +++ b/handheld/console-border/shader-files/gb-pass-5.slang @@ -12,7 +12,7 @@ layout(push_constant) uniform Push vec2 middle = vec2(0.5, 0.5); vec2 screen_scale = params.OutputSize.xy * params.SourceSize.zw; -vec2 border_scale = vec2(800, 400) * (params.SourceSize.y / params.OriginalSize.y); +vec2 border_scale = vec2(800, 400) * params.video_scale; layout(std140, set = 0, binding = 0) uniform UBO {