+1 vote

Note: doing a 2D project. in Godot 3.0.6

I noticed that the Modulate property can only brighten the sprite even if I set the color value higher than 1.0.

It doesn't help me since I have sprites with black(#000000) parts in them and they have to flash between white silhouette.

I tried:

Does anyone have a solution for this?

it's ridiculous to draw multiple white textures for each sprite animation frame.

in Engine by (16 points)

Why you don't use animatedSprite?

I don't see how you could avoid creating white texture variants for most things. As pallet swaps are no longer supported in modern hardware.

You can use shaders to do palette swaps fairly easily.

1 Answer

+2 votes

For anyone who was still searching for a solution to this (like me) as there is no easy way to do this exact thing yet, here is my solution:

  1. Add a new ShaderMaterial to the Sprite you want to flash (if it
    already has a shader attached you can just add the code below to
    it).
  2. Add a new Shader (not VisualShader) to the material.
  3. Open the shader and add the following code:

.

shader_type canvas_item;

uniform float white_progress : hint_range(0,1) = 0;

vec3 interpolate_vec3(vec3 start, vec3 end, float delta){
    return start + (end - start) * delta;
}

void fragment(){
    vec4 origin = texture(TEXTURE, UV);
    COLOR.rgb = interpolate_vec3(origin.rgb, vec3(1,1,1), white_progress);
    COLOR.a = origin.a;
}

Now you can use an AnimationPlayer to change the "white_progress" in "Shader Param" to create a flashing sprite.

by (18 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 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 webmaster@godotengine.org with your username.