Swap Color

Shader code
shader_type canvas_item;

uniform vec4 new : source_color;

void fragment() {
	vec4 current_pixel = texture(TEXTURE,UV);
	vec4 current_pixel2 = texture(TEXTURE,UV);
	if (current_pixel == current_pixel2)
		COLOR.rgb = new.rgb * current_pixel.g; 
	else
		COLOR = current_pixel;
}
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 Timesi

Normal map 2D

Related shaders

Color Swap with Hue Variation Preservation

Color Range Swap [UPDATED]

Palette Swap using two textures

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
denis23x
1 month ago

Hi 👋 I used this shader for my first Godot game! Please check it out

https://denis23x.itch.io/deepwood 

I’ve linked you in the game description, in the game itself and in the game repository, thanks for the materials you provided 🙏

https://github.com/denis23x/deepwood