circle.fs 565 B

12345678910111213141516171819202122232425
  1. #version 120
  2. // Input vertex attributes (from vertex shader)
  3. varying vec2 fragTexCoord;
  4. varying vec4 fragColor;
  5. uniform float radius;
  6. uniform float power;
  7. void main()
  8. {
  9. float r = radius;
  10. vec2 p = fragTexCoord - vec2(0.5);
  11. if (length(p) <= 0.5) {
  12. float s = length(p) - r;
  13. if (s <= 0) {
  14. gl_FragColor = fragColor*1.5;
  15. } else {
  16. float t = 1 - s / (0.5 - r);
  17. gl_FragColor = mix(vec4(fragColor.xyz, 0), fragColor*1.5, pow(t, power));
  18. }
  19. } else {
  20. gl_FragColor = vec4(0);
  21. }
  22. }