I'd like to try and use a shader to do 2D facial animations, like raise a character's eyebrows or purse their lips a bit. Is it possible to mathematically "pause" a shader animation? For example I can pass a parameter 1 or 0 as an on/off for the shader animation, but it snaps back to the original position when I pass 0. Can I use a state machine in the shader to tell to to gracefully continue the animation until the vertex returns to its original position? Seems like the problem I am having is the VERTEX doesn't have knowledge of its frame in the precious position. Or am I going about this the wrong way and I would need to have the state machine in my game script that instead of passing 1 or 0, passes 1 then 0.9 then 0.8 etc to slowly turn the shader animation "off".
This is all new to me, I'm really just looking for a way to programmatically animate to make it dynamic and reusable for various assets.
void vertex() {
//onoff gets set in game script
float value = sin(TIME * (1.0)) * 100.0;
if (VERTEX.y <= -100.0) {
float originalX = VERTEX.x;
VERTEX += vec2(value * onoff, 0);
}
}