+1 vote

Yeah, so... I want to set the Modulate property of a sprite to make it white for a second, but it does not seem possible.
How can I do that?

in Engine by (570 points)

2 Answers

+2 votes
Best answer

A couple of things you could do…

Simple way would be to load a new white texture for the sprite through your code at the desired time and then set it back to the original texture after a second.

If you want cooler effects, you could have a second sprite that is a white silhouette that overlays your normal sprite, but has an alpha value of 0. Then you could tween the alpha to 1 over a few milliseconds, leave it white for a sec and tween it back down to 0. You could expand upon it in lots of ways depending on the effect you are looking for.

by (312 points)
selected by

Interesting solution, I'll try it!

+3 votes

"Modulate" is a color multiplier, so there is no way to make a sprite brighter with it. It is a bit hackable though, because you can input colors higher than 1 by toggling RAW mode on (usually for HDR and bloom). This will brighten your sprite, but it won't work if your sprite is too dark, or black for example.

If you are looking for a cleaner solution, you can use a shader to interpolate the sprite regular texture and a white color, with a uniform parameter:

shader_type canvas_item;

uniform float whitening;

void fragment() {
    vec4 texture_color = texture(TEXTURE, UV);
    COLOR = vec4(mix(texture_color.rgb, vec3(1,1,1), whitening), texture_color.a);
by (29,090 points)
edited by

Thank you! I should dig deeper into shaders

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.