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.

38 lines
1.0 KiB

  1. #version 100
  2. precision mediump float;
  3. // Input vertex attributes (from vertex shader)
  4. varying vec2 fragTexCoord;
  5. varying vec4 fragColor;
  6. // Input uniform values
  7. uniform sampler2D texture0;
  8. uniform vec4 colDiffuse;
  9. // NOTE: Add here your custom variables
  10. const vec2 size = vec2(800, 450); // render size
  11. const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance
  12. const float quality = 2.5; // lower = smaller glow, better quality
  13. void main()
  14. {
  15. vec4 sum = vec4(0);
  16. vec2 sizeFactor = vec2(1)/size*quality;
  17. // Texel color fetching from texture sampler
  18. vec4 source = texture2D(texture0, fragTexCoord);
  19. const int range = 2; // should be = (samples - 1)/2;
  20. for (int x = -range; x <= range; x++)
  21. {
  22. for (int y = -range; y <= range; y++)
  23. {
  24. sum += texture2D(texture0, fragTexCoord + vec2(x, y)*sizeFactor);
  25. }
  26. }
  27. // Calculate final fragment color
  28. gl_FragColor = ((sum/(samples*samples)) + source)*colDiffuse;
  29. }