From 40ae79f6f21081c87a71bfa65b20afb3d43c2d16 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Thu, 18 Oct 2018 16:27:31 +0100 Subject: [PATCH] simpletex_lcd: Fix gba/gbc colour correction and reoptimise shader parameter presets --- .../simpletex_lcd+gba-color-4k.slang | 16 ++++++++-------- .../simpletex_lcd/simpletex_lcd+gba-color.slang | 16 ++++++++-------- .../simpletex_lcd+gbc-color-4k.slang | 16 ++++++++-------- .../simpletex_lcd/simpletex_lcd+gbc-color.slang | 16 ++++++++-------- handheld/simpletex_lcd+gba-color-4k.slangp | 6 +++--- handheld/simpletex_lcd+gba-color.slangp | 6 +++--- handheld/simpletex_lcd+gbc-color-4k.slangp | 8 ++++---- handheld/simpletex_lcd+gbc-color.slangp | 8 ++++---- handheld/simpletex_lcd-4k.slangp | 8 ++++---- handheld/simpletex_lcd.slangp | 8 ++++---- 10 files changed, 54 insertions(+), 54 deletions(-) diff --git a/handheld/shaders/simpletex_lcd/simpletex_lcd+gba-color-4k.slang b/handheld/shaders/simpletex_lcd/simpletex_lcd+gba-color-4k.slang index b578620..7b04348 100644 --- a/handheld/shaders/simpletex_lcd/simpletex_lcd+gba-color-4k.slang +++ b/handheld/shaders/simpletex_lcd/simpletex_lcd+gba-color-4k.slang @@ -121,6 +121,8 @@ const float LINE_WEIGHT_B = 8.0 / 3.0; const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE; // Colour correction +#define TARGET_GAMMA 2.2 +const float INV_DISPLAY_GAMMA = 1.0 / 2.2; #define CC_R 0.84 #define CC_G 0.66 #define CC_B 0.81 @@ -143,8 +145,12 @@ void main() // Get colour of current pixel vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; - // Darken colours (if required...) - colour.rgb = pow(colour.rgb, vec3(1.0 + registers.DARKEN_COLOUR)); + // Darken colours (if required...) and apply colour correction + 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... vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy); @@ -182,12 +188,6 @@ void main() // (lineWeight == 1 -> set colour to value specified by DARKEN_GRID) 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 // > NB: external texture coordinates are referenced in a completely different fashion // here than they are in GLSL shaders... diff --git a/handheld/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang b/handheld/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang index b166f47..8af3ecc 100644 --- a/handheld/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang +++ b/handheld/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang @@ -121,6 +121,8 @@ const float LINE_WEIGHT_B = 8.0 / 3.0; const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE; // Colour correction +#define TARGET_GAMMA 2.2 +const float INV_DISPLAY_GAMMA = 1.0 / 2.2; #define CC_R 0.84 #define CC_G 0.66 #define CC_B 0.81 @@ -143,8 +145,12 @@ void main() // Get colour of current pixel vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; - // Darken colours (if required...) - colour.rgb = pow(colour.rgb, vec3(1.0 + registers.DARKEN_COLOUR)); + // Darken colours (if required...) and apply colour correction + 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... vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy); @@ -182,12 +188,6 @@ void main() // (lineWeight == 1 -> set colour to value specified by DARKEN_GRID) 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 // > NB: external texture coordinates are referenced in a completely different fashion // here than they are in GLSL shaders... diff --git a/handheld/shaders/simpletex_lcd/simpletex_lcd+gbc-color-4k.slang b/handheld/shaders/simpletex_lcd/simpletex_lcd+gbc-color-4k.slang index 2edfc40..35ec2f9 100644 --- a/handheld/shaders/simpletex_lcd/simpletex_lcd+gbc-color-4k.slang +++ b/handheld/shaders/simpletex_lcd/simpletex_lcd+gbc-color-4k.slang @@ -121,6 +121,8 @@ const float LINE_WEIGHT_B = 8.0 / 3.0; const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE; // Colour correction +#define TARGET_GAMMA 2.2 +const float INV_DISPLAY_GAMMA = 1.0 / 2.2; #define CC_R 0.86629 #define CC_G 0.70857 #define CC_B 0.77215 @@ -143,8 +145,12 @@ void main() // Get colour of current pixel vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; - // Darken colours (if required...) - colour.rgb = pow(colour.rgb, vec3(1.0 + registers.DARKEN_COLOUR)); + // Darken colours (if required...) and apply colour correction + 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... vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy); @@ -182,12 +188,6 @@ void main() // (lineWeight == 1 -> set colour to value specified by DARKEN_GRID) 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 // > NB: external texture coordinates are referenced in a completely different fashion // here than they are in GLSL shaders... diff --git a/handheld/shaders/simpletex_lcd/simpletex_lcd+gbc-color.slang b/handheld/shaders/simpletex_lcd/simpletex_lcd+gbc-color.slang index a1e2d91..a8a3369 100644 --- a/handheld/shaders/simpletex_lcd/simpletex_lcd+gbc-color.slang +++ b/handheld/shaders/simpletex_lcd/simpletex_lcd+gbc-color.slang @@ -121,6 +121,8 @@ const float LINE_WEIGHT_B = 8.0 / 3.0; const float INV_BG_TEXTURE_SIZE = 1.0 / BG_TEXTURE_SIZE; // Colour correction +#define TARGET_GAMMA 2.2 +const float INV_DISPLAY_GAMMA = 1.0 / 2.2; #define CC_R 0.86629 #define CC_G 0.70857 #define CC_B 0.77215 @@ -143,8 +145,12 @@ void main() // Get colour of current pixel vec3 colour = texture(Source, registers.SourceSize.zw * imgCenterCoord.xy).rgb; - // Darken colours (if required...) - colour.rgb = pow(colour.rgb, vec3(1.0 + registers.DARKEN_COLOUR)); + // Darken colours (if required...) and apply colour correction + 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... vec2 distFromCenter = abs(imgCenterCoord.xy - imgPixelCoord.xy); @@ -182,12 +188,6 @@ void main() // (lineWeight == 1 -> set colour to value specified by DARKEN_GRID) 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 // > NB: external texture coordinates are referenced in a completely different fashion // here than they are in GLSL shaders... diff --git a/handheld/simpletex_lcd+gba-color-4k.slangp b/handheld/simpletex_lcd+gba-color-4k.slangp index 1b09f2b..79140f5 100644 --- a/handheld/simpletex_lcd+gba-color-4k.slangp +++ b/handheld/simpletex_lcd+gba-color-4k.slangp @@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/4k/textured_paper.png" BACKGROUND_linear = false parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" -GRID_INTENSITY = "0.9" +GRID_INTENSITY = "0.65" GRID_WIDTH = "0.6" -GRID_BIAS = "0.65" +GRID_BIAS = "0.6" DARKEN_GRID = "0.0" -DARKEN_COLOUR = "0.4" +DARKEN_COLOUR = "0.35" diff --git a/handheld/simpletex_lcd+gba-color.slangp b/handheld/simpletex_lcd+gba-color.slangp index 9e3c6d5..ec57799 100644 --- a/handheld/simpletex_lcd+gba-color.slangp +++ b/handheld/simpletex_lcd+gba-color.slangp @@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/2k/textured_paper.png" BACKGROUND_linear = false parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" -GRID_INTENSITY = "0.9" +GRID_INTENSITY = "0.65" GRID_WIDTH = "0.6" -GRID_BIAS = "0.65" +GRID_BIAS = "0.6" DARKEN_GRID = "0.0" -DARKEN_COLOUR = "0.4" +DARKEN_COLOUR = "0.35" diff --git a/handheld/simpletex_lcd+gbc-color-4k.slangp b/handheld/simpletex_lcd+gbc-color-4k.slangp index 52bdd2d..1f85b00 100644 --- a/handheld/simpletex_lcd+gbc-color-4k.slangp +++ b/handheld/simpletex_lcd+gbc-color-4k.slangp @@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/4k/textured_paper.png" BACKGROUND_linear = false parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" -GRID_INTENSITY = "1.0" -GRID_WIDTH = "0.9" -GRID_BIAS = "0.65" +GRID_INTENSITY = "0.8" +GRID_WIDTH = "0.65" +GRID_BIAS = "0.5" DARKEN_GRID = "0.0" -DARKEN_COLOUR = "0.3" +DARKEN_COLOUR = "0.05" diff --git a/handheld/simpletex_lcd+gbc-color.slangp b/handheld/simpletex_lcd+gbc-color.slangp index 36a3a8a..a4169dd 100644 --- a/handheld/simpletex_lcd+gbc-color.slangp +++ b/handheld/simpletex_lcd+gbc-color.slangp @@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/2k/textured_paper.png" BACKGROUND_linear = false parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" -GRID_INTENSITY = "1.0" -GRID_WIDTH = "0.9" -GRID_BIAS = "0.65" +GRID_INTENSITY = "0.8" +GRID_WIDTH = "0.65" +GRID_BIAS = "0.5" DARKEN_GRID = "0.0" -DARKEN_COLOUR = "0.3" +DARKEN_COLOUR = "0.05" diff --git a/handheld/simpletex_lcd-4k.slangp b/handheld/simpletex_lcd-4k.slangp index 9cd0aee..a5ab314 100644 --- a/handheld/simpletex_lcd-4k.slangp +++ b/handheld/simpletex_lcd-4k.slangp @@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/4k/textured_paper.png" BACKGROUND_linear = false parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" -GRID_INTENSITY = "1.0" -GRID_WIDTH = "0.8" -GRID_BIAS = "0.6" +GRID_INTENSITY = "0.8" +GRID_WIDTH = "0.65" +GRID_BIAS = "0.5" DARKEN_GRID = "0.0" -DARKEN_COLOUR = "0.5" +DARKEN_COLOUR = "0.05" diff --git a/handheld/simpletex_lcd.slangp b/handheld/simpletex_lcd.slangp index 4db30a9..9c57219 100644 --- a/handheld/simpletex_lcd.slangp +++ b/handheld/simpletex_lcd.slangp @@ -14,8 +14,8 @@ BACKGROUND = "shaders/simpletex_lcd/png/2k/textured_paper.png" BACKGROUND_linear = false parameters = "GRID_INTENSITY;GRID_WIDTH;GRID_BIAS;DARKEN_GRID;DARKEN_COLOUR" -GRID_INTENSITY = "1.0" -GRID_WIDTH = "0.8" -GRID_BIAS = "0.6" +GRID_INTENSITY = "0.8" +GRID_WIDTH = "0.65" +GRID_BIAS = "0.5" DARKEN_GRID = "0.0" -DARKEN_COLOUR = "0.5" +DARKEN_COLOUR = "0.05"