From ef6aa474173b5b2c9ab78d6ae9b318190fc89330 Mon Sep 17 00:00:00 2001 From: Valerie Date: Sat, 13 Jul 2024 10:26:41 -0400 Subject: [PATCH] readded mono palettes, with support for n-bit shades --- shaders/composite.fsh | 1 - shaders/lang/en_US.lang | 5 +-- shaders/module/color.frag | 42 ++++++++++++++++++++--- shaders/module/color_depth.frag | 61 --------------------------------- shaders/shaders.properties | 18 +++++----- shaders/var/color.glsl | 16 ++++++--- shaders/var/color_depth.glsl | 11 ------ 7 files changed, 62 insertions(+), 92 deletions(-) delete mode 100644 shaders/module/color_depth.frag delete mode 100644 shaders/var/color_depth.glsl diff --git a/shaders/composite.fsh b/shaders/composite.fsh index 6da24f7..4c5eb56 100644 --- a/shaders/composite.fsh +++ b/shaders/composite.fsh @@ -12,7 +12,6 @@ uniform float viewWidth, viewHeight; varying vec2 texcoord; #include "/module/color.frag" -//#include "/module/color_depth.frag" #include "/module/dof.frag" #include "/module/interlace.frag" diff --git a/shaders/lang/en_US.lang b/shaders/lang/en_US.lang index bcfbf18..ea74a58 100644 --- a/shaders/lang/en_US.lang +++ b/shaders/lang/en_US.lang @@ -2,7 +2,7 @@ profile.DEFAULT=Default profile.AEON=Aeon Upstream profile.DOS=DOS -profile.DOTMATRIX=Dot Matrix Game +profile.DOTMATRIX=DMG-01 profile.EIGHTBIT=8-bit profile.OBRADINN=Obra Dinn profile.PSX=PSX @@ -26,6 +26,7 @@ value.colorMode.0=RGB value.colorMode.1=HSV value.colorMode.2=YIQ value.colorMode.3=YUV +value.colorMode.4=Mono option.dithering=Dithering @@ -38,7 +39,7 @@ suffix.thirdBits=-bit option.monoPalette=Mono Palette value.monoPalette.0=Black & White -value.monoPalette.1=Dot Matrix +value.monoPalette.1=DameGame value.monoPalette.2=Paint the Town value.monoPalette.3=Noir diff --git a/shaders/module/color.frag b/shaders/module/color.frag index f9c1b1b..dd4b29c 100644 --- a/shaders/module/color.frag +++ b/shaders/module/color.frag @@ -1,17 +1,38 @@ #include "/var/color.glsl" -#define colorMode 1 // [0 1 2 3] +#define colorMode 1 // [0 1 2 3 4] -#define firstBits 2 // [1 2 3 4 5 6 7 8] -#define secondBits 2 // [1 2 3 4 5 6 7 8] -#define thirdBits 2 // [1 2 3 4 5 6 7 8] +#define firstBits 2 // [0 1 2 3 4 5 6 7 8] +#define secondBits 2 // [0 1 2 3 4 5 6 7 8] +#define thirdBits 2 // [0 1 2 3 4 5 6 7 8] + +#define monoPalette 0 // [0 1 2 3] float bit_max(int bits) { return pow(2, bits); } float firstMax = bit_max(firstBits); +#if colorMode == COLOR_MONO +float secondMax = firstMax; +float thirdMax = firstMax; +#else float secondMax = bit_max(secondBits); float thirdMax = bit_max(thirdBits); +#endif + +#if monoPalette == MONO_BW +vec3 monoHigh = vec3(1); +vec3 monoLow = vec3(0); +#elif monoPalette == MONO_DAMEGAME +vec3 monoHigh = vec3(0.31, 0.40, 0.03); +vec3 monoLow = vec3(0.17, 0.29, 0.13); +#elif monoPalette == MONO_MOTIONSICK +vec3 monoHigh = vec3(1, 0, 0); +vec3 monoLow = vec3(0); +#elif monoPalette == MONO_NOIR +vec3 monoHigh = vec3(0.73, 0.67, 0.55); +vec3 monoLow = vec3(0.26, 0.23, 0.19); +#endif float luminance(vec3 color) { return dot(color, vec3(0.299, 0.587, 0.114)); @@ -68,6 +89,15 @@ vec3 fromYuv(vec3 yuv) { return vec3(r, g, b); } +vec3 toMono(vec3 rgb) { + float luma = luminance(rgb); + return vec3(luma, luma, luma); +} + +vec3 fromMono(vec3 mono) { + return (mono.x * (monoHigh - monoLow)) + monoLow; +} + vec3 to(vec3 rgb) { #if colorMode == COLOR_RGB @@ -78,6 +108,8 @@ vec3 to(vec3 rgb) { return toYiq(rgb); #elif colorMode == COLOR_YUV return toYuv(rgb); + #elif colorMode == COLOR_MONO + return toMono(rgb); #endif } @@ -90,6 +122,8 @@ vec3 from(vec3 color) { return fromYiq(color); #elif colorMode == COLOR_YUV return fromYuv(color); + #elif colorMode == COLOR_MONO + return fromMono(color); #endif } diff --git a/shaders/module/color_depth.frag b/shaders/module/color_depth.frag deleted file mode 100644 index 1a8a213..0000000 --- a/shaders/module/color_depth.frag +++ /dev/null @@ -1,61 +0,0 @@ - -#include "/var/color_depth.glsl" - -#define colorMode 0 // [0 1] - -#define hueBits 2 // [1 2 3 4 5 6 7 8] -#define satBits 2 // [1 2 3 4 5 6 7 8] -#define valBits 2 // [1 2 3 4 5 6 7 8] - -#define colorDepth 6 // [1 3 6 8 12 15 18 24] -#define monoPalette 0 // [0 1 2 3] - -#if colorMode == MODE_HSV - // -- HSV -- - - float bit_max(int bits) { - return pow(2, bits); - } - - float hueMax = bit_max(hueBits); - float satMax = bit_max(satBits); - float valMax = bit_max(valBits); - -#else - // -- RGB -- - - #if colorDepth == 1 - vec3 colormax = vec3(2, 1, 1); - #elif colorDepth == 3 - vec3 colormax = vec3(2, 2, 2); - #elif colorDepth == 6 - vec3 colormax = vec3(4, 4, 4); - #elif colorDepth == 8 - // 8-bit is 3:3:2 - vec3 colormax = vec3(8, 8, 4); - #elif colorDepth == 12 - vec3 colormax = vec3(16, 16, 16); - #elif colorDepth == 15 - vec3 colormax = vec3(32, 32, 32); - #elif colorDepth == 18 - vec3 colormax = vec3(64, 64, 64); - #elif colorDepth == 24 - vec3 colormax = vec3(256, 256, 256); - #endif - - #if monoPalette == MONOCHROME_BW - vec3 monoHigh = vec3(1); - vec3 monoLow = vec3(0); - #elif monoPalette == MONOCHROME_DOTMATRIX - vec3 monoHigh = vec3(0.31, 0.40, 0.03); - vec3 monoLow = vec3(0.17, 0.29, 0.13); - #elif monoPalette == MONOCHROME_MOTIONSICK - vec3 monoHigh = vec3(1, 0, 0); - vec3 monoLow = vec3(0); - #elif monoPalette == MONOCHROME_NOIR - vec3 monoHigh = vec3(0.73, 0.67, 0.55); - vec3 monoLow = vec3(0.26, 0.23, 0.19); - #endif - -#endif - diff --git a/shaders/shaders.properties b/shaders/shaders.properties index 2079694..58e8261 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -1,15 +1,15 @@ -sliders=pixelSize colorDepth hueBits satBits valBits vWarp worldRadius +sliders=pixelSize firstBits secondBits thirdBits vWarp worldRadius # -- PROFILES -- profile.DEFAULT=pixelSize=2 colorMode=1 dithering firstBits=2 secondBits=2 thirdBits=2 vWarp=0 !tWarp !hBlur !interlacing profile.AEON=pixelSize=1 colorMode=1 dithering firstBits=3 secondBits=2 thirdBits=2 vWarp=0 !tWarp !hBlur !interlacing -profile.DOS=pixelSize=4 colorMode=1 dithering colorDepth=3 vWarp=1 !tWarp !hBlur !interlacing -profile.DOTMATRIX=pixelSize=4 colorMode=0 monoPalette=1 dithering vWarp=1 !tWarp !hBlur !interlacing -profile.EIGHTBIT=pixelSize=2 colorMode=0 dithering firstBits=3 secondBits=3 thirdBits=2 vWarp=0 !tWarp !hBlur !interlacing -profile.OBRADINN=pixelSize=2 colorMode=0 colorDepth=1 monoPalette=0 dithering vWarp=0 !tWarp !hBlur !interlacing -profile.PSX=pixelSize=2 colorMode=1 !dithering colorDepth=24 vWarp=2 tWarp !hBlur interlacing -profile.REALITY=pixelSize=2 colorMode=1 firstBits=5 secondBits=5 thirdBits=5 !dithering vWarp=0 !tWarp hBlur interlacing -profile.VR32=pixelSize=8 colorMode=1 !dithering colorDepth=1 monoPalette=2 vWarp=1 !tWarp !hBlur !interlacing +profile.DOS=pixelSize=4 colorMode=0 dithering firstBits=1 secondBits=1 thirdBits=1 vWarp=1 !tWarp !hBlur !interlacing +profile.DOTMATRIX=pixelSize=4 colorMode=4 dithering firstBits=2 monoPalette=1 dithering vWarp=1 !tWarp !hBlur !interlacing +profile.EIGHTBIT=pixelSize=2 colorMode=0 !dithering firstBits=3 secondBits=3 thirdBits=2 vWarp=0 !tWarp !hBlur !interlacing +profile.OBRADINN=pixelSize=2 colorMode=4 dithering firstBits=1 monoPalette=0 vWarp=0 !tWarp !hBlur !interlacing +profile.PSX=pixelSize=2 colorMode=0 !dithering firstBits=8 secondBits=8 thirdBits=8 vWarp=2 tWarp !hBlur interlacing +profile.REALITY=pixelSize=2 colorMode=0 dithering firstBits=5 secondBits=5 thirdBits=5 !dithering vWarp=0 !tWarp hBlur interlacing +profile.VR32=pixelSize=8 colorMode=4 !dithering firstBits=2 monoPalette=2 vWarp=1 !tWarp !hBlur !interlacing # -- SCREENS -- # default @@ -17,7 +17,7 @@ screen= pixelSize [COLOR] [SCREEN] [CON # colors screen.COLOR.columns=3 -screen.COLOR=colorMode dithering firstBits secondBits thirdBits +screen.COLOR=colorMode dithering firstBits secondBits thirdBits monoPalette # screen effects screen.SCREEN=signal wire interlacing scanline aberration diff --git a/shaders/var/color.glsl b/shaders/var/color.glsl index c5f4123..979eaee 100644 --- a/shaders/var/color.glsl +++ b/shaders/var/color.glsl @@ -1,6 +1,14 @@ -#define COLOR_RGB 0 // RGB colorspace -#define COLOR_HSV 1 // HSV colorspace -#define COLOR_YIQ 2 // YIQ colorspace -#define COLOR_YUV 3 // YUV colorspace +// colorspace IDs +#define COLOR_RGB 0 // RGB colorspace +#define COLOR_HSV 1 // HSV colorspace +#define COLOR_YIQ 2 // YIQ colorspace +#define COLOR_YUV 3 // YUV colorspace +#define COLOR_MONO 4 // Monochrome + +// monochrome palette IDs +#define MONO_BW 0 +#define MONO_DAMEGAME 1 +#define MONO_MOTIONSICK 2 +#define MONO_NOIR 3 diff --git a/shaders/var/color_depth.glsl b/shaders/var/color_depth.glsl deleted file mode 100644 index f917c00..0000000 --- a/shaders/var/color_depth.glsl +++ /dev/null @@ -1,11 +0,0 @@ - -// color mode IDs -#define MODE_HSV 0 -#define MODE_RGB 1 - -// monochrome palette IDs -#define MONOCHROME_BW 0 -#define MONOCHROME_DOTMATRIX 1 -#define MONOCHROME_MOTIONSICK 2 -#define MONOCHROME_NOIR 3 -