Desaturation Shader

Very simple 2D Desaturation Shader based on color perception that keep the overal “brightness” of the sprite. You can adjust the desaturation using the “saturation” uniform.

 

Shader code
shader_type canvas_item;

uniform float saturation;

void fragment() {
    vec4 tex_color = texture(TEXTURE, UV);

    COLOR.rgb = mix(vec3(dot(tex_color.rgb, vec3(0.299, 0.587, 0.114))), tex_color.rgb, saturation);
	COLOR.a = tex_color.a;
}
Tags
Color, Desaturation
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.

More from ombarus

Pixelated Glitch PostEffect

Related shaders

Voronoi Synapse-ish Background Shader

Kuwahara Shader

Colorblindness correction shader

guest

0 Comments
Inline Feedbacks
View all comments