Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- glsl transition between colors.
- I pictured it as cutting the interval, as having a playback position inside of that interval ... sort of like movie frames.
- */
- vec3 frame(
- vec3 a, // start color
- vec3 b, // end color
- float t1, // start time
- float t2, // end time
- float t // time
- ) {
- vec3 x = vec3(0,0,0); // black so we have no color if we mix frames together
- if(t>=t1 && t<t2){
- x=mix(a,b,(t-t1)/(t2-t1));
- }
- return x;
- }
- void mainImage( out vec4 fragColor, in vec2 fragCoord )
- {
- // COLORS
- vec3 a=vec3(1,0,0);
- vec3 b=vec3(0,1,0);
- vec3 c=vec3(0,0,1);
- vec3 d=vec3(0,0,0);
- vec3 e=vec3(1,0,1);
- float PERIOD=9.;
- float t = mod(iTime,PERIOD); // 0..PERIOD
- vec3 col= // mix "movie frames"
- frame(a,b,0.,2.,t)+
- frame(b,c,2.,3.,t)+
- frame(c,d,3.,5.,t)+
- frame(d,e,5.,7.,t)+
- frame(e,a,7.,9.,t)+ // back to first color, so it loops smoothly
- vec3(0,0,0); // so we can copypaste previous lines and keep + at the end
- fragColor = vec4(col,1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement