uniform float loopDuration;
uniform float time;
void main()
{
float timeScale = 3.14159f * 2.0f / loopDuration;
float currTime = mod(time, loopDuration);
vec4 totalOffset = vec4(cos(currTime * timeScale) * 0.5f,
sin(currTime * timeScale) * 0.5f,
0.0f,
0.0f);
gl_Position = vec4(vertexPosition,1.0) + totalOffset;
}
triangle.frag
#version 400
out vec4 fragColor;
uniform float fragLoopDuration;
uniform float time;
const vec4 firstColor =vec4(1.0f, 0.0f, 0.0f, 1.0f);
const vec4 secondColor =vec4(0.0f, 1.0f, 0.0f, 1.0f);
void main(){
float currentTime =mod(time, fragLoopDuration);
float currentLerp =currentTime/fragLoopDuration;
fragColor =mix(firstColor, secondColor, currentLerp);
}