From 7b250e6e2a550e7d7dd291d54dbb76de43e9decf Mon Sep 17 00:00:00 2001 From: hunterk Date: Wed, 17 Aug 2016 09:05:19 -0500 Subject: [PATCH] add some parameters to work better with console-borders --- .../shaders/gameboy/shader-files/gb-pass0.slang | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/handheld/shaders/gameboy/shader-files/gb-pass0.slang b/handheld/shaders/gameboy/shader-files/gb-pass0.slang index d487dcc..3df81bd 100644 --- a/handheld/shaders/gameboy/shader-files/gb-pass0.slang +++ b/handheld/shaders/gameboy/shader-files/gb-pass0.slang @@ -8,6 +8,8 @@ layout(push_constant) uniform Push vec4 OriginalHistorySize1; float baseline_alpha; float response_time; + float console_border_enable; + float video_scale; } registers; layout(std140, set = 0, binding = 0) uniform UBO @@ -27,6 +29,12 @@ layout(std140, set = 0, binding = 0) uniform UBO // Higher values result in longer color transition periods - [0, 1] #pragma parameter response_time "LCD Response Time" 0.333 0.0 0.777 0.111 +// Change scaling to enable use in console-border shaders +#pragma parameter console_border_enable "Console-Border Enable" 0.0 0.0 1.0 1.0 + +// Set video scale when used in console-border shaders +#pragma parameter video_scale "Video Scale" 3.0 3.0 5.0 1.0 + /////////////////////////////////////////////////////////////////////////// // // // Gameboy Classic Shader v0.2.2 // @@ -65,21 +73,24 @@ layout(location = 3) out vec2 one_texel; // Largest integer scale of input video that will fit in the current output (y axis would typically be limiting on widescreens) -#define video_scale floor(registers.OutputSize.y * registers.SourceSize.w) +//#define video_scale floor(registers.OutputSize.y * registers.SourceSize.w) <- moved to parameter // Size of the scaled video -#define scaled_video_out (registers.SourceSize.xy * vec2(video_scale)) +//#define scaled_video_out (registers.SourceSize.xy * vec2(video_scale)) <- moved to parameter //it's... half a pixel #define half_pixel (vec2(0.5) * registers.OutputSize.zw) void main() { + float video_scale_factor = floor(registers.OutputSize.y * registers.SourceSize.w); + if (registers.console_border_enable > 0.5) video_scale_factor = registers.video_scale; + vec2 scaled_video_out = (registers.SourceSize.xy * vec2(video_scale_factor)); // Remaps position to integer scaled output gl_Position = global.MVP * Position / vec4( vec2(registers.OutputSize.xy / scaled_video_out), 1.0, 1.0 ); vTexCoord = TexCoord + half_pixel; dot_size = registers.SourceSize.zw; - one_texel = 1.0 / (registers.SourceSize.xy * video_scale); + one_texel = 1.0 / (registers.SourceSize.xy * video_scale_factor); } ////////////////////////////////////////////////////////////////////////////////