0 votes

enter image description here

How do I remove the black and keep the white using shaders?
Keep in mind I am new and text shaders are completely unreadable to me

Godot version 3.5.1
in Engine by (24 points)

1 Answer

0 votes
Best answer

If these are saved sprites then I would suggest manually editing them inside of an image editor and set the black to alpha. Save the image as rgba format and you should be good to go.

If you're looking for a shader that can do this then there's a few tutorials online already that should get you where you want but you need to keep in mind that every shader you use will suck resources. While this may not be a big issue for 2d games, some people might give you some hassle for wasting resources if you're able to just edit the images manually.

by (156 points)
selected by

I found the shader for it

shader_type canvas_item;

uniform vec4 u_color_key : hint_color;
uniform vec4 u_replacement_color : hint_color;
uniform float tolerance : hint_range(0.0, 1.0, 0.01);

void fragment() {
    vec4 col = texture(TEXTURE, UV);
    vec4 d4 = abs(col - u_color_key);
    float d = max(max(d4.r, d4.g), d4.b);
    if(d < tolerance) {
        col = u_replacement_color;
    }
    COLOR = col;
}
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.