Hey! I was trying shaders for the first time because I wanted to know how to invert the colors of my game.
The approach I came up with was including a ColorRect node to my HUD and then adding a material shader with the following code:
shader_type canvas_item;
render_mode unshaded;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture;
void fragment() {
vec4 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgba;
c.rgb = 1.0 - c.rgb;
COLOR = c;
}
That worked fine, but the change happens instantly and I don't quite like the sudden result. For that reason, I searched how to make a smooth transition with shaders and I found the smoothstep
function, but when using it I don't see any changes. My idea was to smoothly change the alpha value making the shader visible. Like this:
c.a = smoothstep(0.0, 1.0, c.a);
Anyone that knows about this more than me could help? Thanks!