printbed.fs 612 B

1234567891011121314151617181920
  1. #version 110
  2. const vec3 back_color_dark = vec3(0.235, 0.235, 0.235);
  3. const vec3 back_color_light = vec3(0.365, 0.365, 0.365);
  4. uniform sampler2D texture;
  5. uniform bool transparent_background;
  6. varying vec2 tex_coords;
  7. void main()
  8. {
  9. // calculates radial gradient
  10. vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(tex_coords.xy) - vec2(0.5)))));
  11. vec4 fore_color = texture2D(texture, tex_coords);
  12. // blends foreground with background
  13. gl_FragColor = vec4(mix(back_color, fore_color.rgb, fore_color.a), transparent_background ? fore_color.a : 1.0);
  14. }