simple shader program for testing purposes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.3KB

  1. #version 110
  2. // Uniforms
  3. uniform int Ticks;
  4. // Constants
  5. // - Math
  6. const float pi = 3.1415926535897932384626433832795;
  7. // - Resolution
  8. const vec2 res = vec2(640.0, 480.0);
  9. const vec2 wh = vec2(256.0, 224.0);
  10. const float w = wh.x;
  11. const float h = wh.y;
  12. // - Border
  13. const float borderx = wh.x / 16.0;
  14. const float bordery = wh.y / 8.0;
  15. // Variables
  16. // - Timer
  17. float t = float(Ticks) / 32.0;
  18. float tbx = sin(t / 8.0);
  19. float tby = cos(t / 8.0);
  20. float tcx = sin(t / 3.0);
  21. float tcy = cos(t / 2.0);
  22. float tsx = sin(t / 48.0);
  23. // Functions
  24. // - Main
  25. void main()
  26. {
  27. vec2 uv = (gl_FragCoord.xy / res) * wh;
  28. float x = uv.x;
  29. float y = uv.y;
  30. float bx;
  31. float by;
  32. float v;
  33. if(y < bordery)
  34. {
  35. gl_FragColor = vec4(0.0, 0.0, (1.0 - (y / bordery)) * 0.5, 1.0);
  36. return;
  37. }
  38. if(y >= h - bordery)
  39. {
  40. gl_FragColor = vec4(0.0, 0.0, (1.0 - ((h - y) / bordery)) * 0.5, 1.0);
  41. return;
  42. }
  43. if(x < borderx || x >= w - borderx)
  44. {
  45. gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
  46. return;
  47. }
  48. bx = x + 0.5 * tbx;
  49. by = y + 0.5 * tby;
  50. v = sin((-bx + t) / 32.0);
  51. v += cos((by + t) / 32.0);
  52. v += sin((-bx + by + t) / 32.0);
  53. v += sin((sqrt(pow(bx + tcx, 2.0) + pow(by + tcy, 2.0) + 1.0) + t) / 128.0);
  54. gl_FragColor.r = sin(v * pi) * 0.5 + 0.5;
  55. gl_FragColor.g = cos(v * pi) * 0.5 + 0.5;
  56. gl_FragColor.g *= 0.6;
  57. gl_FragColor.b = abs(tsx * 0.25);
  58. gl_FragColor.a = 0.0;
  59. }