mirror of
https://github.com/libretro/glsl-shaders.git
synced 2024-11-23 07:40:29 +00:00
Merge pull request #127 from jdgleaver/gba-gbc-nds-colour-correction
Update GBA/GBC/NDS colour correction parameters
This commit is contained in:
commit
47c7288114
@ -14,31 +14,31 @@
|
||||
#endif
|
||||
|
||||
// Parameter lines go here:
|
||||
#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
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
// All parameter floats need to have COMPAT_PRECISION in front of them
|
||||
uniform COMPAT_PRECISION float darken_screen;
|
||||
#else
|
||||
#define darken_screen 0.5
|
||||
#define darken_screen 1.0
|
||||
#endif
|
||||
|
||||
#define target_gamma 2.2
|
||||
#define display_gamma 2.2
|
||||
#define sat 1.0
|
||||
#define lum 1.0
|
||||
#define lum 0.94
|
||||
#define contrast 1.0
|
||||
#define blr 0.0
|
||||
#define blg 0.0
|
||||
#define blb 0.0
|
||||
#define r 0.86
|
||||
#define g 0.66
|
||||
#define b 0.81
|
||||
#define rg 0.11
|
||||
#define rb 0.1325
|
||||
#define gr 0.19
|
||||
#define gb 0.0575
|
||||
#define br -0.05
|
||||
#define bg 0.23
|
||||
#define r 0.82
|
||||
#define g 0.665
|
||||
#define b 0.73
|
||||
#define rg 0.125
|
||||
#define rb 0.195
|
||||
#define gr 0.24
|
||||
#define gb 0.075
|
||||
#define br -0.06
|
||||
#define bg 0.21
|
||||
#define overscan_percent_x 0.0
|
||||
#define overscan_percent_y 0.0
|
||||
|
||||
|
@ -1,13 +1,10 @@
|
||||
/*
|
||||
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, with some tweaks.
|
||||
Further tweaks by Pokefan531.
|
||||
|
||||
Based on Color Mangler
|
||||
Shader Modified: Pokefan531
|
||||
Color Mangler
|
||||
Author: hunterk
|
||||
License: Public domain
|
||||
*/
|
||||
// Shader that replicates the LCD dynamics from a GameBoy Color
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
@ -16,29 +13,34 @@
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
// GBC-Color option has brightness values from 0 to 1.2. light position relative to screen - Top: 1.2 Mid: 0.5 Bottom: 0.0
|
||||
#pragma parameter brighten_screen "Brighten Screen" 0.5 -0.25 1.2 0.05
|
||||
// Parameter lines go here:
|
||||
#pragma parameter lighten_screen "Lighten Screen" 1.0 0.0 1.0 0.05
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
// All parameter floats need to have COMPAT_PRECISION in front of them
|
||||
uniform COMPAT_PRECISION float brighten_screen;
|
||||
uniform COMPAT_PRECISION float lighten_screen;
|
||||
#else
|
||||
#define brighten_screen 0.0
|
||||
#define lighten_screen 1.0
|
||||
#endif
|
||||
|
||||
#define target_gamma 2.2
|
||||
#define display_gamma 2.2
|
||||
#define sat 1.0
|
||||
#define lum 0.94
|
||||
#define contrast 1.0
|
||||
#define blr 0.0
|
||||
#define blg 0.0
|
||||
#define blb 0.0
|
||||
#define r 0.87
|
||||
#define g 0.66
|
||||
#define b 0.79
|
||||
#define rg 0.115
|
||||
#define rb 0.14
|
||||
#define gr 0.18
|
||||
#define gb 0.07
|
||||
#define br -0.05
|
||||
#define bg 0.225
|
||||
#define r 0.82
|
||||
#define g 0.665
|
||||
#define b 0.73
|
||||
#define rg 0.125
|
||||
#define rb 0.195
|
||||
#define gr 0.24
|
||||
#define gb 0.075
|
||||
#define br -0.06
|
||||
#define bg 0.21
|
||||
#define overscan_percent_x 0.0
|
||||
#define overscan_percent_y 0.0
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
@ -112,21 +114,29 @@ COMPAT_VARYING vec4 TEX0;
|
||||
// compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define outsize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 screen = pow(COMPAT_TEXTURE(Source, vTexCoord), vec4(target_gamma - brighten_screen)).rgba;
|
||||
|
||||
// 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 = pow(screen, vec4(1.0 / display_gamma));
|
||||
vec4 screen = pow(texture(Source, vTexCoord), vec4(target_gamma + (lighten_screen * -1.0))).rgba;
|
||||
vec4 avglum = vec4(0.5);
|
||||
screen = mix(screen, avglum, (1.0 - contrast));
|
||||
|
||||
// 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.
|
||||
|
||||
mat4 adjust = mat4((1.0 - sat) * 0.3086 + sat, (1.0 - sat) * 0.3086, (1.0 - sat) * 0.3086, 1.0,
|
||||
(1.0 - sat) * 0.6094, (1.0 - sat) * 0.6094 + sat, (1.0 - sat) * 0.6094, 1.0,
|
||||
(1.0 - sat) * 0.0820, (1.0 - sat) * 0.0820, (1.0 - sat) * 0.0820 + sat, 1.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
color *= adjust;
|
||||
screen = clamp(screen * lum, 0.0, 1.0);
|
||||
screen = color * screen;
|
||||
FragColor = pow(screen, vec4(1.0 / display_gamma));
|
||||
}
|
||||
#endif
|
||||
|
@ -13,23 +13,23 @@
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
#define target_gamma 2.2
|
||||
#define display_gamma 2.2
|
||||
#define target_gamma 1.91
|
||||
#define display_gamma 1.91
|
||||
#define sat 1.0
|
||||
#define lum 1.0
|
||||
#define lum 0.89
|
||||
#define contrast 1.0
|
||||
#define blr 0.0
|
||||
#define blg 0.0
|
||||
#define blb 0.0
|
||||
#define r 0.85
|
||||
#define g 0.655
|
||||
#define b 0.865
|
||||
#define rg 0.095
|
||||
#define rb 0.06
|
||||
#define gr 0.20
|
||||
#define gb 0.075
|
||||
#define br -0.05
|
||||
#define bg 0.25
|
||||
#define r 0.87
|
||||
#define g 0.645
|
||||
#define b 0.73
|
||||
#define rg 0.10
|
||||
#define rb 0.10
|
||||
#define gr 0.255
|
||||
#define gb 0.17
|
||||
#define br -0.125
|
||||
#define bg 0.255
|
||||
#define overscan_percent_x 0.0
|
||||
#define overscan_percent_y 0.0
|
||||
|
||||
|
@ -115,17 +115,18 @@ uniform COMPAT_PRECISION float BRIGHTEN_LCD;
|
||||
|
||||
#define NDS_SCREEN_HEIGHT 192.0
|
||||
|
||||
#define TARGET_GAMMA 2.2
|
||||
const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
|
||||
#define CC_R 0.85
|
||||
#define CC_G 0.655
|
||||
#define CC_B 0.865
|
||||
#define CC_RG 0.095
|
||||
#define CC_RB 0.06
|
||||
#define CC_GR 0.20
|
||||
#define CC_GB 0.075
|
||||
#define CC_BR -0.05
|
||||
#define CC_BG 0.25
|
||||
#define TARGET_GAMMA 1.91
|
||||
const float INV_DISPLAY_GAMMA = 1.0 / 1.91;
|
||||
#define CC_LUM 0.89
|
||||
#define CC_R 0.87
|
||||
#define CC_G 0.645
|
||||
#define CC_B 0.73
|
||||
#define CC_RG 0.10
|
||||
#define CC_RB 0.10
|
||||
#define CC_GR 0.255
|
||||
#define CC_GB 0.17
|
||||
#define CC_BR -0.125
|
||||
#define CC_BG 0.255
|
||||
|
||||
/*
|
||||
FRAGMENT SHADER
|
||||
@ -149,7 +150,7 @@ void main()
|
||||
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA));
|
||||
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
|
||||
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);
|
||||
|
||||
// Apply LCD grid effect
|
||||
|
@ -183,15 +183,16 @@ const COMPAT_PRECISION float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
|
||||
// Colour correction
|
||||
#define TARGET_GAMMA 2.2
|
||||
const COMPAT_PRECISION float INV_DISPLAY_GAMMA = 1.0 / 2.2;
|
||||
#define CC_R 0.86
|
||||
#define CC_G 0.66
|
||||
#define CC_B 0.81
|
||||
#define CC_RG 0.11
|
||||
#define CC_RB 0.1325
|
||||
#define CC_GR 0.19
|
||||
#define CC_GB 0.0575
|
||||
#define CC_BR -0.05
|
||||
#define CC_BG 0.23
|
||||
#define CC_LUM 0.94
|
||||
#define CC_R 0.82
|
||||
#define CC_G 0.665
|
||||
#define CC_B 0.73
|
||||
#define CC_RG 0.125
|
||||
#define CC_RB 0.195
|
||||
#define CC_GR 0.24
|
||||
#define CC_GB 0.075
|
||||
#define CC_BR -0.06
|
||||
#define CC_BG 0.21
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -203,10 +204,10 @@ void main()
|
||||
COMPAT_PRECISION vec3 colour = COMPAT_TEXTURE(Texture, InvTextureSize.xy * imgCenterCoord.xy).rgb;
|
||||
|
||||
// Darken colours (if required...) and apply colour correction
|
||||
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 0.5 + DARKEN_COLOUR));
|
||||
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 1.0 + DARKEN_COLOUR));
|
||||
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
|
||||
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);
|
||||
|
||||
// Generate grid pattern...
|
||||
|
@ -183,15 +183,16 @@ const COMPAT_PRECISION float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
|
||||
// Colour correction
|
||||
#define TARGET_GAMMA 2.2
|
||||
const COMPAT_PRECISION float INV_DISPLAY_GAMMA = 1.0 / 2.2;
|
||||
#define CC_R 0.86
|
||||
#define CC_G 0.66
|
||||
#define CC_B 0.81
|
||||
#define CC_RG 0.11
|
||||
#define CC_RB 0.1325
|
||||
#define CC_GR 0.19
|
||||
#define CC_GB 0.0575
|
||||
#define CC_BR -0.05
|
||||
#define CC_BG 0.23
|
||||
#define CC_LUM 0.94
|
||||
#define CC_R 0.82
|
||||
#define CC_G 0.665
|
||||
#define CC_B 0.73
|
||||
#define CC_RG 0.125
|
||||
#define CC_RB 0.195
|
||||
#define CC_GR 0.24
|
||||
#define CC_GB 0.075
|
||||
#define CC_BR -0.06
|
||||
#define CC_BG 0.21
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -203,10 +204,10 @@ void main()
|
||||
COMPAT_PRECISION vec3 colour = COMPAT_TEXTURE(Texture, InvTextureSize.xy * imgCenterCoord.xy).rgb;
|
||||
|
||||
// Darken colours (if required...) and apply colour correction
|
||||
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 0.5 + DARKEN_COLOUR));
|
||||
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 1.0 + DARKEN_COLOUR));
|
||||
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
|
||||
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);
|
||||
|
||||
// Generate grid pattern...
|
||||
|
@ -183,15 +183,16 @@ const COMPAT_PRECISION float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
|
||||
// Colour correction
|
||||
#define TARGET_GAMMA 2.2
|
||||
const COMPAT_PRECISION float INV_DISPLAY_GAMMA = 1.0 / 2.2;
|
||||
#define CC_R 0.87
|
||||
#define CC_G 0.66
|
||||
#define CC_B 0.79
|
||||
#define CC_RG 0.115
|
||||
#define CC_RB 0.14
|
||||
#define CC_GR 0.18
|
||||
#define CC_GB 0.07
|
||||
#define CC_BR -0.05
|
||||
#define CC_BG 0.225
|
||||
#define CC_LUM 0.94
|
||||
#define CC_R 0.82
|
||||
#define CC_G 0.665
|
||||
#define CC_B 0.73
|
||||
#define CC_RG 0.125
|
||||
#define CC_RB 0.195
|
||||
#define CC_GR 0.24
|
||||
#define CC_GB 0.075
|
||||
#define CC_BR -0.06
|
||||
#define CC_BG 0.21
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -206,7 +207,7 @@ void main()
|
||||
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA - 0.5 + DARKEN_COLOUR));
|
||||
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
|
||||
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);
|
||||
|
||||
// Generate grid pattern...
|
||||
|
@ -183,15 +183,16 @@ const COMPAT_PRECISION float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
|
||||
// Colour correction
|
||||
#define TARGET_GAMMA 2.2
|
||||
const COMPAT_PRECISION float INV_DISPLAY_GAMMA = 1.0 / 2.2;
|
||||
#define CC_R 0.87
|
||||
#define CC_G 0.66
|
||||
#define CC_B 0.79
|
||||
#define CC_RG 0.115
|
||||
#define CC_RB 0.14
|
||||
#define CC_GR 0.18
|
||||
#define CC_GB 0.07
|
||||
#define CC_BR -0.05
|
||||
#define CC_BG 0.225
|
||||
#define CC_LUM 0.94
|
||||
#define CC_R 0.82
|
||||
#define CC_G 0.665
|
||||
#define CC_B 0.73
|
||||
#define CC_RG 0.125
|
||||
#define CC_RB 0.195
|
||||
#define CC_GR 0.24
|
||||
#define CC_GB 0.075
|
||||
#define CC_BR -0.06
|
||||
#define CC_BG 0.21
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -206,7 +207,7 @@ void main()
|
||||
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA - 0.5 + DARKEN_COLOUR));
|
||||
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
|
||||
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);
|
||||
|
||||
// Generate grid pattern...
|
||||
|
@ -182,15 +182,16 @@ const COMPAT_PRECISION float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
|
||||
// Colour correction
|
||||
#define TARGET_GAMMA 2.2
|
||||
const COMPAT_PRECISION float INV_DISPLAY_GAMMA = 1.0 / 2.2;
|
||||
#define CC_R 0.86
|
||||
#define CC_G 0.66
|
||||
#define CC_B 0.81
|
||||
#define CC_RG 0.11
|
||||
#define CC_RB 0.1325
|
||||
#define CC_GR 0.19
|
||||
#define CC_GB 0.0575
|
||||
#define CC_BR -0.05
|
||||
#define CC_BG 0.23
|
||||
#define CC_LUM 0.94
|
||||
#define CC_R 0.82
|
||||
#define CC_G 0.665
|
||||
#define CC_B 0.73
|
||||
#define CC_RG 0.125
|
||||
#define CC_RB 0.195
|
||||
#define CC_GR 0.24
|
||||
#define CC_GB 0.075
|
||||
#define CC_BR -0.06
|
||||
#define CC_BG 0.21
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -202,10 +203,10 @@ void main()
|
||||
COMPAT_PRECISION vec3 colour = COMPAT_TEXTURE(Texture, InvTextureSize.xy * imgCenterCoord.xy).rgb;
|
||||
|
||||
// Darken colours (if required...) and apply colour correction
|
||||
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 0.5 + DARKEN_COLOUR));
|
||||
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + 1.0 + DARKEN_COLOUR));
|
||||
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
|
||||
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);
|
||||
|
||||
// Generate grid pattern...
|
||||
|
@ -182,15 +182,16 @@ const COMPAT_PRECISION float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
|
||||
// Colour correction
|
||||
#define TARGET_GAMMA 2.2
|
||||
const COMPAT_PRECISION float INV_DISPLAY_GAMMA = 1.0 / 2.2;
|
||||
#define CC_R 0.87
|
||||
#define CC_G 0.66
|
||||
#define CC_B 0.79
|
||||
#define CC_RG 0.115
|
||||
#define CC_RB 0.14
|
||||
#define CC_GR 0.18
|
||||
#define CC_GB 0.07
|
||||
#define CC_BR -0.05
|
||||
#define CC_BG 0.225
|
||||
#define CC_LUM 0.94
|
||||
#define CC_R 0.82
|
||||
#define CC_G 0.665
|
||||
#define CC_B 0.73
|
||||
#define CC_RG 0.125
|
||||
#define CC_RB 0.195
|
||||
#define CC_GR 0.24
|
||||
#define CC_GB 0.075
|
||||
#define CC_BR -0.06
|
||||
#define CC_BG 0.21
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -205,7 +206,7 @@ void main()
|
||||
colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA - 0.5 + DARKEN_COLOUR));
|
||||
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
|
||||
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);
|
||||
|
||||
// Generate grid pattern...
|
||||
|
@ -10,5 +10,5 @@ scale0 = "1.000000"
|
||||
filter_linear1 = "false"
|
||||
|
||||
parameters = "darken_screen;RETRO_PIXEL_SIZE"
|
||||
darken_screen = "0.500000"
|
||||
darken_screen = "1.000000"
|
||||
RETRO_PIXEL_SIZE = "0.840000"
|
||||
|
Loading…
Reference in New Issue
Block a user