diff --git a/handheld/console-border/dmg-2x.slangp b/handheld/console-border/dmg-2x.slangp
new file mode 100644
index 0000000..596e87d
--- /dev/null
+++ b/handheld/console-border/dmg-2x.slangp
@@ -0,0 +1,52 @@
+shaders = 6
+
+shader0 = shader-files/gb-pass0.slang
+filter_linear0 = false
+scale_type0 = viewport
+scale0 = 1.0
+alias0 = "PASS0"
+
+shader1 = shader-files/gb-pass1.slang
+filter_linear1 = false
+scale_type1 = source
+scale1 = 1.0
+alias1 = "PASS1"
+
+shader2 = shader-files/gb-pass2.slang
+filter_linear2 = false
+scale_type2 = source
+scale2 = 1.0
+alias2 = "PASS2"
+
+shader3 = shader-files/gb-pass3.slang
+filter_linear3 = false
+scale_type3 = source
+scale3 = 1.0
+alias3 = "PASS3"
+
+shader4 = shader-files/gb-pass4.slang
+filter_linear4 = false
+scale_type4 = source
+scale4 = 1.0
+alias4 = "PASS4"
+
+shader5 = shader-files/border.slang
+
+parameters = "border_on_top;box_scale;in_res_x;in_res_y;border_zoom_x;border_zoom_y;adjacent_texel_alpha_blending;pixel_opacity;shadow_opacity"
+box_scale = "2.0"
+in_res_x = "279.0"
+in_res_y = "158.0"
+border_zoom_x = "1.05"
+border_zoom_y = "1.18"
+adjacent_texel_alpha_blending = "0.38"
+pixel_opacity = "0.90"
+shadow_opacity = "0.90"
+border_on_top = "0.0"
+
+textures = COLOR_PALETTE;BACKGROUND;BORDER
+COLOR_PALETTE = resources/dmg-palette.png
+COLOR_PALETTE_linear = false
+BACKGROUND = resources/dmg-background.png
+BACKGROUND_linear = true
+BORDER = resources/dmg-border-square-4x.png
+BORDER_linear = true
\ No newline at end of file
diff --git a/handheld/console-border/dmg-3x.slangp b/handheld/console-border/dmg-3x.slangp
new file mode 100644
index 0000000..ce8f7fc
--- /dev/null
+++ b/handheld/console-border/dmg-3x.slangp
@@ -0,0 +1,52 @@
+shaders = 6
+
+shader0 = shader-files/gb-pass0.slang
+filter_linear0 = false
+scale_type0 = viewport
+scale0 = 1.0
+alias0 = "PASS0"
+
+shader1 = shader-files/gb-pass1.slang
+filter_linear1 = false
+scale_type1 = source
+scale1 = 1.0
+alias1 = "PASS1"
+
+shader2 = shader-files/gb-pass2.slang
+filter_linear2 = false
+scale_type2 = source
+scale2 = 1.0
+alias2 = "PASS2"
+
+shader3 = shader-files/gb-pass3.slang
+filter_linear3 = false
+scale_type3 = source
+scale3 = 1.0
+alias3 = "PASS3"
+
+shader4 = shader-files/gb-pass4.slang
+filter_linear4 = false
+scale_type4 = source
+scale4 = 1.0
+alias4 = "PASS4"
+
+shader5 = shader-files/border.slang
+
+parameters = "border_on_top;box_scale;in_res_x;in_res_y;border_zoom_x;border_zoom_y;adjacent_texel_alpha_blending;pixel_opacity;shadow_opacity"
+box_scale = "3.0"
+in_res_x = "279.0"
+in_res_y = "158.0"
+border_zoom_x = "0.7"
+border_zoom_y = "0.79"
+adjacent_texel_alpha_blending = "0.38"
+pixel_opacity = "0.90"
+shadow_opacity = "0.90"
+border_on_top = "0.0"
+
+textures = COLOR_PALETTE;BACKGROUND;BORDER
+COLOR_PALETTE = resources/dmg-palette.png
+COLOR_PALETTE_linear = false
+BACKGROUND = resources/dmg-background.png
+BACKGROUND_linear = true
+BORDER = resources/dmg-border-square-4x.png
+BORDER_linear = true
\ No newline at end of file
diff --git a/handheld/console-border/dmg-4x.slangp b/handheld/console-border/dmg-4x.slangp
new file mode 100644
index 0000000..281819e
--- /dev/null
+++ b/handheld/console-border/dmg-4x.slangp
@@ -0,0 +1,52 @@
+shaders = 6
+
+shader0 = shader-files/gb-pass0.slang
+filter_linear0 = false
+scale_type0 = viewport
+scale0 = 1.0
+alias0 = "PASS0"
+
+shader1 = shader-files/gb-pass1.slang
+filter_linear1 = false
+scale_type1 = source
+scale1 = 1.0
+alias1 = "PASS1"
+
+shader2 = shader-files/gb-pass2.slang
+filter_linear2 = false
+scale_type2 = source
+scale2 = 1.0
+alias2 = "PASS2"
+
+shader3 = shader-files/gb-pass3.slang
+filter_linear3 = false
+scale_type3 = source
+scale3 = 1.0
+alias3 = "PASS3"
+
+shader4 = shader-files/gb-pass4.slang
+filter_linear4 = false
+scale_type4 = source
+scale4 = 1.0
+alias4 = "PASS4"
+
+shader5 = shader-files/border.slang
+
+parameters = "border_on_top;box_scale;in_res_x;in_res_y;border_zoom_x;border_zoom_y;adjacent_texel_alpha_blending;pixel_opacity;shadow_opacity"
+box_scale = "4.0"
+in_res_x = "279.0"
+in_res_y = "158.0"
+border_zoom_x = "0.53"
+border_zoom_y = "0.60"
+adjacent_texel_alpha_blending = "0.38"
+pixel_opacity = "0.90"
+shadow_opacity = "0.90"
+border_on_top = "0.0"
+
+textures = COLOR_PALETTE;BACKGROUND;BORDER
+COLOR_PALETTE = resources/dmg-palette.png
+COLOR_PALETTE_linear = false
+BACKGROUND = resources/dmg-background.png
+BACKGROUND_linear = true
+BORDER = resources/dmg-border-square-4x.png
+BORDER_linear = true
\ No newline at end of file
diff --git a/handheld/console-border/dmg-5x.slangp b/handheld/console-border/dmg-5x.slangp
new file mode 100644
index 0000000..51294a9
--- /dev/null
+++ b/handheld/console-border/dmg-5x.slangp
@@ -0,0 +1,52 @@
+shaders = 6
+
+shader0 = shader-files/gb-pass0.slang
+filter_linear0 = false
+scale_type0 = viewport
+scale0 = 1.0
+alias0 = "PASS0"
+
+shader1 = shader-files/gb-pass1.slang
+filter_linear1 = false
+scale_type1 = source
+scale1 = 1.0
+alias1 = "PASS1"
+
+shader2 = shader-files/gb-pass2.slang
+filter_linear2 = false
+scale_type2 = source
+scale2 = 1.0
+alias2 = "PASS2"
+
+shader3 = shader-files/gb-pass3.slang
+filter_linear3 = false
+scale_type3 = source
+scale3 = 1.0
+alias3 = "PASS3"
+
+shader4 = shader-files/gb-pass4.slang
+filter_linear4 = false
+scale_type4 = source
+scale4 = 1.0
+alias4 = "PASS4"
+
+shader5 = shader-files/border.slang
+
+parameters = "border_on_top;box_scale;in_res_x;in_res_y;border_zoom_x;border_zoom_y;adjacent_texel_alpha_blending;pixel_opacity;shadow_opacity"
+box_scale = "5.0"
+in_res_x = "279.0"
+in_res_y = "158.0"
+border_zoom_x = "0.42"
+border_zoom_y = "0.48"
+adjacent_texel_alpha_blending = "0.38"
+pixel_opacity = "0.90"
+shadow_opacity = "0.90"
+border_on_top = "0.0"
+
+textures = COLOR_PALETTE;BACKGROUND;BORDER
+COLOR_PALETTE = resources/dmg-palette.png
+COLOR_PALETTE_linear = false
+BACKGROUND = resources/dmg-background.png
+BACKGROUND_linear = true
+BORDER = resources/dmg-border-square-4x.png
+BORDER_linear = true
\ No newline at end of file
diff --git a/handheld/console-border/dmg-6x.slangp b/handheld/console-border/dmg-6x.slangp
new file mode 100644
index 0000000..2ec795f
--- /dev/null
+++ b/handheld/console-border/dmg-6x.slangp
@@ -0,0 +1,52 @@
+shaders = 6
+
+shader0 = shader-files/gb-pass0.slang
+filter_linear0 = false
+scale_type0 = viewport
+scale0 = 1.0
+alias0 = "PASS0"
+
+shader1 = shader-files/gb-pass1.slang
+filter_linear1 = false
+scale_type1 = source
+scale1 = 1.0
+alias1 = "PASS1"
+
+shader2 = shader-files/gb-pass2.slang
+filter_linear2 = false
+scale_type2 = source
+scale2 = 1.0
+alias2 = "PASS2"
+
+shader3 = shader-files/gb-pass3.slang
+filter_linear3 = false
+scale_type3 = source
+scale3 = 1.0
+alias3 = "PASS3"
+
+shader4 = shader-files/gb-pass4.slang
+filter_linear4 = false
+scale_type4 = source
+scale4 = 1.0
+alias4 = "PASS4"
+
+shader5 = shader-files/border.slang
+
+parameters = "border_on_top;box_scale;in_res_x;in_res_y;border_zoom_x;border_zoom_y;adjacent_texel_alpha_blending;pixel_opacity;shadow_opacity"
+box_scale = "6.0"
+in_res_x = "279.0"
+in_res_y = "158.0"
+border_zoom_x = "0.35"
+border_zoom_y = "0.40"
+adjacent_texel_alpha_blending = "0.38"
+pixel_opacity = "0.90"
+shadow_opacity = "0.90"
+border_on_top = "0.0"
+
+textures = COLOR_PALETTE;BACKGROUND;BORDER
+COLOR_PALETTE = resources/dmg-palette.png
+COLOR_PALETTE_linear = false
+BACKGROUND = resources/dmg-background.png
+BACKGROUND_linear = true
+BORDER = resources/dmg-border-square-4x.png
+BORDER_linear = true
\ No newline at end of file
diff --git a/handheld/console-border/gb-pocket-2x.slangp b/handheld/console-border/gb-pocket-2x.slangp
new file mode 100644
index 0000000..e78c81a
--- /dev/null
+++ b/handheld/console-border/gb-pocket-2x.slangp
@@ -0,0 +1,52 @@
+shaders = 6
+
+shader0 = shader-files/gb-pass0.slang
+filter_linear0 = false
+scale_type0 = viewport
+scale0 = 1.0
+alias0 = "PASS0"
+
+shader1 = shader-files/gb-pass1.slang
+filter_linear1 = false
+scale_type1 = source
+scale1 = 1.0
+alias1 = "PASS1"
+
+shader2 = shader-files/gb-pass2.slang
+filter_linear2 = false
+scale_type2 = source
+scale2 = 1.0
+alias2 = "PASS2"
+
+shader3 = shader-files/gb-pass3.slang
+filter_linear3 = false
+scale_type3 = source
+scale3 = 1.0
+alias3 = "PASS3"
+
+shader4 = shader-files/gb-pass4.slang
+filter_linear4 = false
+scale_type4 = source
+scale4 = 1.0
+alias4 = "PASS4"
+
+shader5 = shader-files/border.slang
+
+parameters = "border_on_top;box_scale;in_res_x;in_res_y;border_zoom_x;border_zoom_y;adjacent_texel_alpha_blending;pixel_opacity;shadow_opacity"
+box_scale = "2.0"
+in_res_x = "279.0"
+in_res_y = "158.0"
+border_zoom_x = "1.05"
+border_zoom_y = "1.18"
+adjacent_texel_alpha_blending = "0.38"
+pixel_opacity = "0.90"
+shadow_opacity = "0.90"
+border_on_top = "0.0"
+
+textures = COLOR_PALETTE;BACKGROUND;BORDER
+COLOR_PALETTE = resources/pocket-palette.png
+COLOR_PALETTE_linear = false
+BACKGROUND = resources/pocket-background.png
+BACKGROUND_linear = true
+BORDER = resources/pocket-border-square-4x.png
+BORDER_linear = true
\ No newline at end of file
diff --git a/handheld/console-border/gb-pocket-3x.slangp b/handheld/console-border/gb-pocket-3x.slangp
new file mode 100644
index 0000000..120c0c0
--- /dev/null
+++ b/handheld/console-border/gb-pocket-3x.slangp
@@ -0,0 +1,52 @@
+shaders = 6
+
+shader0 = shader-files/gb-pass0.slang
+filter_linear0 = false
+scale_type0 = viewport
+scale0 = 1.0
+alias0 = "PASS0"
+
+shader1 = shader-files/gb-pass1.slang
+filter_linear1 = false
+scale_type1 = source
+scale1 = 1.0
+alias1 = "PASS1"
+
+shader2 = shader-files/gb-pass2.slang
+filter_linear2 = false
+scale_type2 = source
+scale2 = 1.0
+alias2 = "PASS2"
+
+shader3 = shader-files/gb-pass3.slang
+filter_linear3 = false
+scale_type3 = source
+scale3 = 1.0
+alias3 = "PASS3"
+
+shader4 = shader-files/gb-pass4.slang
+filter_linear4 = false
+scale_type4 = source
+scale4 = 1.0
+alias4 = "PASS4"
+
+shader5 = shader-files/border.slang
+
+parameters = "border_on_top;box_scale;in_res_x;in_res_y;border_zoom_x;border_zoom_y;adjacent_texel_alpha_blending;pixel_opacity;shadow_opacity"
+box_scale = "3.0"
+in_res_x = "279.0"
+in_res_y = "158.0"
+border_zoom_x = "0.7"
+border_zoom_y = "0.79"
+adjacent_texel_alpha_blending = "0.38"
+pixel_opacity = "0.90"
+shadow_opacity = "0.90"
+border_on_top = "0.0"
+
+textures = COLOR_PALETTE;BACKGROUND;BORDER
+COLOR_PALETTE = resources/pocket-palette.png
+COLOR_PALETTE_linear = false
+BACKGROUND = resources/pocket-background.png
+BACKGROUND_linear = true
+BORDER = resources/pocket-border-square-4x.png
+BORDER_linear = true
\ No newline at end of file
diff --git a/handheld/console-border/gb-pocket-4x.slangp b/handheld/console-border/gb-pocket-4x.slangp
new file mode 100644
index 0000000..a108754
--- /dev/null
+++ b/handheld/console-border/gb-pocket-4x.slangp
@@ -0,0 +1,52 @@
+shaders = 6
+
+shader0 = shader-files/gb-pass0.slang
+filter_linear0 = false
+scale_type0 = viewport
+scale0 = 1.0
+alias0 = "PASS0"
+
+shader1 = shader-files/gb-pass1.slang
+filter_linear1 = false
+scale_type1 = source
+scale1 = 1.0
+alias1 = "PASS1"
+
+shader2 = shader-files/gb-pass2.slang
+filter_linear2 = false
+scale_type2 = source
+scale2 = 1.0
+alias2 = "PASS2"
+
+shader3 = shader-files/gb-pass3.slang
+filter_linear3 = false
+scale_type3 = source
+scale3 = 1.0
+alias3 = "PASS3"
+
+shader4 = shader-files/gb-pass4.slang
+filter_linear4 = false
+scale_type4 = source
+scale4 = 1.0
+alias4 = "PASS4"
+
+shader5 = shader-files/border.slang
+
+parameters = "border_on_top;box_scale;in_res_x;in_res_y;border_zoom_x;border_zoom_y;adjacent_texel_alpha_blending;pixel_opacity;shadow_opacity"
+box_scale = "4.0"
+in_res_x = "279.0"
+in_res_y = "158.0"
+border_zoom_x = "0.53"
+border_zoom_y = "0.60"
+adjacent_texel_alpha_blending = "0.38"
+pixel_opacity = "0.90"
+shadow_opacity = "0.90"
+border_on_top = "0.0"
+
+textures = COLOR_PALETTE;BACKGROUND;BORDER
+COLOR_PALETTE = resources/pocket-palette.png
+COLOR_PALETTE_linear = false
+BACKGROUND = resources/pocket-background.png
+BACKGROUND_linear = true
+BORDER = resources/pocket-border-square-4x.png
+BORDER_linear = true
\ No newline at end of file
diff --git a/handheld/console-border/gb-pocket-5x.slangp b/handheld/console-border/gb-pocket-5x.slangp
new file mode 100644
index 0000000..9a97f44
--- /dev/null
+++ b/handheld/console-border/gb-pocket-5x.slangp
@@ -0,0 +1,52 @@
+shaders = 6
+
+shader0 = shader-files/gb-pass0.slang
+filter_linear0 = false
+scale_type0 = viewport
+scale0 = 1.0
+alias0 = "PASS0"
+
+shader1 = shader-files/gb-pass1.slang
+filter_linear1 = false
+scale_type1 = source
+scale1 = 1.0
+alias1 = "PASS1"
+
+shader2 = shader-files/gb-pass2.slang
+filter_linear2 = false
+scale_type2 = source
+scale2 = 1.0
+alias2 = "PASS2"
+
+shader3 = shader-files/gb-pass3.slang
+filter_linear3 = false
+scale_type3 = source
+scale3 = 1.0
+alias3 = "PASS3"
+
+shader4 = shader-files/gb-pass4.slang
+filter_linear4 = false
+scale_type4 = source
+scale4 = 1.0
+alias4 = "PASS4"
+
+shader5 = shader-files/border.slang
+
+parameters = "border_on_top;box_scale;in_res_x;in_res_y;border_zoom_x;border_zoom_y;adjacent_texel_alpha_blending;pixel_opacity;shadow_opacity"
+box_scale = "5.0"
+in_res_x = "279.0"
+in_res_y = "158.0"
+border_zoom_x = "0.42"
+border_zoom_y = "0.48"
+adjacent_texel_alpha_blending = "0.38"
+pixel_opacity = "0.90"
+shadow_opacity = "0.90"
+border_on_top = "0.0"
+
+textures = COLOR_PALETTE;BACKGROUND;BORDER
+COLOR_PALETTE = resources/pocket-palette.png
+COLOR_PALETTE_linear = false
+BACKGROUND = resources/pocket-background.png
+BACKGROUND_linear = true
+BORDER = resources/pocket-border-square-4x.png
+BORDER_linear = true
\ No newline at end of file
diff --git a/handheld/console-border/gb-pocket-6x.slangp b/handheld/console-border/gb-pocket-6x.slangp
new file mode 100644
index 0000000..be55565
--- /dev/null
+++ b/handheld/console-border/gb-pocket-6x.slangp
@@ -0,0 +1,52 @@
+shaders = 6
+
+shader0 = shader-files/gb-pass0.slang
+filter_linear0 = false
+scale_type0 = viewport
+scale0 = 1.0
+alias0 = "PASS0"
+
+shader1 = shader-files/gb-pass1.slang
+filter_linear1 = false
+scale_type1 = source
+scale1 = 1.0
+alias1 = "PASS1"
+
+shader2 = shader-files/gb-pass2.slang
+filter_linear2 = false
+scale_type2 = source
+scale2 = 1.0
+alias2 = "PASS2"
+
+shader3 = shader-files/gb-pass3.slang
+filter_linear3 = false
+scale_type3 = source
+scale3 = 1.0
+alias3 = "PASS3"
+
+shader4 = shader-files/gb-pass4.slang
+filter_linear4 = false
+scale_type4 = source
+scale4 = 1.0
+alias4 = "PASS4"
+
+shader5 = shader-files/border.slang
+
+parameters = "border_on_top;box_scale;in_res_x;in_res_y;border_zoom_x;border_zoom_y;adjacent_texel_alpha_blending;pixel_opacity;shadow_opacity"
+box_scale = "6.0"
+in_res_x = "279.0"
+in_res_y = "158.0"
+border_zoom_x = "0.35"
+border_zoom_y = "0.40"
+adjacent_texel_alpha_blending = "0.38"
+pixel_opacity = "0.90"
+shadow_opacity = "0.90"
+border_on_top = "0.0"
+
+textures = COLOR_PALETTE;BACKGROUND;BORDER
+COLOR_PALETTE = resources/pocket-palette.png
+COLOR_PALETTE_linear = false
+BACKGROUND = resources/pocket-background.png
+BACKGROUND_linear = true
+BORDER = resources/pocket-border-square-4x.png
+BORDER_linear = true
\ No newline at end of file
diff --git a/handheld/console-border/shader-files/gb-pass0.slang b/handheld/console-border/shader-files/gb-pass0.slang
new file mode 100644
index 0000000..aadc7fe
--- /dev/null
+++ b/handheld/console-border/shader-files/gb-pass0.slang
@@ -0,0 +1,154 @@
+#version 450
+
+layout(push_constant) uniform Push
+{
+ vec4 OutputSize;
+ vec4 OriginalSize;
+ vec4 SourceSize;
+ vec4 OriginalHistorySize1;
+ float baseline_alpha;
+ float response_time;
+} registers;
+
+layout(std140, set = 0, binding = 0) uniform UBO
+{
+ mat4 MVP;
+} global;
+
+////////////////////////////////////////////////////////////////////////////////
+// Config //
+////////////////////////////////////////////////////////////////////////////////
+
+// The alpha value of dots in their "off" state
+// Does not affect the border region of the screen - [0, 1]
+#pragma parameter baseline_alpha "Baseline Alpha" 0.10 0.0 1.0 0.01
+
+// Simulate response time
+// 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
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// Gameboy Classic Shader v0.2.2 //
+// //
+// Copyright (C) 2013 Harlequin : unknown92835@gmail.com //
+// //
+// This program is free software: you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation, either version 3 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with this program. If not, see . //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex shader //
+////////////////////////////////////////////////////////////////////////////////
+
+#pragma stage vertex
+layout(location = 0) in vec4 Position;
+layout(location = 1) in vec2 TexCoord;
+layout(location = 0) out vec2 vTexCoord;
+layout(location = 2) out vec2 dot_size;
+layout(location = 3) out vec2 one_texel;
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex definitions //
+////////////////////////////////////////////////////////////////////////////////
+
+
+// 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)
+
+// Size of the scaled video
+#define scaled_video_out (registers.SourceSize.xy * vec2(video_scale))
+
+//it's... half a pixel
+#define half_pixel (vec2(0.5) * registers.OutputSize.zw)
+
+void main()
+{
+ // 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);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Fragment shader //
+////////////////////////////////////////////////////////////////////////////////
+
+#pragma stage fragment
+layout(location = 0) in vec2 vTexCoord;
+layout(location = 2) in vec2 dot_size;
+layout(location = 3) in vec2 one_texel;
+layout(location = 4) in vec2 HistCoord;
+layout(location = 0) out vec4 FragColor;
+layout(set = 0, binding = 2) uniform sampler2D Source;
+layout(set = 0, binding = 3) uniform sampler2D OriginalHistory1;
+layout(set = 0, binding = 4) uniform sampler2D OriginalHistory2;
+layout(set = 0, binding = 5) uniform sampler2D OriginalHistory3;
+layout(set = 0, binding = 6) uniform sampler2D OriginalHistory4;
+layout(set = 0, binding = 7) uniform sampler2D OriginalHistory5;
+layout(set = 0, binding = 8) uniform sampler2D OriginalHistory6;
+layout(set = 0, binding = 9) uniform sampler2D OriginalHistory7;
+layout(set = 0, binding = 10) uniform sampler2D COLOR_PALETTE;
+
+////////////////////////////////////////////////////////////////////////////////
+//fragment definitions //
+////////////////////////////////////////////////////////////////////////////////
+
+#define foreground_color texture(COLOR_PALETTE, vec2(0.75, 0.5)).rgb //hardcoded to look up the foreground color from the right half of the palette image
+//#define rgb_to_alpha(rgb) ( ((rgb.r + rgb.g + rgb.b) / 3.0) + (is_on_dot * vec2(registers.baseline_alpha), 1.0) ) //averages rgb values (allows it to work with color games), modified for contrast and base alpha
+
+
+// Frame sampling definitions
+#define curr_rgb abs(1.0 - texture(Source, vTexCoord).rgb)
+#define prev0_rgb abs(1.0 - texture(OriginalHistory1, vTexCoord).rgb)
+#define prev1_rgb abs(1.0 - texture(OriginalHistory2, vTexCoord).rgb)
+#define prev2_rgb abs(1.0 - texture(OriginalHistory3, vTexCoord).rgb)
+#define prev3_rgb abs(1.0 - texture(OriginalHistory4, vTexCoord).rgb)
+#define prev4_rgb abs(1.0 - texture(OriginalHistory5, vTexCoord).rgb)
+#define prev5_rgb abs(1.0 - texture(OriginalHistory6, vTexCoord).rgb)
+#define prev6_rgb abs(1.0 - texture(OriginalHistory7, vTexCoord).rgb)
+
+void main()
+{
+ // Determine if the corrent texel lies on a dot or in the space between dots
+ float is_on_dot = 0.0;
+ if ( mod(vTexCoord.x, dot_size.x) > one_texel.x && mod(vTexCoord.y, dot_size.y * 1.0001) > one_texel.y )
+ is_on_dot = 1.0;
+
+ // Sample color from the current and previous frames, apply response time modifier
+ // Response time effect implmented through an exponential dropoff algorithm
+ vec3 input_rgb = curr_rgb;
+ input_rgb += (prev0_rgb - input_rgb) * registers.response_time;
+ input_rgb += (prev1_rgb - input_rgb) * pow(registers.response_time, 2.0);
+ input_rgb += (prev2_rgb - input_rgb) * pow(registers.response_time, 3.0);
+ input_rgb += (prev3_rgb - input_rgb) * pow(registers.response_time, 4.0);
+ input_rgb += (prev4_rgb - input_rgb) * pow(registers.response_time, 5.0);
+ input_rgb += (prev5_rgb - input_rgb) * pow(registers.response_time, 6.0);
+ input_rgb += (prev6_rgb - input_rgb) * pow(registers.response_time, 7.0);
+
+ float rgb_to_alpha = (input_rgb.r + input_rgb.g + input_rgb.b) * 0.333333333
+ + (is_on_dot * registers.baseline_alpha);
+
+ // Apply foreground color and assign alpha value
+ // Apply the foreground color to all texels -
+ // the color will be modified by alpha later - and assign alpha based on rgb input
+ vec4 out_color = vec4(foreground_color, rgb_to_alpha);
+
+ // Overlay the matrix
+ // If the fragment is not on a dot, set its alpha value to 0
+ out_color.a *= is_on_dot;
+
+ FragColor = out_color;
+}
diff --git a/handheld/console-border/shader-files/gb-pass1.slang b/handheld/console-border/shader-files/gb-pass1.slang
new file mode 100644
index 0000000..2ca3474
--- /dev/null
+++ b/handheld/console-border/shader-files/gb-pass1.slang
@@ -0,0 +1,135 @@
+#version 450
+
+layout(push_constant) uniform Push
+{
+ vec4 OutputSize;
+ vec4 OriginalSize;
+ vec4 SourceSize;
+ float blending_mode;
+ float adjacent_texel_alpha_blending;
+} registers;
+
+layout(std140, set = 0, binding = 0) uniform UBO
+{
+ mat4 MVP;
+} global;
+
+////////////////////////////////////////////////////////////////////////////////
+// Config //
+////////////////////////////////////////////////////////////////////////////////
+
+// 0 - only the space between dots is blending
+// 1 - all texels are blended
+/* TODO/FIXME - When set to zero, frame will be a solid green color */
+#pragma parameter blending_mode "Blending Mode" 1.0 0.0 1.0 1.0
+
+// The amount of alpha swapped between neighboring texels
+#pragma parameter adjacent_texel_alpha_blending "Neighbor Blending" 0.1755 0.0 1.0 0.05
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// Gameboy Classic Shader v0.2.2 //
+// //
+// Copyright (C) 2013 Harlequin : unknown92835@gmail.com //
+// //
+// This program is free software: you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation, either version 3 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with this program. If not, see . //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex shader //
+////////////////////////////////////////////////////////////////////////////////
+
+#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 texel;
+layout(location = 2) out vec2 blur_coords_up;
+layout(location = 3) out vec2 blur_coords_down;
+layout(location = 4) out vec2 blur_coords_right;
+layout(location = 5) out vec2 blur_coords_left;
+layout(location = 6) out vec2 blur_coords_lower_bound;
+layout(location = 7) out vec2 blur_coords_upper_bound;
+
+void main()
+{
+ gl_Position = global.MVP * Position;
+ vTexCoord = TexCoord;
+
+ texel = registers.SourceSize.zw;
+ blur_coords_down = vTexCoord + vec2(0.0, texel.y);
+ blur_coords_up = vTexCoord + vec2(0.0, -texel.y);
+ blur_coords_right = vTexCoord + vec2(texel.x, 0.0);
+ blur_coords_left = vTexCoord + vec2(-texel.x, 0.0);
+ blur_coords_lower_bound = vec2(0.0);
+ blur_coords_upper_bound = texel * (registers.OutputSize.xy - vec2(2.0));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Fragment shader //
+////////////////////////////////////////////////////////////////////////////////
+
+#pragma stage fragment
+layout(location = 0) in vec2 vTexCoord;
+layout(location = 1) in vec2 texel;
+layout(location = 2) in vec2 blur_coords_up;
+layout(location = 3) in vec2 blur_coords_down;
+layout(location = 4) in vec2 blur_coords_right;
+layout(location = 5) in vec2 blur_coords_left;
+layout(location = 6) in vec2 blur_coords_lower_bound;
+layout(location = 7) in vec2 blur_coords_upper_bound;
+layout(location = 0) out vec4 FragColor;
+layout(set = 0, binding = 2) uniform sampler2D Source;
+
+////////////////////////////////////////////////////////////////////////////////
+// Fragment definitions //
+////////////////////////////////////////////////////////////////////////////////
+
+//#define blending_modifier(color) clamp((color.a == 0) + registers.blending_mode, 0.0, 1.0)
+
+void main()
+{
+ // A simple blur technique that softens harsh color transitions
+ // Specialized to only blur alpha values and limited to only blurring texels
+ // lying in the spaces between two or more texels
+
+ // Sample the input textures
+ vec4 out_color = texture(Source, vTexCoord).rgba;
+
+ // Clamp the blur coords to the input texture size so it doesn't attempt to sample off the texture (it'll retrieve float4(0.0) and darken the edges otherwise)
+ vec2 blur_coords_up_clamped = clamp(blur_coords_up, blur_coords_lower_bound, blur_coords_upper_bound);
+ vec2 blur_coords_down_clamped = clamp(blur_coords_down, blur_coords_lower_bound, blur_coords_upper_bound);
+ vec2 blur_coords_right_clamped = clamp(blur_coords_right, blur_coords_lower_bound, blur_coords_upper_bound);
+ vec2 blur_coords_left_clamped = clamp(blur_coords_left, blur_coords_lower_bound, blur_coords_upper_bound);
+
+ //Sample adjacent texels based on the coordinates above
+ vec4 adjacent_texel_1 = texture(Source, blur_coords_up_clamped).rgba;
+ vec4 adjacent_texel_2 = texture(Source, blur_coords_down_clamped).rgba;
+ vec4 adjacent_texel_3 = texture(Source, blur_coords_right_clamped).rgba;
+ vec4 adjacent_texel_4 = texture(Source, blur_coords_left_clamped).rgba;
+
+ // Sum the alpha differences between neighboring texels, apply modifiers, then subtract the result from the current fragment alpha value
+ out_color.a -=
+ (
+ (out_color.a - adjacent_texel_1.a) +
+ (out_color.a - adjacent_texel_2.a) +
+ (out_color.a - adjacent_texel_3.a) +
+ (out_color.a - adjacent_texel_4.a)
+ ) * registers.adjacent_texel_alpha_blending;
+
+ out_color.a *= clamp((0.0) + registers.blending_mode, 0.0, 1.0);
+
+ FragColor = out_color;
+}
diff --git a/handheld/console-border/shader-files/gb-pass2.slang b/handheld/console-border/shader-files/gb-pass2.slang
new file mode 100644
index 0000000..3e2f17b
--- /dev/null
+++ b/handheld/console-border/shader-files/gb-pass2.slang
@@ -0,0 +1,117 @@
+#version 450
+
+layout(push_constant) uniform Push
+{
+ vec4 OutputSize;
+ vec4 OriginalSize;
+ vec4 SourceSize;
+} registers;
+
+layout(std140, set = 0, binding = 0) uniform UBO
+{
+ mat4 MVP;
+} global;
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// Gameboy Classic Shader v0.2.2 //
+// //
+// Copyright (C) 2013 Harlequin : unknown92835@gmail.com //
+// //
+// This program is free software: you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation, either version 3 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with this program. If not, see . //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+#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 texel;
+layout(location = 2) out vec2 lower_bound;
+layout(location = 3) out vec2 upper_bound;
+
+void main()
+{
+ gl_Position = global.MVP * Position;
+ vTexCoord = TexCoord;
+
+ texel = registers.SourceSize.zw;
+ lower_bound = vec2(0.0);
+ upper_bound = vec2(texel * (registers.OutputSize.xy - 1.0));
+}
+
+#pragma stage fragment
+layout(location = 0) in vec2 vTexCoord;
+layout(location = 1) in vec2 texel;
+layout(location = 2) in vec2 lower_bound;
+layout(location = 3) in vec2 upper_bound;
+layout(location = 0) out vec4 FragColor;
+layout(set = 0, binding = 2) uniform sampler2D Source;
+
+/*
+sigma = 4.0, normalized for 5 pixel offset sigma = 4.0, normalized for 4 pixel offset
+Raw Gaussian weights: Raw Gaussian weights:
+0.09973561222190091607086808117254 @position0 0.09973561222190091607086808117254 @position0
+0.09666707205829167156101677393475 @position1 0.09666707205829167156101677393475 @position1
+0.08801637626376240452162358324964 @position2 0.08801637626376240452162358324964 @position2
+0.07528440407628116669052257071979 @position3 0.07528440407628116669052257071979 @position3
+0.06049272702308815188099267447364 @position4 0.06049272702308815188099267447364 @position4
+0.04566231462789672460813692086928 @position5
+
+sum [p0 + 2(p1 + p2 + p3 + p4 + p5)]: sum [p0 + 2(p1 + p2 + p3 + p4)]:
+0.83198140032054115459545312766674 0.74065677106474770537917928592818
+
+Normalizing factor [1 / sum]: Normalizing factor [1 / sum]:
+1.2019499469756482251051310195171 1.350153052084338115052273748029
+
+Normalized Gaussian weights: Normalized Gaussian weights:
+0.11987721382169761913280166382392 @position0 0.13465834124289953661305802732548 @position0
+0.11618898213475484076479592086597 @position1 0.13051534237555914090930704141833 @position1
+0.10579127878321792515352079488329 @position2 0.11883557904592230273554609080014 @position2
+0.09048808548757942339961181362524 @position3 0.10164546793794160274995705611009 @position3
+0.07270923003781316665844409497651 @position4 0.08167444001912718529866079800870 @position4
+0.05488381664578583445722654373702 @position5
+*/
+void main()
+{
+ // Define offsets and weights - change this for both the X and Y passes if you change the sigma value or number of texels sampled
+ float offsets[5] = float[](0.0, 1.0, 2.0, 3.0, 4.0);
+
+ /*
+ Precalculated using the Gaussian function:
+ G(x) = (1 / sqrt(2 * pi * sigma^2)) * e^(-x^2 / (2 * sigma^2))
+
+ Where sigma = 4.0 and x = offset in range [0, 5]
+ Normalized to 1 to prevent image darkening by multiplying each weight by:
+ 1 / sum(all weights)
+ */
+ float weights[5] = float[]( 0.13465834124289953661305802732548,
+ 0.13051534237555914090930704141833,
+ 0.11883557904592230273554609080014,
+ 0.10164546793794160274995705611009,
+ 0.08167444001912718529866079800870 );
+
+ // Sample the current fragment and apply its weight
+ vec4 out_color = texture(Source, clamp(vTexCoord, lower_bound, upper_bound)) * weights[0];
+
+ // Iterate across the offsets in both directions sampling texels
+ // and adding their weighted alpha values to the total
+ for (int i = 1; i < 5; i++)
+ {
+ out_color.a += texture(Source, clamp(vTexCoord + vec2(offsets[i] * texel.x, 0.0), lower_bound, upper_bound)).a * weights[i];
+ out_color.a += texture(Source, clamp(vTexCoord - vec2(offsets[i] * texel.x, 0.0), lower_bound, upper_bound)).a * weights[i];
+ }
+
+ FragColor = out_color;
+}
diff --git a/handheld/console-border/shader-files/gb-pass3.slang b/handheld/console-border/shader-files/gb-pass3.slang
new file mode 100644
index 0000000..29b8d19
--- /dev/null
+++ b/handheld/console-border/shader-files/gb-pass3.slang
@@ -0,0 +1,117 @@
+#version 450
+
+layout(push_constant) uniform Push
+{
+ vec4 OutputSize;
+ vec4 OriginalSize;
+ vec4 SourceSize;
+} registers;
+
+layout(std140, set = 0, binding = 0) uniform UBO
+{
+ mat4 MVP;
+} global;
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// Gameboy Classic Shader v0.2.2 //
+// //
+// Copyright (C) 2013 Harlequin : unknown92835@gmail.com //
+// //
+// This program is free software: you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation, either version 3 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with this program. If not, see . //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+#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 texel;
+layout(location = 2) out vec2 lower_bound;
+layout(location = 3) out vec2 upper_bound;
+
+void main()
+{
+ gl_Position = global.MVP * Position;
+ vTexCoord = TexCoord;
+
+ texel = registers.SourceSize.zw;
+ lower_bound = vec2(0.0);
+ upper_bound = vec2(texel * (registers.OutputSize.xy - 1.0));
+}
+
+#pragma stage fragment
+layout(location = 0) in vec2 vTexCoord;
+layout(location = 1) in vec2 texel;
+layout(location = 2) in vec2 lower_bound;
+layout(location = 3) in vec2 upper_bound;
+layout(location = 0) out vec4 FragColor;
+layout(set = 0, binding = 2) uniform sampler2D Source;
+
+/*
+sigma = 4.0, normalized for 5 pixel offset sigma = 4.0, normalized for 4 pixel offset
+Raw Gaussian weights: Raw Gaussian weights:
+0.09973561222190091607086808117254 @position0 0.09973561222190091607086808117254 @position0
+0.09666707205829167156101677393475 @position1 0.09666707205829167156101677393475 @position1
+0.08801637626376240452162358324964 @position2 0.08801637626376240452162358324964 @position2
+0.07528440407628116669052257071979 @position3 0.07528440407628116669052257071979 @position3
+0.06049272702308815188099267447364 @position4 0.06049272702308815188099267447364 @position4
+0.04566231462789672460813692086928 @position5
+
+sum [p0 + 2(p1 + p2 + p3 + p4 + p5)]: sum [p0 + 2(p1 + p2 + p3 + p4)]:
+0.83198140032054115459545312766674 0.74065677106474770537917928592818
+
+Normalizing factor [1 / sum]: Normalizing factor [1 / sum]:
+1.2019499469756482251051310195171 1.350153052084338115052273748029
+
+Normalized Gaussian weights: Normalized Gaussian weights:
+0.11987721382169761913280166382392 @position0 0.13465834124289953661305802732548 @position0
+0.11618898213475484076479592086597 @position1 0.13051534237555914090930704141833 @position1
+0.10579127878321792515352079488329 @position2 0.11883557904592230273554609080014 @position2
+0.09048808548757942339961181362524 @position3 0.10164546793794160274995705611009 @position3
+0.07270923003781316665844409497651 @position4 0.08167444001912718529866079800870 @position4
+0.05488381664578583445722654373702 @position5
+*/
+void main()
+{
+ // Define offsets and weights - change this for both the X and Y passes if you change the sigma value or number of texels sampled
+ float offsets[5] = float[](0.0, 1.0, 2.0, 3.0, 4.0);
+
+ /*
+ Precalculated using the Gaussian function:
+ G(x) = (1 / sqrt(2 * pi * sigma^2)) * e^(-x^2 / (2 * sigma^2))
+
+ Where sigma = 4.0 and x = offset in range [0, 5]
+ Normalized to 1 to prevent image darkening by multiplying each weight by:
+ 1 / sum(all weights)
+ */
+ float weights[5] = float[]( 0.13465834124289953661305802732548,
+ 0.13051534237555914090930704141833,
+ 0.11883557904592230273554609080014,
+ 0.10164546793794160274995705611009,
+ 0.08167444001912718529866079800870 );
+
+ // Sample the current fragment and apply its weight
+ vec4 out_color = texture(Source, clamp(vTexCoord, lower_bound, upper_bound)) * weights[0];
+
+ // Iterate across the offsets in both directions sampling texels
+ // and adding their weighted alpha values to the total
+ for (int i = 1; i < 5; i++)
+ {
+ out_color.a += texture(Source, clamp(vTexCoord + vec2(0.0, offsets[i] * texel.y), lower_bound, upper_bound)).a * weights[i];
+ out_color.a += texture(Source, clamp(vTexCoord - vec2(0.0, offsets[i] * texel.y), lower_bound, upper_bound)).a * weights[i];
+ }
+
+ FragColor = out_color;
+}
diff --git a/handheld/console-border/shader-files/gb-pass4.slang b/handheld/console-border/shader-files/gb-pass4.slang
new file mode 100644
index 0000000..a24502a
--- /dev/null
+++ b/handheld/console-border/shader-files/gb-pass4.slang
@@ -0,0 +1,164 @@
+#version 450
+
+layout(push_constant) uniform Push
+{
+ vec4 OutputSize;
+ vec4 OriginalSize;
+ vec4 SourceSize;
+ vec4 PassOutputSize1;
+ float contrast;
+ float screen_light;
+ float pixel_opacity;
+ float bg_smoothing;
+ float shadow_opacity;
+ float shadow_offset_x;
+ float shadow_offset_y;
+ float screen_offset_x;
+ float screen_offset_y;
+} registers;
+
+layout(std140, set = 0, binding = 0) uniform UBO
+{
+ mat4 MVP;
+} global;
+
+////////////////////////////////////////////////////////////////////////////////
+// Config //
+////////////////////////////////////////////////////////////////////////////////
+
+// Useful to fine-tune the colors.
+// Higher values make the "black" color closer to black - [0, 1] [DEFAULT: 0.95]
+#pragma parameter contrast "Contrast" 0.95 0.0 1.0 0.05
+
+// Controls the ambient light of the screen.
+// Lower values darken the screen - [0, 2] [DEFAULT: 1.00]
+#pragma parameter screen_light "Ambient Screen Light" 1.0 0.0 2.0 0.05
+
+// Controls the opacity of the dot-matrix pixels.
+// Lower values make pixels more transparent - [0, 1] [DEFAULT: 1.00]
+#pragma parameter pixel_opacity "Pixel Opacity" 1.0 0.01 1.0 0.01
+
+// Higher values suppress changes in background color directly beneath
+// the foreground to improve image clarity - [0, 1] [DEFAULT: 0.75]
+#pragma parameter bg_smoothing "Background Smooth" 0.75 0.0 1.0 0.05
+
+// How strongly shadows affect the background
+// Higher values darken the shadows - [0, 1] [DEFAULT: 0.55]
+#pragma parameter shadow_opacity "Shadow Opacity" 0.55 0.01 1.0 0.01
+
+// How far the shadow should be shifted to the
+// right in pixels - [-infinity, infinity] [DEFAULT: 1.0]
+#pragma parameter shadow_offset_x "Shadow Offset Horiz" 1.0 -5.0 5.0 0.5
+
+// How far the shadow should be shifted
+// down in pixels - [-infinity, infinity] [DEFAULT: 1.5]
+#pragma parameter shadow_offset_y "Shadow Offset Vert" 1.0 -5.0 5.0 0.5
+
+// Screen offset - [-infinity, infinity] [DEFAULT: 0]
+#pragma parameter screen_offset_x "Screen Offset Horiz" 0.0 -5.0 5.0 0.5
+
+// Screen offset - [-infinity, infinity] [DEFAULT: 0]
+#pragma parameter screen_offset_y "Screen Offset Vert" 0.0 -5.0 5.0 0.5
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// Gameboy Classic Shader v0.2.2 //
+// //
+// Copyright (C) 2013 Harlequin : unknown92835@gmail.com //
+// //
+// This program is free software: you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation, either version 3 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with this program. If not, see . //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+#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 texel;
+
+void main()
+{
+ gl_Position = global.MVP * Position;
+ vTexCoord = TexCoord;
+
+ texel = registers.SourceSize.zw;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Fragment definitions //
+////////////////////////////////////////////////////////////////////////////////
+
+#pragma stage fragment
+layout(location = 0) in vec2 vTexCoord;
+layout(location = 1) in vec2 texel;
+layout(location = 0) out vec4 FragColor;
+layout(set = 0, binding = 1) uniform sampler2D Source;
+layout(set = 0, binding = 2) uniform sampler2D PassOutput1;
+layout(set = 0, binding = 3) uniform sampler2D BACKGROUND;
+layout(set = 0, binding = 4) uniform sampler2D COLOR_PALETTE;
+
+#define bg_color texture(COLOR_PALETTE, vec2(0.25, 0.5))
+
+// Sample the background color from the palette
+#define shadow_alpha (registers.contrast * registers.shadow_opacity)
+
+// Offset for the shadow
+#define shadow_offset vec2(registers.shadow_offset_x * texel.x, registers.shadow_offset_y * texel.y)
+
+// Offset for the entire screen
+#define screen_offset vec2(registers.screen_offset_x * texel.x, registers.screen_offset_y * texel.y)
+
+////////////////////////////////////////////////////////////////////////////////
+// Fragment shader //
+////////////////////////////////////////////////////////////////////////////////
+
+void main()
+{
+ vec2 tex = floor(registers.PassOutputSize1.xy * vTexCoord);
+ tex = (tex + 0.5) * registers.PassOutputSize1.zw;
+
+ // Sample all the relevant textures
+ vec4 foreground = texture(PassOutput1, tex - screen_offset);
+ vec4 background = texture(BACKGROUND, vTexCoord);
+ vec4 shadows = texture(Source, vTexCoord - (shadow_offset + screen_offset));
+ vec4 background_color = bg_color;
+
+ // Foreground and background are blended with the background color
+ foreground *= bg_color;
+
+ float bg_test = 0.0;
+ if ( foreground.a > 0.0 )
+ bg_test = 1.0;
+
+ background -= (background - 0.5) * registers.bg_smoothing * bg_test;
+
+ // Allows for highlights,
+ // background = bg_color when the background color is 0.5 gray
+ background.rgb = clamp(
+ vec3(
+ bg_color.r + mix(-1.0, 1.0, background.r),
+ bg_color.g + mix(-1.0, 1.0, background.g),
+ bg_color.b + mix(-1.0, 1.0, background.b)
+ ),
+ 0.0, 1.0
+ );
+
+ // Shadows are alpha blended with the background
+ vec4 out_color = (shadows * shadows.a * shadow_alpha) + (background * (1 - shadows.a * shadow_alpha));
+
+ // Foreground is alpha blended with the shadowed background
+ out_color = (foreground * foreground.a * registers.contrast) + (out_color * (registers.screen_light - foreground.a * registers.contrast * registers.pixel_opacity));
+
+ FragColor = out_color;
+}
diff --git a/handheld/gameboy/shader-files/gb-pass0.slang b/handheld/gameboy/shader-files/gb-pass0.slang
index cc8244c..d487dcc 100644
--- a/handheld/gameboy/shader-files/gb-pass0.slang
+++ b/handheld/gameboy/shader-files/gb-pass0.slang
@@ -58,7 +58,6 @@ layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 2) out vec2 dot_size;
layout(location = 3) out vec2 one_texel;
-layout(location = 4) out vec2 HistCoord;
////////////////////////////////////////////////////////////////////////////////
// Vertex definitions //
@@ -79,8 +78,6 @@ void main()
// 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;
- HistCoord = floor(registers.OriginalHistorySize1.xy * vTexCoord);
- HistCoord = (HistCoord + 0.5) * registers.OriginalHistorySize1.zw;
dot_size = registers.SourceSize.zw;
one_texel = 1.0 / (registers.SourceSize.xy * video_scale);
}
@@ -93,7 +90,6 @@ void main()
layout(location = 0) in vec2 vTexCoord;
layout(location = 2) in vec2 dot_size;
layout(location = 3) in vec2 one_texel;
-layout(location = 4) in vec2 HistCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
layout(set = 0, binding = 3) uniform sampler2D OriginalHistory1;
@@ -115,19 +111,19 @@ layout(set = 0, binding = 10) uniform sampler2D COLOR_PALETTE;
// Frame sampling definitions
#define curr_rgb abs(1.0 - texture(Source, vTexCoord).rgb)
-#define prev0_rgb abs(1.0 - texture(OriginalHistory1, HistCoord).rgb)
-#define prev1_rgb abs(1.0 - texture(OriginalHistory2, HistCoord).rgb)
-#define prev2_rgb abs(1.0 - texture(OriginalHistory3, HistCoord).rgb)
-#define prev3_rgb abs(1.0 - texture(OriginalHistory4, HistCoord).rgb)
-#define prev4_rgb abs(1.0 - texture(OriginalHistory5, HistCoord).rgb)
-#define prev5_rgb abs(1.0 - texture(OriginalHistory6, HistCoord).rgb)
-#define prev6_rgb abs(1.0 - texture(OriginalHistory7, HistCoord).rgb)
+#define prev0_rgb abs(1.0 - texture(OriginalHistory1, vTexCoord).rgb)
+#define prev1_rgb abs(1.0 - texture(OriginalHistory2, vTexCoord).rgb)
+#define prev2_rgb abs(1.0 - texture(OriginalHistory3, vTexCoord).rgb)
+#define prev3_rgb abs(1.0 - texture(OriginalHistory4, vTexCoord).rgb)
+#define prev4_rgb abs(1.0 - texture(OriginalHistory5, vTexCoord).rgb)
+#define prev5_rgb abs(1.0 - texture(OriginalHistory6, vTexCoord).rgb)
+#define prev6_rgb abs(1.0 - texture(OriginalHistory7, vTexCoord).rgb)
void main()
{
// Determine if the corrent texel lies on a dot or in the space between dots
float is_on_dot = 0.0;
- if ( mod(vTexCoord.x, dot_size.x) > one_texel.x && mod(vTexCoord.y, dot_size.y * 1.001) > one_texel.y )
+ if ( mod(vTexCoord.x, dot_size.x) > one_texel.x && mod(vTexCoord.y, dot_size.y * 1.0001) > one_texel.y )
is_on_dot = 1.0;
// Sample color from the current and previous frames, apply response time modifier