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.

45 lines
1016 B

  1. #version 330
  2. // Input vertex attributes (from vertex shader)
  3. in vec2 fragTexCoord;
  4. in vec4 fragColor;
  5. // Input uniform values
  6. uniform sampler2D texture0;
  7. uniform vec4 fragTintColor;
  8. // Output fragment color
  9. out vec4 finalColor;
  10. // NOTE: Add here your custom variables
  11. const float renderWidth = 800.0; // HARDCODED for example!
  12. const float renderHeight = 480.0; // Use uniforms instead...
  13. float radius = 250.0;
  14. float angle = 0.8;
  15. uniform vec2 center = vec2(200.0, 200.0);
  16. void main()
  17. {
  18. vec2 texSize = vec2(renderWidth, renderHeight);
  19. vec2 tc = fragTexCoord*texSize;
  20. tc -= center;
  21. float dist = length(tc);
  22. if (dist < radius)
  23. {
  24. float percent = (radius - dist)/radius;
  25. float theta = percent*percent*angle*8.0;
  26. float s = sin(theta);
  27. float c = cos(theta);
  28. tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
  29. }
  30. tc += center;
  31. vec3 color = texture(texture0, tc/texSize).rgb;
  32. finalColor = vec4(color, 1.0);;
  33. }