0 votes

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 =

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?

enter image description here

Thanks for your help!

Godot version 3.4.4 stable
in Engine by (196 points)

1 Answer

0 votes

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!

by (21 points)

I am also unsure, but this idea sounds promising

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

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.