How do i delete a color from a sprite?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rustyStriker
:warning: Old Version Published before Godot 3 was released.

I got a texture for a sprite and I had like the delete the white from it to make it transparent so it wont overdraw the background

:bust_in_silhouette: Reply From: Zylann

Just delete the white pixels and leave it transparent in an image editor?

is there a way i can do it with shaders?

rustyStriker | 2016-08-15 18:05

Do you really need the white part of the image?
Anyways, here is a simple CanvasItemMaterial fragment shader that makes white pixels transparent:

vec4 col = tex(TEXTURE, UV);
if(col.rgb == vec3(1,1,1)) {
    col.a = 0;
}
COLOR = col * SRC_COLOR;

But I still think it would be much simpler if you open the image in Paint.NET / Photoshop / Gimp and make the areas you want transparent.

Zylann | 2016-08-15 19:06

Literally doesn’t work

PizzaMaker | 2022-11-27 15:15

This answer is 6 years old. It was for Godot 2.

Zylann | 2022-11-27 15:19