antialiasFragment.fs 475 B

1234567891011121314151617181920
  1. #version 430
  2. layout (binding = 0) uniform sampler2D colorSamp;
  3. in vec2 varTex;
  4. out vec4 color;
  5. uniform int radius;
  6. void main() {
  7. vec2 texelSize = 1.0 / vec2(textureSize(colorSamp, 0));
  8. color = vec4(0.0, 0.0, 0.0, 0.0);
  9. for(float x = 0; x < radius; x++) {
  10. for(float y = 0; y < radius; y++) {
  11. vec2 offset = vec2(x, y) * texelSize;
  12. color += texture(colorSamp, varTex + offset);
  13. }
  14. }
  15. color /= (radius * radius);
  16. }