Invert color

A simple shader which invert the colors of an object.

Shader code
shader_type canvas_item;

void fragment(){
	vec4 color = texture(TEXTURE, UV);
	COLOR = vec4(1.0 - color.rgb, color.a);
}
Tags
color effect, invert
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 godotshaders

Fireworks

2D fire

Simple 2D dissolve

Related shaders

Invert Color

Simple color invert area.

Invert color :DDD

Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Josh
Josh
3 years ago

Unfortunately this didn’t work for me as I’d hoped; It filled in the transparent parts of the image with white.

This did work for me though:

shader_type canvas_item;

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

		c.r=1.0-c.r;

		c.g=1.0-c.g;

		c.b=1.0-c.b;

		COLOR.rgba=c;

}
Last edited 3 years ago by Josh
Josh
Josh
3 years ago
Reply to  godotshaders

Great, thank you!