Ok, here's two different shaders I made. One that clips based on the background, and another that clips based on the objects color. Both of these shaders were written for Godot 2.1, and could probably use some fixes/performance boosts, since I made them back when I was experimenting with shaders.
Both of the shaders are fragment shaders.
Clips based on background
uniform color background=color(0.392157, 0.392157, 0.392157, 1);
uniform float range;
if (texscreen(SCREEN_UV).r >= background.r - range && texscreen(SCREEN_UV).r <= background.r + range)
{
if (texscreen(SCREEN_UV).g >= background.g - range && texscreen(SCREEN_UV).g <= background.g + range)
{
if (texscreen(SCREEN_UV).b >= background.b - range && texscreen(SCREEN_UV).b <= background.b + range)
{
COLOR.w *= 0;
}
else
{
COLOR.a = tex(TEXTURE, UV).a;
}
}
else
{
COLOR.a = tex(TEXTURE, UV).a;
}
}
else
{
COLOR.a = tex(TEXTURE, UV).a;
}
Clips based on object
uniform color Object_color;
uniform float Range;
if (texscreen(SCREEN_UV).r >= Object_color.r - Range && texscreen(SCREEN_UV).r <= Object_color.r + Range)
{
if (texscreen(SCREEN_UV).g >= Object_color.g - Range && texscreen(SCREEN_UV).g <= Object_color.g + Range)
{
if (texscreen(SCREEN_UV).b >= Object_color.b - Range && texscreen(SCREEN_UV).b <= Object_color.b + Range)
{
COLOR.a = tex(TEXTURE, UV).a;
}
else
{
COLOR.w *= 0;
}
}
else
{
COLOR.w *= 0;
}
}
else
{
COLOR.w *= 0;
}