Topic was automatically imported from the old Question2Answer platform.
Asked By
Teln0
I got a CS script that overrides the _Draw() method of Node2D to display text. When I tried to add a canvas_item shader to it, it gave me weird results. Here’s the shader code :
shader_type canvas_item;
void vertex() {
COLOR = COLOR;
}
The issue was that we were taking all the pixels in the character’s box (or something similar, I don’t fully understand the backend here) and assigning them to some value regardless of whether or not they were part of the letter or transparent. We need to modify the white text by our desired color, not replace it.
Multiplication might not be the best way to modify the pixels, but it works well enough for me, and I’m too tired from figuring this simple solution out to work through the arithmetic.
You should be able to set_shader_param() a Color to this color (since Godot will translate a Color to a vec4) directly.
Hope this helps!
You’d think someone must have tried to make a shader in Godot and found this out and published it, but I can’t find it!