+1 vote

I am trying to outline a certain piece of text with a single specific color. This is for a game that has a restricted color pallete.

I have a Label with a theme that modifies the default font. I set the "Outline Color" of the DynamicFont to my desired color and have an Outline size of 2.

Notice the feathering around the outline

However, as it is, the outline is not a solid color - It behaves like a shadow and will make up extra colors to feather out the edges:

How to I modify this so that the outline is a single color?

P.S. There seems to be a property called "Shadow As Outline" which appears to be related to the problem, but changing this value (or any other constants in this category) from the default 0 does not seem to have any effect.

in Engine by (29 points)

1 Answer

+1 vote

The way I've fixed this issue is by stepping the alpha value at a certain threshold. Which means that transparent pixels will be either completely opaque or completely invisible.

shader_type canvas_item;

void fragment() {
    float alpha = texture(TEXTURE, UV).a;
    COLOR.a = step(0.5, alpha);
}

example of transparent outline
before
result of applying the shader
after

by (16 points)
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.