diff --git a/gltiles.vert b/gltiles.vert index d5a0d210..9d4b0568 100644 --- a/gltiles.vert +++ b/gltiles.vert @@ -43,6 +43,8 @@ uniform LayerParams { in uint layerID; in vec4 pos; +in vec4 pos_to; +in vec3 anim; // x=start_time, y=duration, z=mode out float sheetLayer; out mat3 tileTransform; @@ -54,6 +56,32 @@ const mat3 spinOffset = mat3( ); void main(void) { + vec4 pos_at = pos; + + if (anim_enabled && anim.y > 0.0) { + float a = (anim_time - anim.x) / anim.y; + if (a > 0.0) { + switch (int(anim.z)) { + + case 1: // loop + a = fract(a); + break; + + case 2: // loop-back + if (int(floor(a)) % 2 == 1) { + a = 1.0 - fract(a); + } else { + a = fract(a); + } + break; + + default: + a = max(0.0, min(1.0, a)); + } + pos_at = mix(pos_at, pos_to, /*a*/ 0.0); + } + } + vec2 offset = pos.xy; float spin = pos.z; float scale = pos.w;