2022-03-21 12:10:47 +00:00
|
|
|
#version 140
|
|
|
|
|
|
|
|
const vec3 back_color_dark = vec3(0.235, 0.235, 0.235);
|
|
|
|
const vec3 back_color_light = vec3(0.365, 0.365, 0.365);
|
|
|
|
|
2022-03-22 14:35:02 +00:00
|
|
|
uniform sampler2D in_texture;
|
2022-03-21 12:10:47 +00:00
|
|
|
uniform bool transparent_background;
|
|
|
|
uniform bool svg_source;
|
|
|
|
|
|
|
|
in vec2 tex_coord;
|
2022-03-22 14:35:02 +00:00
|
|
|
out vec4 frag_color;
|
2022-03-21 12:10:47 +00:00
|
|
|
|
|
|
|
vec4 svg_color()
|
|
|
|
{
|
|
|
|
// takes foreground from texture
|
2022-03-22 14:35:02 +00:00
|
|
|
vec4 fore_color = texture(in_texture, tex_coord);
|
2022-03-21 12:10:47 +00:00
|
|
|
|
|
|
|
// calculates radial gradient
|
|
|
|
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(tex_coord.xy) - vec2(0.5)))));
|
|
|
|
|
|
|
|
// blends foreground with background
|
|
|
|
return vec4(mix(back_color, fore_color.rgb, fore_color.a), transparent_background ? fore_color.a : 1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
vec4 non_svg_color()
|
|
|
|
{
|
|
|
|
// takes foreground from texture
|
2022-03-22 14:35:02 +00:00
|
|
|
vec4 color = texture(in_texture, tex_coord);
|
2022-03-21 12:10:47 +00:00
|
|
|
return vec4(color.rgb, transparent_background ? color.a * 0.25 : color.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2022-04-11 06:38:09 +00:00
|
|
|
vec4 color = svg_source ? svg_color() : non_svg_color();
|
|
|
|
color.a = transparent_background ? color.a * 0.5 : color.a;
|
|
|
|
frag_color = color;
|
2022-03-21 12:10:47 +00:00
|
|
|
}
|