From b8f57be9c90187a648c4c190630050a142d00d42 Mon Sep 17 00:00:00 2001 From: nfp0 Date: Tue, 3 May 2022 19:33:53 +0100 Subject: [PATCH] Make scaling a single parameter affair on handheld border shaders --- .../shader-files/gb-pass-5.slang | 22 ++++++++----------- .../shader-files/gb-pass0.slang | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/handheld/console-border/shader-files/gb-pass-5.slang b/handheld/console-border/shader-files/gb-pass-5.slang index ba3ae7f..247b949 100644 --- a/handheld/console-border/shader-files/gb-pass-5.slang +++ b/handheld/console-border/shader-files/gb-pass-5.slang @@ -4,14 +4,14 @@ layout(push_constant) uniform Push { vec4 OutputSize; vec4 SourceSize; - float SCALE; - float OUT_X; - float OUT_Y; + float video_scale; } params; -#pragma parameter SCALE "Box Scale" 0.6667 0.6667 1.5 0.33333 -#pragma parameter OUT_X "Out X" 1600.0 1600.0 4800.0 8000.0 -#pragma parameter OUT_Y "Out Y" 800.0 800.0 2400.0 400.0 +#pragma parameter video_scale "Video Scale" 3.0 2.0 20.0 1.0 + +vec2 middle = vec2(0.5, 0.5); +vec2 screen_scale = params.OutputSize.xy * params.SourceSize.zw; +vec2 border_scale = vec2(800, 400) * params.video_scale; layout(std140, set = 0, binding = 0) uniform UBO { @@ -27,14 +27,10 @@ layout(location = 1) out vec2 tex_border; void main() { gl_Position = global.MVP * Position; - vec2 scale = (params.OutputSize.xy * params.SourceSize.zw) / params.SCALE; - vec2 middle = vec2(0.5, 0.5); - vec2 diff = TexCoord.xy - middle; - vTexCoord = middle + diff * scale; - middle = vec2(0.5, 0.5); - vec2 dist = TexCoord - middle; - tex_border = middle + dist * params.OutputSize.xy / vec2(params.OUT_X, params.OUT_Y); + vec2 diff = TexCoord.xy - middle; + vTexCoord = middle + diff * screen_scale; + tex_border = middle + diff * params.OutputSize.xy / border_scale; } #pragma stage fragment diff --git a/handheld/console-border/shader-files/gb-pass0.slang b/handheld/console-border/shader-files/gb-pass0.slang index eaed2fe..f0bdaad 100644 --- a/handheld/console-border/shader-files/gb-pass0.slang +++ b/handheld/console-border/shader-files/gb-pass0.slang @@ -33,7 +33,7 @@ layout(std140, set = 0, binding = 0) uniform UBO #pragma parameter response_time "LCD Response Time" 0.20 0.0 0.777 0.111 // Set video scale when used in console-border shaders -#pragma parameter video_scale "Video Scale" 3.0 3.0 5.0 1.0 +#pragma parameter video_scale "Video Scale" 3.0 2.0 20.0 1.0 /////////////////////////////////////////////////////////////////////////// // //