diff --git a/handheld/gbc-gambatte-color.slangp b/handheld/gbc-gambatte-color.slangp new file mode 100644 index 0000000..72ac3a2 --- /dev/null +++ b/handheld/gbc-gambatte-color.slangp @@ -0,0 +1,6 @@ +shaders = 1 + +shader0 = shaders/color/gbc-gambatte-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 index 06a0e79..85aa715 100644 --- a/handheld/lcd-grid-v2-gbc-color-motionblur.slangp +++ b/handheld/lcd-grid-v2-gbc-color-motionblur.slangp @@ -29,4 +29,4 @@ gain = "1.500000" gamma = "2.200000" blacklevel = "0.000000" ambient = "0.000000" -BGR = "1.000000" +BGR = "0.0" diff --git a/handheld/lcd-grid-v2-gbc-color.slangp b/handheld/lcd-grid-v2-gbc-color.slangp index 3e133a9..9ee9e66 100644 --- a/handheld/lcd-grid-v2-gbc-color.slangp +++ b/handheld/lcd-grid-v2-gbc-color.slangp @@ -24,4 +24,4 @@ gain = "1.500000" gamma = "2.200000" blacklevel = "0.000000" ambient = "0.000000" -BGR = "1.000000" +BGR = "0.0" diff --git a/handheld/shaders/color/gba-color.slang b/handheld/shaders/color/gba-color.slang index b1c91a8..8f40dd9 100644 --- a/handheld/shaders/color/gba-color.slang +++ b/handheld/shaders/color/gba-color.slang @@ -21,7 +21,7 @@ layout(std140, set = 0, binding = 0) uniform UBO */ // Shader that replicates the LCD dynamics from a GameBoy Advance -#pragma parameter darken_screen "Darken Screen" 0.5 0.0 2.0 0.05 +#pragma parameter darken_screen "Darken Screen" 0.5 -0.25 2.0 0.05 #define target_gamma 2.2 #define display_gamma 2.2 @@ -31,15 +31,15 @@ layout(std140, set = 0, binding = 0) uniform UBO #define blr 0.0 #define blg 0.0 #define blb 0.0 -#define r 0.81 -#define g 0.67 -#define b 0.73 +#define r 0.845 +#define g 0.68 +#define b 0.755 #define rg 0.09 -#define rb 0.15 -#define gr 0.23 -#define gb 0.12 -#define br -0.04 -#define bg 0.24 +#define rb 0.16 +#define gr 0.17 +#define gb 0.085 +#define br -0.015 +#define bg 0.23 #define overscan_percent_x 0.0 #define overscan_percent_y 0.0 diff --git a/handheld/shaders/color/gbc-color.slang b/handheld/shaders/color/gbc-color.slang index df020fa..b3fc9a6 100644 --- a/handheld/shaders/color/gbc-color.slang +++ b/handheld/shaders/color/gbc-color.slang @@ -3,13 +3,18 @@ /* 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. + Color values are derived from Gambatte's color correction implementation, with some tweaks. Based on Color Mangler Author: hunterk License: Public domain */ +layout(push_constant) uniform Push +{ + float darken_screen; +} params; + layout(std140, set = 0, binding = 0) uniform UBO { mat4 MVP; @@ -18,18 +23,22 @@ layout(std140, set = 0, binding = 0) uniform UBO vec4 SourceSize; } global; +#pragma parameter darken_screen "Darken Screen" 0.0 -0.25 2.0 0.05 + +#define target_gamma 2.2 +#define display_gamma 2.2 #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 b 0.82 +#define rg 0.025 +#define rb 0.12039 #define gr 0.12157 #define gb 0.12157 -#define br 0.05882 -#define bg 0.24314 +#define br 0.0 +#define bg 0.275000 #pragma stage vertex layout(location = 0) in vec4 Position; @@ -49,14 +58,14 @@ layout(set = 0, binding = 2) uniform sampler2D Source; void main() { - vec4 screen = texture(Source, vTexCoord); + vec4 screen = pow(texture(Source, vTexCoord), vec4(target_gamma + params.darken_screen)).rgba; - // 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. + // red green blue alpha ; alpha does nothing for our purposes + mat4 color = mat4(r, rg, rb, 0.0, //red + gr, g, gb, 0.0, //green + br, bg, b, 0.0, //blue + blr, blg, blb, 0.0); //black screen = color * screen; - FragColor = screen; -} \ No newline at end of file + FragColor = pow(screen, vec4(1.0 / display_gamma)); +} diff --git a/handheld/shaders/color/gbc-gambatte-color.slang b/handheld/shaders/color/gbc-gambatte-color.slang new file mode 100644 index 0000000..adc6894 --- /dev/null +++ b/handheld/shaders/color/gbc-gambatte-color.slang @@ -0,0 +1,103 @@ +#version 450 + +/* + Gambatte Color + A Slang/GLSL port of the color correction option on Gambatte emulator + Ported by: RiskyJumps + License: Public domain +*/ + +/* +OPTIONS: + +INT_OPS (default: Disabled) +It's supposed to be more "accurate" but it's a waste. Not recommended +*/ +//#define INT_OPS + +/* +SIMULATE_INT (default: Disabled) +Only meaningful if INT_OPS is disabled. It truncates floats. Then +again, it's supposed to be more "accurate" but it looks just +too similar. It's still a waste. Not recommended. +*/ +//#define SIMULATE_INT + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; + vec4 OutputSize; + vec4 OriginalSize; + vec4 SourceSize; +} global; + +#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 color = texture(Source, vTexCoord); + +#ifdef INT_OPS + color.rgb *= 255.0; + + int r = (int)color.r; + int g = (int)color.g; + int b = (int)color.b; + + int R = (r * 13 + g * 2 + b) >> 4; + int G = (g * 3 + b) >> 2; + int B = (r * 3 + g * 2 + b * 11) >> 4; + + color.rgb = vec3((float)R, (float)G, (float)B); + color.rgb /= 255.0; + + FragColor = color; + return; + +#else + mat3 color_correction = mat3( + 13.0, 2.0, 1.0, + 0.0, 3.0, 1.0, + 3.0, 2.0, 11.0 + ); + + mat3 scale = mat3( + 1.0/16.0, 0.0, 0.0, + 0.0, 1.0/4.0, 0.0, + 0.0, 0.0, 1.0/16.0 + ); + + color_correction *= scale; + +#ifdef SIMULATE_INT + color.rgb *= 255.0; + color.rgb = floor(color.rgb); + color.rgb *= color_correction; + color.rgb = floor(color.rgb); + color.rgb /= 255.0; + FragColor = color; + return; + +#else + color.rgb *= color_correction; + FragColor = color; + return; + +#endif + +#endif +} diff --git a/handheld/shaders/color/nds-color.slang b/handheld/shaders/color/nds-color.slang index 29260bb..c52e7d4 100644 --- a/handheld/shaders/color/nds-color.slang +++ b/handheld/shaders/color/nds-color.slang @@ -24,15 +24,15 @@ layout(std140, set = 0, binding = 0) uniform UBO #define blr 0.0 #define blg 0.0 #define blb 0.0 -#define r 0.82 -#define g 0.66 -#define b 0.81 -#define rg 0.085 -#define rb 0.085 -#define gr 0.25 -#define gb 0.105 -#define br -0.07 -#define bg 0.255 +#define r 0.83 +#define g 0.65 +#define b 0.765 +#define rg 0.105 +#define rb 0.105 +#define gr 0.20 +#define gb 0.13 +#define br -0.03 +#define bg 0.245 #define overscan_percent_x 0.0 #define overscan_percent_y 0.0 diff --git a/reshade/shaders/LUT/GBA-Unaltered_Gamma.png b/reshade/shaders/LUT/GBA-Unaltered_Gamma.png index 4f039a6..06585b1 100644 Binary files a/reshade/shaders/LUT/GBA-Unaltered_Gamma.png and b/reshade/shaders/LUT/GBA-Unaltered_Gamma.png differ diff --git a/reshade/shaders/LUT/GBA.png b/reshade/shaders/LUT/GBA.png index aef1e81..6fcb7a7 100644 Binary files a/reshade/shaders/LUT/GBA.png and b/reshade/shaders/LUT/GBA.png differ diff --git a/reshade/shaders/LUT/NDS.png b/reshade/shaders/LUT/NDS.png index 2d4e6bf..f15b84f 100644 Binary files a/reshade/shaders/LUT/NDS.png and b/reshade/shaders/LUT/NDS.png differ