Hidden part of my game
I used asimple trick to add style to my game by limiting the color space. This is how it looks without it and with it.

```gdshader shadertype canvasitem;
uniform sampler2D SCREENTEXTURE : hintscreentexture, filternearest;
uniform sampler2D palettetex : filternearest; uniform int colorcount : hintrange(1, 256) = 16; uniform vec4 basecolor : sourcecolor = vec4(1.0, 1.0, 1.0, 1.0); uniform float blendamount : hintrange(0.0, 1.0) = 1.0;
uniform sampler2D dithertex : filternearest, repeatenable; uniform float ditherscale : hintrange(1.0, 128.0) = 1.0; uniform float ditherintensity : hintrange(0.0, 1.0) = 0.1; uniform bool ditherenabled = false;
vec4 palettesnap(vec3 color) { float u0 = 0.5 / float(colorcount); vec4 best = texture(palettetex, vec2(u0, 0.5)); float dist = distance(color, best.rgb); for (int j = 1; j < colorcount; j++) { float u = (float(j) + 0.5) / float(colorcount); vec4 c = texture(palettetex, vec2(u, 0.5)); float d = distance(color, c.rgb); if (d < dist) { dist = d; best = c; } } return best; }
void fragment() { vec4 color = texture(SCREENTEXTURE, SCREENUV); vec4 original_color = color;
if (dither_enabled) {
vec2 screen_px = FRAGCOORD.xy;
ivec2 dither_size = textureSize(dither_tex, 0);
vec2 scaled = floor(screen_px / dither_scale);
vec2 wrapped = mod(scaled, vec2(dither_size));
vec2 dither_uv = (wrapped + 0.5) / vec2(dither_size);
float dither_val = texture(dither_tex, dither_uv).r - 0.5;
color.rgb += dither_val * dither_intensity;
}
vec4 palette_color = palette_snap(color.rgb) * base_color;
COLOR = mix(original_color, palette_color, blend_amount);
} ```