Update GBA/GBC/NDS colour correction parameters

This commit is contained in:
jdgleaver 2020-08-12 13:04:33 +01:00
parent 31888eeb25
commit 3ccfa35588
12 changed files with 140 additions and 117 deletions

View file

@ -21,25 +21,25 @@ layout(std140, set = 0, binding = 0) uniform UBO
*/ */
// Shader that replicates the LCD dynamics from a GameBoy Advance // Shader that replicates the LCD dynamics from a GameBoy Advance
#pragma parameter darken_screen "Darken Screen" 0.5 -0.25 1.5 0.05 #pragma parameter darken_screen "Darken Screen" 1.0 -0.25 1.0 0.05
#define target_gamma 2.2 #define target_gamma 2.2
#define display_gamma 2.2 #define display_gamma 2.2
#define sat 1.0 #define sat 1.0
#define lum 1.0 #define lum 0.94
#define contrast 1.0 #define contrast 1.0
#define blr 0.0 #define blr 0.0
#define blg 0.0 #define blg 0.0
#define blb 0.0 #define blb 0.0
#define r 0.86 #define r 0.82
#define g 0.66 #define g 0.665
#define b 0.81 #define b 0.73
#define rg 0.11 #define rg 0.125
#define rb 0.1325 #define rb 0.195
#define gr 0.19 #define gr 0.24
#define gb 0.0575 #define gb 0.075
#define br -0.05 #define br -0.06
#define bg 0.23 #define bg 0.21
#define overscan_percent_x 0.0 #define overscan_percent_x 0.0
#define overscan_percent_y 0.0 #define overscan_percent_y 0.0

View file

@ -2,7 +2,7 @@
layout(push_constant) uniform Push layout(push_constant) uniform Push
{ {
float brighten_screen; float lighten_screen;
} params; } params;
layout(std140, set = 0, binding = 0) uniform UBO layout(std140, set = 0, binding = 0) uniform UBO
@ -19,27 +19,29 @@ layout(std140, set = 0, binding = 0) uniform UBO
Author: hunterk Author: hunterk
License: Public domain License: Public domain
*/ */
// Shader that replicates the LCD dynamics from a GameBoy Advance // Shader that replicates the LCD dynamics from a GameBoy Color
#pragma parameter brighten_screen "Brighten Screen" 0.5 -0.25 1.2 0.05 #pragma parameter lighten_screen "Lighten Screen" 1.0 0.0 1.0 0.05
#define target_gamma 2.2 #define target_gamma 2.2
#define display_gamma 2.2 #define display_gamma 2.2
#define sat 1.0 #define sat 1.0
#define lum 1.0 #define lum 0.94
#define contrast 1.0 #define contrast 1.0
#define blr 0.0 #define blr 0.0
#define blg 0.0 #define blg 0.0
#define blb 0.0 #define blb 0.0
#define r 0.87 #define r 0.82
#define g 0.66 #define g 0.665
#define b 0.79 #define b 0.73
#define rg 0.115 #define rg 0.125
#define rb 0.14 #define rb 0.195
#define gr 0.18 #define gr 0.24
#define gb 0.07 #define gb 0.075
#define br -0.05 #define br -0.06
#define bg 0.225 #define bg 0.21
#define overscan_percent_x 0.0
#define overscan_percent_y 0.0
#pragma stage vertex #pragma stage vertex
layout(location = 0) in vec4 Position; layout(location = 0) in vec4 Position;
@ -59,7 +61,7 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
void main() void main()
{ {
vec4 screen = pow(texture(Source, vTexCoord), vec4(target_gamma + (params.brighten_screen * -1.0))).rgba; vec4 screen = pow(texture(Source, vTexCoord), vec4(target_gamma + (params.lighten_screen * -1.0))).rgba;
vec4 avglum = vec4(0.5); vec4 avglum = vec4(0.5);
screen = mix(screen, avglum, (1.0 - contrast)); screen = mix(screen, avglum, (1.0 - contrast));

View file

@ -14,28 +14,42 @@ layout(std140, set = 0, binding = 0) uniform UBO
Author: hunterk Author: hunterk
License: Public domain License: Public domain
*/ */
// Shader that replicates the LCD dynamics from a Nintendo DS Phat // Shader that replicates the LCD dynamics from a Nintendo DS Phat --
#define target_gamma 2.2 #define target_gamma 1.91
#define display_gamma 2.2 #define display_gamma 1.91
#define sat 1.0 #define sat 1.0
#define lum 1.0 #define lum 0.89
#define contrast 1.0 #define contrast 1.0
#define blr 0.0 #define blr 0.0
#define blg 0.0 #define blg 0.0
#define blb 0.0 #define blb 0.0
#define r 0.85 #define r 0.87
#define g 0.655 #define g 0.645
#define b 0.865 #define b 0.73
#define rg 0.095 #define rg 0.10
#define rb 0.06 #define rb 0.10
#define gr 0.20 #define gr 0.255
#define gb 0.075 #define gb 0.17
#define br -0.05 #define br -0.125
#define bg 0.25 #define bg 0.255
#define overscan_percent_x 0.0 #define overscan_percent_x 0.0
#define overscan_percent_y 0.0 #define overscan_percent_y 0.0
/*
White-NDS
#define lum 0.98
#define r 0.83
#define g 0.625
#define b 0.785
#define rg 0.07
#define rb 0.075
#define gr 0.22
#define gb 0.155
#define br -0.13
#define bg 0.22
*/
#pragma stage vertex #pragma stage vertex
layout(location = 0) in vec4 Position; layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord; layout(location = 1) in vec2 TexCoord;

View file

@ -71,17 +71,18 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
#define NDS_SCREEN_HEIGHT 192.0 #define NDS_SCREEN_HEIGHT 192.0
#define TARGET_GAMMA 2.2 #define TARGET_GAMMA 1.91
const float INV_DISPLAY_GAMMA = 1.0 / 2.2; const float INV_DISPLAY_GAMMA = 1.0 / 1.91;
#define CC_R 0.85 #define CC_LUM 0.89
#define CC_G 0.655 #define CC_R 0.87
#define CC_B 0.865 #define CC_G 0.645
#define CC_RG 0.095 #define CC_B 0.73
#define CC_RB 0.06 #define CC_RG 0.10
#define CC_GR 0.20 #define CC_RB 0.10
#define CC_GB 0.075 #define CC_GR 0.255
#define CC_BR -0.05 #define CC_GB 0.17
#define CC_BG 0.25 #define CC_BR -0.125
#define CC_BG 0.255
/* /*
FRAGMENT SHADER FRAGMENT SHADER
@ -106,7 +107,7 @@ void main()
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA));
colour.rgb = mat3(CC_R, CC_RG, CC_RB, colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB, CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb; CC_BR, CC_BG, CC_B) * (colour.rgb * CC_LUM);
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0); colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Apply LCD grid effect // Apply LCD grid effect

View file

@ -123,15 +123,16 @@ const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
// Colour correction // Colour correction
#define TARGET_GAMMA 2.2 #define TARGET_GAMMA 2.2
const float INV_DISPLAY_GAMMA = 1.0 / 2.2; const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
#define CC_R 0.86 #define CC_LUM 0.94
#define CC_G 0.66 #define CC_R 0.82
#define CC_B 0.81 #define CC_G 0.665
#define CC_RG 0.11 #define CC_B 0.73
#define CC_RB 0.1325 #define CC_RG 0.125
#define CC_GR 0.19 #define CC_RB 0.195
#define CC_GB 0.0575 #define CC_GR 0.24
#define CC_BR -0.05 #define CC_GB 0.075
#define CC_BG 0.23 #define CC_BR -0.06
#define CC_BG 0.21
/* /*
FRAGMENT SHADER FRAGMENT SHADER
@ -146,10 +147,10 @@ void main()
vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb;
// Darken colours (if required...) and apply colour correction // Darken colours (if required...) and apply colour correction
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 0.5 + registers.DARKEN_COLOUR)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 1.0 + registers.DARKEN_COLOUR));
colour.rgb = mat3(CC_R, CC_RG, CC_RB, colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB, CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb; CC_BR, CC_BG, CC_B) * (colour.rgb * CC_LUM);
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0); colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Generate grid pattern... // Generate grid pattern...

View file

@ -123,15 +123,16 @@ const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
// Colour correction // Colour correction
#define TARGET_GAMMA 2.2 #define TARGET_GAMMA 2.2
const float INV_DISPLAY_GAMMA = 1.0 / 2.2; const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
#define CC_R 0.86 #define CC_LUM 0.94
#define CC_G 0.66 #define CC_R 0.82
#define CC_B 0.81 #define CC_G 0.665
#define CC_RG 0.11 #define CC_B 0.73
#define CC_RB 0.1325 #define CC_RG 0.125
#define CC_GR 0.19 #define CC_RB 0.195
#define CC_GB 0.0575 #define CC_GR 0.24
#define CC_BR -0.05 #define CC_GB 0.075
#define CC_BG 0.23 #define CC_BR -0.06
#define CC_BG 0.21
/* /*
FRAGMENT SHADER FRAGMENT SHADER
@ -146,10 +147,10 @@ void main()
vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb;
// Darken colours (if required...) and apply colour correction // Darken colours (if required...) and apply colour correction
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 0.5 + registers.DARKEN_COLOUR)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 1.0 + registers.DARKEN_COLOUR));
colour.rgb = mat3(CC_R, CC_RG, CC_RB, colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB, CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb; CC_BR, CC_BG, CC_B) * (colour.rgb * CC_LUM);
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0); colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Generate grid pattern... // Generate grid pattern...

View file

@ -123,15 +123,16 @@ const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
// Colour correction // Colour correction
#define TARGET_GAMMA 2.2 #define TARGET_GAMMA 2.2
const float INV_DISPLAY_GAMMA = 1.0 / 2.2; const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
#define CC_R 0.87 #define CC_LUM 0.94
#define CC_G 0.66 #define CC_R 0.82
#define CC_B 0.79 #define CC_G 0.665
#define CC_RG 0.115 #define CC_B 0.73
#define CC_RB 0.14 #define CC_RG 0.125
#define CC_GR 0.18 #define CC_RB 0.195
#define CC_GB 0.07 #define CC_GR 0.24
#define CC_BR -0.05 #define CC_GB 0.075
#define CC_BG 0.225 #define CC_BR -0.06
#define CC_BG 0.21
/* /*
FRAGMENT SHADER FRAGMENT SHADER
@ -149,7 +150,7 @@ void main()
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA - 0.5 + registers.DARKEN_COLOUR)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA - 0.5 + registers.DARKEN_COLOUR));
colour.rgb = mat3(CC_R, CC_RG, CC_RB, colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB, CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb; CC_BR, CC_BG, CC_B) * (colour.rgb * CC_LUM);
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0); colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Generate grid pattern... // Generate grid pattern...

View file

@ -123,15 +123,16 @@ const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
// Colour correction // Colour correction
#define TARGET_GAMMA 2.2 #define TARGET_GAMMA 2.2
const float INV_DISPLAY_GAMMA = 1.0 / 2.2; const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
#define CC_R 0.87 #define CC_LUM 0.94
#define CC_G 0.66 #define CC_R 0.82
#define CC_B 0.79 #define CC_G 0.665
#define CC_RG 0.115 #define CC_B 0.73
#define CC_RB 0.14 #define CC_RG 0.125
#define CC_GR 0.18 #define CC_RB 0.195
#define CC_GB 0.07 #define CC_GR 0.24
#define CC_BR -0.05 #define CC_GB 0.075
#define CC_BG 0.225 #define CC_BR -0.06
#define CC_BG 0.21
/* /*
FRAGMENT SHADER FRAGMENT SHADER
@ -149,7 +150,7 @@ void main()
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA - 0.5 + registers.DARKEN_COLOUR)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA - 0.5 + registers.DARKEN_COLOUR));
colour.rgb = mat3(CC_R, CC_RG, CC_RB, colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB, CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb; CC_BR, CC_BG, CC_B) * (colour.rgb * CC_LUM);
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0); colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Generate grid pattern... // Generate grid pattern...

View file

@ -122,15 +122,16 @@ const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
// Colour correction // Colour correction
#define TARGET_GAMMA 2.2 #define TARGET_GAMMA 2.2
const float INV_DISPLAY_GAMMA = 1.0 / 2.2; const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
#define CC_R 0.86 #define CC_LUM 0.94
#define CC_G 0.66 #define CC_R 0.82
#define CC_B 0.81 #define CC_G 0.665
#define CC_RG 0.11 #define CC_B 0.73
#define CC_RB 0.1325 #define CC_RG 0.125
#define CC_GR 0.19 #define CC_RB 0.195
#define CC_GB 0.0575 #define CC_GR 0.24
#define CC_BR -0.05 #define CC_GB 0.075
#define CC_BG 0.23 #define CC_BR -0.06
#define CC_BG 0.21
/* /*
FRAGMENT SHADER FRAGMENT SHADER
@ -145,10 +146,10 @@ void main()
vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb;
// Darken colours (if required...) and apply colour correction // Darken colours (if required...) and apply colour correction
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 0.5 + registers.DARKEN_COLOUR)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 1.0 + registers.DARKEN_COLOUR));
colour.rgb = mat3(CC_R, CC_RG, CC_RB, colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB, CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb; CC_BR, CC_BG, CC_B) * (colour.rgb * CC_LUM);
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0); colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Generate grid pattern... // Generate grid pattern...

View file

@ -122,15 +122,16 @@ const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
// Colour correction // Colour correction
#define TARGET_GAMMA 2.2 #define TARGET_GAMMA 2.2
const float INV_DISPLAY_GAMMA = 1.0 / 2.2; const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
#define CC_R 0.87 #define CC_LUM 0.94
#define CC_G 0.66 #define CC_R 0.82
#define CC_B 0.79 #define CC_G 0.665
#define CC_RG 0.115 #define CC_B 0.73
#define CC_RB 0.14 #define CC_RG 0.125
#define CC_GR 0.18 #define CC_RB 0.195
#define CC_GB 0.07 #define CC_GR 0.24
#define CC_BR -0.05 #define CC_GB 0.075
#define CC_BG 0.225 #define CC_BR -0.06
#define CC_BG 0.21
/* /*
FRAGMENT SHADER FRAGMENT SHADER
@ -148,7 +149,7 @@ void main()
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA - 0.5 + registers.DARKEN_COLOUR)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA - 0.5 + registers.DARKEN_COLOUR));
colour.rgb = mat3(CC_R, CC_RG, CC_RB, colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB, CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb; CC_BR, CC_BG, CC_B) * (colour.rgb * CC_LUM);
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0); colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Generate grid pattern... // Generate grid pattern...

View file

@ -10,5 +10,5 @@ scale0 = "1.000000"
filter_linear1 = "false" filter_linear1 = "false"
parameters = "darken_screen;RETRO_PIXEL_SIZE" parameters = "darken_screen;RETRO_PIXEL_SIZE"
darken_screen = "0.500000" darken_screen = "1.000000"
RETRO_PIXEL_SIZE = "0.840000" RETRO_PIXEL_SIZE = "0.840000"

View file

@ -9,6 +9,6 @@ scale0 = "1.000000"
filter_linear1 = "false" filter_linear1 = "false"
parameters = "brighten_screen;RETRO_PIXEL_SIZE" parameters = "lighten_screen;RETRO_PIXEL_SIZE"
brighten_screen = "0.500000" lighten_screen = "0.500000"
RETRO_PIXEL_SIZE = "0.840000" RETRO_PIXEL_SIZE = "0.840000"