From 6d73c4f47a70c2b86c16b7264b5407f97340c4da Mon Sep 17 00:00:00 2001 From: Monroe88 Date: Sat, 3 Feb 2018 14:27:36 -0600 Subject: [PATCH] Add GBC color shader and presets --- handheld/gbc-color.slangp | 6 ++ .../lcd-grid-v2-gbc-color-motionblur.slangp | 32 ++++++++++ handheld/lcd-grid-v2-gbc-color.slangp | 27 ++++++++ handheld/shaders/color/gbc-color.slang | 62 +++++++++++++++++++ presets/retro-v2+gbc-color.slangp | 14 +++++ 5 files changed, 141 insertions(+) create mode 100644 handheld/gbc-color.slangp create mode 100644 handheld/lcd-grid-v2-gbc-color-motionblur.slangp create mode 100644 handheld/lcd-grid-v2-gbc-color.slangp create mode 100644 handheld/shaders/color/gbc-color.slang create mode 100644 presets/retro-v2+gbc-color.slangp diff --git a/handheld/gbc-color.slangp b/handheld/gbc-color.slangp new file mode 100644 index 0000000..2527b19 --- /dev/null +++ b/handheld/gbc-color.slangp @@ -0,0 +1,6 @@ +shaders = 1 + +shader0 = shaders/color/gbc-color.slang +filter_linear0 = false +scale_type_0 = source +scale0 = 1.0 diff --git a/handheld/lcd-grid-v2-gbc-color-motionblur.slangp b/handheld/lcd-grid-v2-gbc-color-motionblur.slangp new file mode 100644 index 0000000..06a0e79 --- /dev/null +++ b/handheld/lcd-grid-v2-gbc-color-motionblur.slangp @@ -0,0 +1,32 @@ +shaders = "3" + +shader0 = "../motionblur/shaders/motionblur-simple.slang" +filter_linear0 = "false" +scale_type0 = "source" +scale0 = "1.0" + +shader1 = "shaders/lcd-cgwg/lcd-grid-v2.slang" +filter_linear1 = "false" +scale_type1 = "viewport" +scale1 = "1.0" + +shader2 = "shaders/color/gbc-color.slang" +filter_linear2 = "false" +scale_type2 = "source" +scale2 = "1.0" + +parameters = "RSUBPIX_R;RSUBPIX_G;RSUBPIX_B;GSUBPIX_R;GSUBPIX_G;GSUBPIX_B;BSUBPIX_R;BSUBPIX_G;BSUBPIX_B;gain;gamma;blacklevel;ambient;BGR" +RSUBPIX_R = "0.750000" +RSUBPIX_G = "0.000000" +RSUBPIX_B = "0.000000" +GSUBPIX_R = "0.000000" +GSUBPIX_G = "0.750000" +GSUBPIX_B = "0.000000" +BSUBPIX_R = "0.000000" +BSUBPIX_G = "0.000000" +BSUBPIX_B = "0.750000" +gain = "1.500000" +gamma = "2.200000" +blacklevel = "0.000000" +ambient = "0.000000" +BGR = "1.000000" diff --git a/handheld/lcd-grid-v2-gbc-color.slangp b/handheld/lcd-grid-v2-gbc-color.slangp new file mode 100644 index 0000000..3e133a9 --- /dev/null +++ b/handheld/lcd-grid-v2-gbc-color.slangp @@ -0,0 +1,27 @@ +shaders = "2" + +shader0 = "shaders/lcd-cgwg/lcd-grid-v2.slang" +filter_linear0 = "false" +scale_type0 = "viewport" +scale0 = "1.0" + +shader1 = "shaders/color/gbc-color.slang" +filter_linear1 = "false" +scale_type1 = "source" +scale1 = "1.0" + +parameters = "RSUBPIX_R;RSUBPIX_G;RSUBPIX_B;GSUBPIX_R;GSUBPIX_G;GSUBPIX_B;BSUBPIX_R;BSUBPIX_G;BSUBPIX_B;gain;gamma;blacklevel;ambient;BGR" +RSUBPIX_R = "0.750000" +RSUBPIX_G = "0.000000" +RSUBPIX_B = "0.000000" +GSUBPIX_R = "0.000000" +GSUBPIX_G = "0.750000" +GSUBPIX_B = "0.000000" +BSUBPIX_R = "0.000000" +BSUBPIX_G = "0.000000" +BSUBPIX_B = "0.750000" +gain = "1.500000" +gamma = "2.200000" +blacklevel = "0.000000" +ambient = "0.000000" +BGR = "1.000000" diff --git a/handheld/shaders/color/gbc-color.slang b/handheld/shaders/color/gbc-color.slang new file mode 100644 index 0000000..df020fa --- /dev/null +++ b/handheld/shaders/color/gbc-color.slang @@ -0,0 +1,62 @@ +#version 450 + +/* + GBC Color Correction Shader + A shader that replicates the LCD dynamics from a Game Boy Color + Color values are derived from Gambatte's color correction implementation. + + Based on Color Mangler + Author: hunterk + License: Public domain +*/ + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; + vec4 OutputSize; + vec4 OriginalSize; + vec4 SourceSize; +} global; + +#define blr 0.0 +#define blg 0.0 +#define blb 0.0 +#define r 0.78824 +#define g 0.72941 +#define b 0.66667 +#define rg 0.00 +#define rb 0.18039 +#define gr 0.12157 +#define gb 0.12157 +#define br 0.05882 +#define bg 0.24314 + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec4 screen = texture(Source, vTexCoord); + + // r g b black + mat4 color = mat4(r, rg, rb, 0.0, //red channel + gr, g, gb, 0.0, //green channel + br, bg, b, 0.0, //blue channel + blr, blg, blb, 0.0); //alpha channel; these numbers do nothing for our purposes. + + screen = color * screen; + FragColor = screen; +} \ No newline at end of file diff --git a/presets/retro-v2+gbc-color.slangp b/presets/retro-v2+gbc-color.slangp new file mode 100644 index 0000000..9292e3a --- /dev/null +++ b/presets/retro-v2+gbc-color.slangp @@ -0,0 +1,14 @@ +shaders = "2" + +shader0 = "../handheld/shaders/color/gbc-color.slang" +shader1 = "../retro/shaders/retro-v2.slang" + +filter_linear0 = "false" +scale_type0 = "source" +scale0 = "1.000000" + +filter_linear1 = "false" + +parameters = "darken_screen;RETRO_PIXEL_SIZE" +darken_screen = "0.500000" +RETRO_PIXEL_SIZE = "0.840000"