readded mono palettes, with support for n-bit shades

This commit is contained in:
Valerie Wolfe 2024-07-13 10:26:41 -04:00
parent a7e2143491
commit ef6aa47417
7 changed files with 62 additions and 92 deletions

View file

@ -12,7 +12,6 @@ uniform float viewWidth, viewHeight;
varying vec2 texcoord; varying vec2 texcoord;
#include "/module/color.frag" #include "/module/color.frag"
//#include "/module/color_depth.frag"
#include "/module/dof.frag" #include "/module/dof.frag"
#include "/module/interlace.frag" #include "/module/interlace.frag"

View file

@ -2,7 +2,7 @@
profile.DEFAULT=Default profile.DEFAULT=Default
profile.AEON=Aeon Upstream profile.AEON=Aeon Upstream
profile.DOS=DOS profile.DOS=DOS
profile.DOTMATRIX=Dot Matrix Game profile.DOTMATRIX=DMG-01
profile.EIGHTBIT=8-bit profile.EIGHTBIT=8-bit
profile.OBRADINN=Obra Dinn profile.OBRADINN=Obra Dinn
profile.PSX=PSX profile.PSX=PSX
@ -26,6 +26,7 @@ value.colorMode.0=RGB
value.colorMode.1=HSV value.colorMode.1=HSV
value.colorMode.2=YIQ value.colorMode.2=YIQ
value.colorMode.3=YUV value.colorMode.3=YUV
value.colorMode.4=Mono
option.dithering=Dithering option.dithering=Dithering
@ -38,7 +39,7 @@ suffix.thirdBits=-bit
option.monoPalette=Mono Palette option.monoPalette=Mono Palette
value.monoPalette.0=Black & White value.monoPalette.0=Black & White
value.monoPalette.1=Dot Matrix value.monoPalette.1=DameGame
value.monoPalette.2=Paint the Town value.monoPalette.2=Paint the Town
value.monoPalette.3=Noir value.monoPalette.3=Noir

View file

@ -1,17 +1,38 @@
#include "/var/color.glsl" #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 firstBits 2 // [0 1 2 3 4 5 6 7 8]
#define secondBits 2 // [1 2 3 4 5 6 7 8] #define secondBits 2 // [0 1 2 3 4 5 6 7 8]
#define thirdBits 2 // [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 bit_max(int bits) { return pow(2, bits); }
float firstMax = bit_max(firstBits); float firstMax = bit_max(firstBits);
#if colorMode == COLOR_MONO
float secondMax = firstMax;
float thirdMax = firstMax;
#else
float secondMax = bit_max(secondBits); float secondMax = bit_max(secondBits);
float thirdMax = bit_max(thirdBits); 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) { float luminance(vec3 color) {
return dot(color, vec3(0.299, 0.587, 0.114)); return dot(color, vec3(0.299, 0.587, 0.114));
@ -68,6 +89,15 @@ vec3 fromYuv(vec3 yuv) {
return vec3(r, g, b); 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) { vec3 to(vec3 rgb) {
#if colorMode == COLOR_RGB #if colorMode == COLOR_RGB
@ -78,6 +108,8 @@ vec3 to(vec3 rgb) {
return toYiq(rgb); return toYiq(rgb);
#elif colorMode == COLOR_YUV #elif colorMode == COLOR_YUV
return toYuv(rgb); return toYuv(rgb);
#elif colorMode == COLOR_MONO
return toMono(rgb);
#endif #endif
} }
@ -90,6 +122,8 @@ vec3 from(vec3 color) {
return fromYiq(color); return fromYiq(color);
#elif colorMode == COLOR_YUV #elif colorMode == COLOR_YUV
return fromYuv(color); return fromYuv(color);
#elif colorMode == COLOR_MONO
return fromMono(color);
#endif #endif
} }

View file

@ -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

View file

@ -1,15 +1,15 @@
sliders=pixelSize colorDepth hueBits satBits valBits vWarp worldRadius sliders=pixelSize firstBits secondBits thirdBits vWarp worldRadius
# -- PROFILES -- # -- PROFILES --
profile.DEFAULT=pixelSize=2 colorMode=1 dithering firstBits=2 secondBits=2 thirdBits=2 vWarp=0 !tWarp !hBlur !interlacing 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.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.DOS=pixelSize=4 colorMode=0 dithering firstBits=1 secondBits=1 thirdBits=1 vWarp=1 !tWarp !hBlur !interlacing
profile.DOTMATRIX=pixelSize=4 colorMode=0 monoPalette=1 dithering 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.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.OBRADINN=pixelSize=2 colorMode=4 dithering firstBits=1 monoPalette=0 vWarp=0 !tWarp !hBlur !interlacing
profile.PSX=pixelSize=2 colorMode=1 !dithering colorDepth=24 vWarp=2 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=1 firstBits=5 secondBits=5 thirdBits=5 !dithering vWarp=0 !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=1 !dithering colorDepth=1 monoPalette=2 vWarp=1 !tWarp !hBlur !interlacing profile.VR32=pixelSize=8 colorMode=4 !dithering firstBits=2 monoPalette=2 vWarp=1 !tWarp !hBlur !interlacing
# -- SCREENS -- # -- SCREENS --
# default # default
@ -17,7 +17,7 @@ screen=<profile> <empty> <empty> <empty> pixelSize <empty> [COLOR] [SCREEN] [CON
# colors # colors
screen.COLOR.columns=3 screen.COLOR.columns=3
screen.COLOR=colorMode dithering <empty> firstBits secondBits thirdBits screen.COLOR=colorMode dithering <empty> firstBits secondBits thirdBits monoPalette
# screen effects # screen effects
screen.SCREEN=signal wire interlacing scanline <empty> <empty> aberration screen.SCREEN=signal wire interlacing scanline <empty> <empty> aberration

View file

@ -1,6 +1,14 @@
#define COLOR_RGB 0 // RGB colorspace // colorspace IDs
#define COLOR_HSV 1 // HSV colorspace #define COLOR_RGB 0 // RGB colorspace
#define COLOR_YIQ 2 // YIQ colorspace #define COLOR_HSV 1 // HSV colorspace
#define COLOR_YUV 3 // YUV 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

View file

@ -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