Fade sprite after rotation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TobiLa

Hey,
I am using the following shader to make my sprite fade out at the bottom:

shader_type canvas_item;

uniform float progress : hint_range(0,1); uniform float clip_height =
0.05;

void fragment(){
    vec4 main_texture = texture(TEXTURE, UV);
    //main_texture.a *= 1.0 - step(1.0 - progress, UV.y); 	main_texture.a *= 1.0 - smoothstep(1.0 - progress - clip_height,1.0 - progress + clip_height, UV.y);
    COLOR = main_texture; }

Now when I add rotation, my fade effect gets rotated with it as the shader seems to be applied before the rotation:

enter image description here

How can I achieve that my rotated object has an even fade effect from bottom to top even when rotated, so it looks like this?

Thanks for your help!

:bust_in_silhouette: Reply From: Anemony

Could you add the rotating node as a child of another, then only rotate the child and fade out the parent? I haven’t tested this, but I would think that the fade would use the un-rotated transform of the parent while the child happily rotated away!

I am also unsure, but this idea sounds promising

godot_dev_ | 2022-08-03 15:37

Tried this already with a node2D parent, but assigning the shader the it doesn’t fade anything.

TobiLa | 2022-08-03 15:37