2022-06-21 23:16:14 -05:00
|
|
|
#version 330
|
2023-05-12 13:22:05 -05:00
|
|
|
out vec4 frag_color;
|
2022-06-21 23:16:14 -05:00
|
|
|
|
|
|
|
in vec2 apos;
|
|
|
|
vec2 bpos;
|
2023-05-12 13:22:05 -05:00
|
|
|
uniform float thickness; /* thickness in pixels */
|
|
|
|
uniform float span;
|
|
|
|
uniform vec3 color;
|
2022-06-21 23:16:14 -05:00
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
2023-05-12 13:22:05 -05:00
|
|
|
float t = thickness / span;
|
|
|
|
t /= 2.0;
|
|
|
|
bpos.x = mod(apos.x, span) / span;
|
|
|
|
bpos.y = mod(apos.y, span) / span;
|
|
|
|
bpos.x -= t;
|
|
|
|
bpos.y -= t;
|
2022-06-21 23:16:14 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
float comp = min(bpos.x, bpos.y);
|
2022-06-21 23:16:14 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
if (comp > t)
|
|
|
|
discard;
|
|
|
|
|
|
|
|
comp += t;
|
|
|
|
|
|
|
|
frag_color = vec4(color, 1.0);
|
|
|
|
}
|