add pseudo signed distance field rendering
[voxelands-alt.git] / data / shaders / ui_fragment.glsl
blob0dc19e53ebdcf0d772eee2077fe81d57aff251d2
1 #version 330 core
3 in vec2 uv;
5 out vec4 out_Colour;
7 uniform sampler2D tex;
8 uniform float alphafunc;
10 void main(void) {
12         out_Colour = texture(tex,uv);
13         if (alphafunc > 1.5) {
14                 float a0 = out_Colour.a;
15                 float a1 = texture(tex,uv+vec2(-0.001,-0.001)).a;
16                 float a2 = texture(tex,uv+vec2(-0.001,0.0)).a;
17                 float a3 = texture(tex,uv+vec2(-0.001,0.001)).a;
18                 float a4 = texture(tex,uv+vec2(0.0,-0.001)).a;
19                 float a5 = texture(tex,uv+vec2(0.0,0.001)).a;
20                 float a6 = texture(tex,uv+vec2(0.001,-0.001)).a;
21                 float a7 = texture(tex,uv+vec2(0.001,0.0)).a;
22                 float a8 = texture(tex,uv+vec2(0.001,0.001)).a;
23                 out_Colour.a = smoothstep(0.45,0.55,(a0+a1+a2+a3+a4+a5+a6+a7+a8)/9.0);
24         }else if (alphafunc > 0.5) {
25                 out_Colour.a = smoothstep(0.45,0.55,out_Colour.a);
26         }