godfade.frag 346 B

123456789101112131415161718192021
  1. uniform sampler2D tex;
  2. uniform vec3 col;
  3. out vec4 FragColor;
  4. void main()
  5. {
  6. // Use quarter resolution
  7. vec2 uv = 4. * gl_FragCoord.xy / screen;
  8. vec4 res = texture(tex, uv);
  9. // Keep the sun fully bright, but fade the sky
  10. float mul = distance(res.xyz, col);
  11. mul = step(mul, 0.02);
  12. mul *= 0.97;
  13. res = res * vec4(mul);
  14. FragColor = res;
  15. }