Godot Version
Godot v4.3.stable
Question
I have a sprite that I want to be able to change to a flat colour, to make a silhouette during some scenes. I’m not wanting to tint the sprite I just want to cover the entire thing in a flat colour.
With modulate I can make a sprite completely black or white, or tint the sprite any colour, but in this specific case I want the silhouette to be a dark brown. Is there any good way to do this without using shaders? (I would be willing to use shaders but not if I can avoid it.
Thankyou.
shaders are the easy way
and I don’t think so you can do it with gdscript
Shaders. Or swap the texture with its silhouette version.
There’s also a shaderless trick. Parent a color rect to the sprite and set sprite’s clip_children to “Clip+Draw”. If the color rect is white you’ll be able to tint it with sprite’s modulate property.
I’m suprised there aren’t mixable versions of this on GodotShaders, Here’s one that accepts t, a transitional value so the color may be partially applied or fade out with an AnimationPlayer/Tween.
// CC0 hit flash
shader_type canvas_item;
uniform vec3 color: source_color = vec3(1.0);
uniform float t: hint_range(0.0, 1.0, 0.1) = 0.0;
void fragment() {
vec4 base = texture(TEXTURE, UV);
COLOR = vec4(mix(base.rgb, color, t), base.a);
}
1 Like