0
$\begingroup$

I want to make "trails" of objects on my shader that appear and disappear gradually.

I am getting pixels (for fragment shader) where objects are from uniform texture.

Basically, I have my TARGET_ALPHA for alpha for this pixel.

How can I interpolate over time (1 second) current alpha for pixel to TARGET_ALPHA?

I can't understand how to achieve this. I tried

ALPHA = mix(ALPHA, TARGET_ALPHA, 0.01); // mix is lerp in godot shader language

But it won't work like it's some kind of ordinary game engine code, because ALPHA won't retain it's value every call of shader function and value stays the same.

I assume something can be done with TIME but I don't understand what. I tried sin(TIME) etc, but it just makes value go up and down, and I want to achieve interpolation without it going back. So my ALPHA would just always follow TARGET_ALPHA with interpolation.

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.