From a6305a1789befc3bca5dbd8955c2d1c8f1b6b0b0 Mon Sep 17 00:00:00 2001 From: metallic77 <43163462+metallic77@users.noreply.github.com> Date: Sat, 13 May 2023 15:21:57 +0300 Subject: [PATCH] Update ega.slang (#426) add CGA mode --- misc/shaders/ega.slang | 52 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/misc/shaders/ega.slang b/misc/shaders/ega.slang index 60d6e4e..14d5fe4 100644 --- a/misc/shaders/ega.slang +++ b/misc/shaders/ega.slang @@ -6,15 +6,21 @@ layout(push_constant) uniform Push vec4 OriginalSize; vec4 OutputSize; uint FrameCount; - + float palette, color_enhance; } params; +#pragma parameter palette "Choose palette Hercules/CGA/EGA" 2.0 0.0 2.0 1.0 +#define palette params.palette + +#pragma parameter color_enhance "Color Enchance" 1.4 1.0 4.0 0.05 +#define color_enhance params.color_enhance + #define _ 0.0 #define o (1./3.) #define b (2./3.) #define B 1.0 -#define color_enhance 1.0 + #define SourceSize params.SourceSize layout(std140, set = 0, binding = 0) uniform UBO @@ -42,7 +48,10 @@ layout(set = 0, binding = 2) uniform sampler2D Source; // Color lookup table (RGBI palette with brown fix) const vec3 rgbi_palette[19] = { - vec3(_, _, _), + vec3(_, _, _), // cga + vec3(B, B, B), // cga white + vec3(o, B, B), // cga cyan + vec3(B, o, B), // cga pink vec3(_, _, b), vec3(_, b, _), vec3(_, b, _), @@ -56,11 +65,24 @@ const vec3 rgbi_palette[19] = vec3(o, o, o), vec3(o, o, B), vec3(o, B, o), - vec3(o, B, B), vec3(B, o, o), - vec3(B, o, B), vec3(B, B, o), - vec3(B, B, B), + +}; + +const vec3 cga_palette[4] = +{ + vec3(_, _, _), // cga + vec3(o, B, B), // cga cyan + vec3(B, o, B), // cga pink + vec3(B, B, B), // cga white +}; + +const vec3 simcga_palette[2] = +{ + vec3(_, _, _), // black + vec3(o, b, o), // green + }; @@ -80,7 +102,9 @@ vec3 nearest_rgbi (vec3 original) float dst; float min_dst = 2.0; int idx = 0; - for (int i=0; i<19; i++) + + int set; if (palette == 2.0)set = 19; else if (palette == 1.0) set = 4;else if (palette == 1.0) set = 2; + for (int i=0; i