Palette Shader

Converts an image to a color pallete.

Shader code
shader_type canvas_item;
void fragment(){
	vec3 palette[] = {vec3(0)}; // Can be any list of RGB colors, but there must be at least one.
	vec3 color = texture(TEXTURE,UV).rgb;
	vec3 new_color = palette[0];
	for (int i = 0; i<pallete.length(); i++){
		if (distance(palette[i],color) < distance(new_color, color)){
			new_color = palette[i];
		COLOR.rgb = new_color;
		COLOR.a  = texture(TEXTURE,UV).a
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Earthbound-like battle background shader w/scroll effect and palette cycling

Palette Filter For 3D and 2D

Palette Swap (no recolor / recolor)

Inline Feedbacks
View all comments