Color reduction and dither
Reduces the values per RGB-channel.
Can use a checkerboard-dither with variable intensity.
Shader code
shader_type canvas_item;
uniform float colors : hint_range(1.0, 16.0);
uniform float dither : hint_range(0.0, 0.5);
void fragment()
{
vec4 color = texture(TEXTURE, UV);
float a = floor(mod(UV.x / TEXTURE_PIXEL_SIZE.x, 2.0));
float b = floor(mod(UV.y / TEXTURE_PIXEL_SIZE.y, 2.0));
float c = mod(a + b, 2.0);
COLOR.r = (round(color.r * colors + dither) / colors) * c;
COLOR.g = (round(color.g * colors + dither) / colors) * c;
COLOR.b = (round(color.b * colors + dither) / colors) * c;
c = 1.0 - c;
COLOR.r += (round(color.r * colors - dither) / colors) * c;
COLOR.g += (round(color.g * colors - dither) / colors) * c;
COLOR.b += (round(color.b * colors - dither) / colors) * c;
}
I applied this to a ColorRect and it just looks white, how do you make it work?
The shader is being applied to your colorrect which is probably white, thus is why its white.
If you want to apply it to the screen as an effect then you should replace the color rect with a texture rect and set its texture to a viewport texture.
But if you want to use the color rect then try replacing
vec4 color = texture(TEXTURE, UV);
with
vec4 color = texture(SCREEN_TEXTURE, UV);
and add
uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_nearest, repeat_disable;
at the top of the shader code.
I was not able to get it to work with the Texture rect, however it works perfectly with the other option, thank you so much!