Guest User

Animate4x1.fp

a guest
Aug 8th, 2018
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. uniform float timer;
  2.  
  3. vec4 ProcessTexel()
  4. {
  5. vec4 finalTex = vec4(0.0,0.0,0.0,0.0);
  6. vec2 XY = vTexCoord.st;
  7. vec2 offset = vec2(0.0,0.0);
  8. vec4 tex0 = getTexel(XY);
  9.  
  10. //green channel off the initial texture color offsets timer
  11. float timer2 = timer * 0.1 + tex0.y;
  12.  
  13. //or as another example, the X position is used
  14. //float timer2 = timer * 0.1 + XY.x;
  15.  
  16. //needed as timer2 will be modified later
  17. float timer3 = timer2;
  18.  
  19. XY.x *= 0.25;
  20.  
  21. //ensures that only 1 image in the strip is visible at a time
  22. XY.x = mod(XY.x, 0.25);
  23.  
  24. //mirrors image because why not
  25. XY.x = 0.125 - abs(0.125 - XY.x);
  26.  
  27. vec2 XYtwo;
  28. XYtwo.x = XY.x;
  29. XYtwo.y = XY.y;
  30.  
  31. //animates image
  32. timer2 = floor(mod(timer2 * 4, 4)) * 0.25;
  33.  
  34. //first image
  35. XY.x += timer2;
  36.  
  37. //second image
  38. XYtwo.x = XY.x + 0.25;
  39. vec4 tex1 = getTexel(XY);
  40. vec4 tex2 = getTexel(XYtwo);
  41.  
  42. //blend factor. increases until 2nd image is completely visible.
  43. //when it goes back to 0, the 2nd image becomes the 1st image
  44. float mixrate = mod(timer3, 0.25) * 4;
  45.  
  46. finalTex = ((tex1 * (1 - mixrate)) + (tex2 * mixrate));
  47. return finalTex;
  48. }
RAW Paste Data