49 lines
640 B
Plaintext
49 lines
640 B
Plaintext
@vs vs
|
|
in vec2 pos;
|
|
|
|
out vec2 apos;
|
|
|
|
uniform mpara {
|
|
uniform vec2 offset;
|
|
uniform vec2 dimen;
|
|
};
|
|
|
|
void main()
|
|
{
|
|
apos = ((pos*0.5)*dimen) + offset;
|
|
|
|
gl_Position = vec4(pos, 0.f, 1.f);
|
|
}
|
|
@end
|
|
|
|
@fs fs
|
|
out vec4 frag_color;
|
|
in vec2 apos;
|
|
uniform fs_params {
|
|
uniform float thickness;
|
|
uniform float span;
|
|
uniform vec4 color;
|
|
};
|
|
|
|
void main()
|
|
{
|
|
float t = thickness / span;
|
|
t /= 2.0;
|
|
vec2 bpos;
|
|
bpos.x = mod(apos.x, span) / span;
|
|
bpos.y = mod(apos.y, span) / span;
|
|
bpos.x -= t;
|
|
bpos.y -= t;
|
|
|
|
float comp = min(bpos.x, bpos.y);
|
|
|
|
if (comp > t)
|
|
discard;
|
|
|
|
comp += t;
|
|
|
|
frag_color = color;
|
|
}
|
|
@end
|
|
|
|
@program grid vs fs |