scanlines.fs 712 B

1234567891011121314151617181920212223242526
  1. #version 330 core
  2. out vec4 FragColor;
  3. in vec2 TexCoords;
  4. uniform sampler2D screenTexture;
  5. uniform vec3 screenSize;
  6. uniform bool screenBurn;
  7. void main()
  8. {
  9. vec3 col = texture(screenTexture, TexCoords).rgb;
  10. float scanLine = mod(gl_FragCoord.y, 2.0) * 0.25;
  11. vec3 scanColor = col.rgb - scanLine;
  12. if (col.r < 0.1f && col.g < 0.1f && col.b < 0.1f) {
  13. if (screenBurn) {
  14. float dist = (1.0 - distance(vec2(gl_FragCoord.x / screenSize.x, gl_FragCoord.y / screenSize.y), vec2(0.5,0.5))) * 0.2;
  15. FragColor = vec4(0.0, dist, dist, 1.0);
  16. } else {
  17. FragColor = vec4(0.0, 0.0, 0.0, 1.0);
  18. }
  19. } else {
  20. FragColor = vec4(scanColor, 1.0);
  21. }
  22. }