simpletex_lcd: Fix gba/gbc colour correction and reoptimise shader parameter presets

This commit is contained in:
jdgleaver 2018-10-18 16:27:31 +01:00
parent e09307f799
commit 40ae79f6f2
10 changed files with 54 additions and 54 deletions

View file

@ -121,6 +121,8 @@ const float LINE_WEIGHT_B = 8.0 / 3.0;
const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE; const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
// Colour correction // Colour correction
#define TARGET_GAMMA 2.2
const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
#define CC_R 0.84 #define CC_R 0.84
#define CC_G 0.66 #define CC_G 0.66
#define CC_B 0.81 #define CC_B 0.81
@ -143,8 +145,12 @@ void main()
// Get colour of current pixel // Get colour of current pixel
vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb;
// Darken colours (if required...) // Darken colours (if required...) and apply colour correction
colour.rgb = pow(colour.rgb, vec3(1.0 + registers.DARKEN_COLOUR)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + registers.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;
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Generate grid pattern... // Generate grid pattern...
vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy); vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy);
@ -182,12 +188,6 @@ void main()
// (lineWeight == 1 -> set colour to value specified by DARKEN_GRID) // (lineWeight == 1 -> set colour to value specified by DARKEN_GRID)
colour.rgb = mix(colour.rgb, vec3(1.0 - registers.DARKEN_GRID), lineWeight); colour.rgb = mix(colour.rgb, vec3(1.0 - registers.DARKEN_GRID), lineWeight);
// Apply colour correction
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb;
colour.rgb = clamp(colour.rgb, 0.0, 1.0);
// Get background sample point // Get background sample point
// > NB: external texture coordinates are referenced in a completely different fashion // > NB: external texture coordinates are referenced in a completely different fashion
// here than they are in GLSL shaders... // here than they are in GLSL shaders...

View file

@ -121,6 +121,8 @@ const float LINE_WEIGHT_B = 8.0 / 3.0;
const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE; const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
// Colour correction // Colour correction
#define TARGET_GAMMA 2.2
const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
#define CC_R 0.84 #define CC_R 0.84
#define CC_G 0.66 #define CC_G 0.66
#define CC_B 0.81 #define CC_B 0.81
@ -143,8 +145,12 @@ void main()
// Get colour of current pixel // Get colour of current pixel
vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb;
// Darken colours (if required...) // Darken colours (if required...) and apply colour correction
colour.rgb = pow(colour.rgb, vec3(1.0 + registers.DARKEN_COLOUR)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + registers.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;
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Generate grid pattern... // Generate grid pattern...
vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy); vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy);
@ -182,12 +188,6 @@ void main()
// (lineWeight == 1 -> set colour to value specified by DARKEN_GRID) // (lineWeight == 1 -> set colour to value specified by DARKEN_GRID)
colour.rgb = mix(colour.rgb, vec3(1.0 - registers.DARKEN_GRID), lineWeight); colour.rgb = mix(colour.rgb, vec3(1.0 - registers.DARKEN_GRID), lineWeight);
// Apply colour correction
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb;
colour.rgb = clamp(colour.rgb, 0.0, 1.0);
// Get background sample point // Get background sample point
// > NB: external texture coordinates are referenced in a completely different fashion // > NB: external texture coordinates are referenced in a completely different fashion
// here than they are in GLSL shaders... // here than they are in GLSL shaders...

View file

@ -121,6 +121,8 @@ const float LINE_WEIGHT_B = 8.0 / 3.0;
const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE; const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
// Colour correction // Colour correction
#define TARGET_GAMMA 2.2
const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
#define CC_R 0.86629 #define CC_R 0.86629
#define CC_G 0.70857 #define CC_G 0.70857
#define CC_B 0.77215 #define CC_B 0.77215
@ -143,8 +145,12 @@ void main()
// Get colour of current pixel // Get colour of current pixel
vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb;
// Darken colours (if required...) // Darken colours (if required...) and apply colour correction
colour.rgb = pow(colour.rgb, vec3(1.0 + registers.DARKEN_COLOUR)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + registers.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;
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Generate grid pattern... // Generate grid pattern...
vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy); vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy);
@ -182,12 +188,6 @@ void main()
// (lineWeight == 1 -> set colour to value specified by DARKEN_GRID) // (lineWeight == 1 -> set colour to value specified by DARKEN_GRID)
colour.rgb = mix(colour.rgb, vec3(1.0 - registers.DARKEN_GRID), lineWeight); colour.rgb = mix(colour.rgb, vec3(1.0 - registers.DARKEN_GRID), lineWeight);
// Apply colour correction
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb;
colour.rgb = clamp(colour.rgb, 0.0, 1.0);
// Get background sample point // Get background sample point
// > NB: external texture coordinates are referenced in a completely different fashion // > NB: external texture coordinates are referenced in a completely different fashion
// here than they are in GLSL shaders... // here than they are in GLSL shaders...

View file

@ -121,6 +121,8 @@ const float LINE_WEIGHT_B = 8.0 / 3.0;
const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE; const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE;
// Colour correction // Colour correction
#define TARGET_GAMMA 2.2
const float INV_DISPLAY_GAMMA = 1.0 / 2.2;
#define CC_R 0.86629 #define CC_R 0.86629
#define CC_G 0.70857 #define CC_G 0.70857
#define CC_B 0.77215 #define CC_B 0.77215
@ -143,8 +145,12 @@ void main()
// Get colour of current pixel // Get colour of current pixel
vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb;
// Darken colours (if required...) // Darken colours (if required...) and apply colour correction
colour.rgb = pow(colour.rgb, vec3(1.0 + registers.DARKEN_COLOUR)); colour.rgb = pow(colour.rgb, vec3(TARGET_GAMMA + registers.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;
colour.rgb = clamp(pow(colour.rgb, vec3(INV_DISPLAY_GAMMA)), 0.0, 1.0);
// Generate grid pattern... // Generate grid pattern...
vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy); vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy);
@ -182,12 +188,6 @@ void main()
// (lineWeight == 1 -> set colour to value specified by DARKEN_GRID) // (lineWeight == 1 -> set colour to value specified by DARKEN_GRID)
colour.rgb = mix(colour.rgb, vec3(1.0 - registers.DARKEN_GRID), lineWeight); colour.rgb = mix(colour.rgb, vec3(1.0 - registers.DARKEN_GRID), lineWeight);
// Apply colour correction
colour.rgb = mat3(CC_R, CC_RG, CC_RB,
CC_GR, CC_G, CC_GB,
CC_BR, CC_BG, CC_B) * colour.rgb;
colour.rgb = clamp(colour.rgb, 0.0, 1.0);
// Get background sample point // Get background sample point
// > NB: external texture coordinates are referenced in a completely different fashion // > NB: external texture coordinates are referenced in a completely different fashion
// here than they are in GLSL shaders... // here than they are in GLSL shaders...

View file

@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/4k/textured_paper.png"
BACKGROUND_linear = false BACKGROUND_linear = false
parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR"
GRID_INTENSITY = "0.9" GRID_INTENSITY = "0.65"
GRID_WIDTH = "0.6" GRID_WIDTH = "0.6"
GRID_BIAS = "0.65" GRID_BIAS = "0.6"
DARKEN_GRID = "0.0" DARKEN_GRID = "0.0"
DARKEN_COLOUR = "0.4" DARKEN_COLOUR = "0.35"

View file

@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/2k/textured_paper.png"
BACKGROUND_linear = false BACKGROUND_linear = false
parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR"
GRID_INTENSITY = "0.9" GRID_INTENSITY = "0.65"
GRID_WIDTH = "0.6" GRID_WIDTH = "0.6"
GRID_BIAS = "0.65" GRID_BIAS = "0.6"
DARKEN_GRID = "0.0" DARKEN_GRID = "0.0"
DARKEN_COLOUR = "0.4" DARKEN_COLOUR = "0.35"

View file

@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/4k/textured_paper.png"
BACKGROUND_linear = false BACKGROUND_linear = false
parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR"
GRID_INTENSITY = "1.0" GRID_INTENSITY = "0.8"
GRID_WIDTH = "0.9" GRID_WIDTH = "0.65"
GRID_BIAS = "0.65" GRID_BIAS = "0.5"
DARKEN_GRID = "0.0" DARKEN_GRID = "0.0"
DARKEN_COLOUR = "0.3" DARKEN_COLOUR = "0.05"

View file

@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/2k/textured_paper.png"
BACKGROUND_linear = false BACKGROUND_linear = false
parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR"
GRID_INTENSITY = "1.0" GRID_INTENSITY = "0.8"
GRID_WIDTH = "0.9" GRID_WIDTH = "0.65"
GRID_BIAS = "0.65" GRID_BIAS = "0.5"
DARKEN_GRID = "0.0" DARKEN_GRID = "0.0"
DARKEN_COLOUR = "0.3" DARKEN_COLOUR = "0.05"

View file

@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/4k/textured_paper.png"
BACKGROUND_linear = false BACKGROUND_linear = false
parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR"
GRID_INTENSITY = "1.0" GRID_INTENSITY = "0.8"
GRID_WIDTH = "0.8" GRID_WIDTH = "0.65"
GRID_BIAS = "0.6" GRID_BIAS = "0.5"
DARKEN_GRID = "0.0" DARKEN_GRID = "0.0"
DARKEN_COLOUR = "0.5" DARKEN_COLOUR = "0.05"

View file

@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/2k/textured_paper.png"
BACKGROUND_linear = false BACKGROUND_linear = false
parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR"
GRID_INTENSITY = "1.0" GRID_INTENSITY = "0.8"
GRID_WIDTH = "0.8" GRID_WIDTH = "0.65"
GRID_BIAS = "0.6" GRID_BIAS = "0.5"
DARKEN_GRID = "0.0" DARKEN_GRID = "0.0"
DARKEN_COLOUR = "0.5" DARKEN_COLOUR = "0.05"