prosperon/source/shaders/gridfrag.glsl

29 lines
449 B
Plaintext
Raw Normal View History

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;
2023-05-16 01:31:13 -05:00
2023-05-12 13:22:05 -05:00
uniform float thickness; /* thickness in pixels */
uniform float span;
2023-05-16 01:31:13 -05:00
uniform vec4 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;
2023-05-16 01:31:13 -05:00
vec2 bpos;
2023-05-12 13:22:05 -05:00
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;
2023-05-16 01:31:13 -05:00
frag_color = color;
2023-05-12 13:22:05 -05:00
}