From 70070526185fb8514bbbcfb2ba561b2782cc27ca Mon Sep 17 00:00:00 2001 From: Valerie Date: Tue, 23 Apr 2024 00:14:28 -0400 Subject: [PATCH] reoriented HSV around bit depth rather than steps --- shaders/composite.fsh | 9 +--- shaders/lang/en_US.lang | 9 ++-- shaders/module/color_depth.frag | 73 +++++++++++++++++++++------------ shaders/shaders.properties | 8 ++-- 4 files changed, 59 insertions(+), 40 deletions(-) diff --git a/shaders/composite.fsh b/shaders/composite.fsh index 3689385..0085211 100644 --- a/shaders/composite.fsh +++ b/shaders/composite.fsh @@ -5,11 +5,6 @@ float renderRes = pixelSize; #define dithering // whether or not to apply dithering -#define colorMode 0 // hsv/rgb [0 1] - -#define hueSteps 4 // the number of hues to use [2 4 8 16 32 64] -#define satSteps 4 // the number of saturations to use [2 4 8 16 32 64] -#define valSteps 4 // the number of lightnesses to use [2 4 8 16 32 64] uniform sampler2D gcolor; uniform float viewWidth, viewHeight; @@ -137,14 +132,14 @@ void main() { vec3 final; #ifdef dithering #if colorMode == 0 - vec3 filtered = vec3(dither(color.x, hueSteps), dither(color.y, satSteps), dither(color.z, valSteps)).rgb; + vec3 filtered = vec3(dither(color.x, hueMax), dither(color.y, satMax), dither(color.z, valMax)).rgb; final = hsv2rgb(filtered); #else final = vec3(dither(color.r, colormax.x), dither(color.g, colormax.y), dither(color.b, colormax.z)); #endif #else #if colorMode == 0 - vec3 filtered = vec3(lightnessStep(color.x, hueSteps), lightnessStep(color.y, satSteps), lightnessStep(color.z, valSteps)).rgb; + vec3 filtered = vec3(lightnessStep(color.x, hueMax), lightnessStep(color.y, satMax), lightnessStep(color.z, valMax)).rgb; final = hsv2rgb(filtered); #else final = vec3(lightnessStep(color.r, colormax.x), lightnessStep(color.g, colormax.y), lightnessStep(color.b, colormax.z)).rgb; diff --git a/shaders/lang/en_US.lang b/shaders/lang/en_US.lang index d5577e2..2688da7 100644 --- a/shaders/lang/en_US.lang +++ b/shaders/lang/en_US.lang @@ -34,9 +34,12 @@ option.monoPalette=Mono Palette value.monoPalette.0=Black & White value.monoPalette.1=Dot Matrix value.monoPalette.2=Paint the Town -option.hueSteps=Hue Depth -option.satSteps=Saturation Depth -option.valSteps=Value Depth +option.hueBits=Hue Depth +suffix.hueBits=-bit +option.satBits=Saturation Depth +suffix.satBits=-bit +option.valBits=Value Depth +suffix.valBits=-bit screen.SCREEN=Screen option.interlacing=Interlacing diff --git a/shaders/module/color_depth.frag b/shaders/module/color_depth.frag index 9b340f7..be240cb 100644 --- a/shaders/module/color_depth.frag +++ b/shaders/module/color_depth.frag @@ -1,32 +1,53 @@ +#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] -#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); +#if colorMode == 0 + // -- 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 == 0 + vec3 monoColor = vec3(1, 1, 1); + #elif monoPalette == 1 + vec3 monoColor = vec3(0.48, 0.72, 0.28); + #elif monoPalette == 2 + vec3 monoColor = vec3(1, 0, 0); + #endif + #endif -#if monoPalette == 0 - vec3 monoColor = vec3(1, 1, 1); -#elif monoPalette == 1 - vec3 monoColor = vec3(0.48, 0.72, 0.28); -#elif monoPalette == 2 - vec3 monoColor = vec3(1, 0, 0); -#endif - - diff --git a/shaders/shaders.properties b/shaders/shaders.properties index 2d25bc0..db6c244 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -1,8 +1,8 @@ -sliders=pixelSize colorDepth hueSteps satSteps valSteps vWarp worldRadius +sliders=pixelSize colorDepth hueBits satBits valBits vWarp worldRadius # -- PROFILES -- -profile.DEFAULT=pixelSize=2 colorMode=0 dithering hueSteps=4 satSteps=4 valSteps=4 vWarp=0 !tWarp !hBlur !interlacing -profile.AEON=pixelSize=1 colorMode=0 dithering hueSteps=8 satSteps=4 valSteps=4 vWarp=0 !tWarp !hBlur !interlacing +profile.DEFAULT=pixelSize=2 colorMode=0 dithering hueBits=2 satBits=2 valBits=2 vWarp=0 !tWarp !hBlur !interlacing +profile.AEON=pixelSize=1 colorMode=0 dithering hueBits=3 satBits=2 valBits=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=1 colorDepth=1 monoPalette=1 dithering vWarp=1 !tWarp !hBlur !interlacing profile.OBRADINN=pixelSize=2 colorMode=1 colorDepth=1 monoPalette=0 dithering vWarp=0 !tWarp !hBlur !interlacing @@ -17,7 +17,7 @@ screen= pixelSize [COLOR] [SCREEN] [CONSOLE] [FX] # colors screen.COLOR.columns=3 -screen.COLOR=colorMode dithering colorDepth monoPalette hueSteps satSteps valSteps +screen.COLOR=colorMode dithering colorDepth monoPalette hueBits satBits valBits # screen effects screen.SCREEN=interlacing scanlines aberration