2023-09-15 03:37:07 -05:00
|
|
|
@vs circle_vs
|
|
|
|
in vec2 vertex;
|
|
|
|
in vec2 apos;
|
|
|
|
in float aradius;
|
|
|
|
in vec4 acolor;
|
|
|
|
in float asegsize;
|
|
|
|
in float afill;
|
2022-06-21 23:16:14 -05:00
|
|
|
|
2023-09-15 03:37:07 -05:00
|
|
|
out vec2 coords;
|
|
|
|
out vec4 fcolor;
|
|
|
|
out float segsize;
|
|
|
|
out float fill;
|
|
|
|
out float radius;
|
2022-06-21 23:16:14 -05:00
|
|
|
|
2023-09-15 03:37:07 -05:00
|
|
|
uniform cvs_params { mat4 proj; };
|
2023-05-24 20:45:50 -05:00
|
|
|
|
2023-09-15 03:37:07 -05:00
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_Position = proj * vec4((vertex * aradius) + apos, 0.0, 1.0);
|
|
|
|
coords = vertex;
|
|
|
|
fcolor = acolor;
|
|
|
|
segsize = asegsize;
|
|
|
|
fill = afill;
|
|
|
|
radius = aradius;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@fs circle_fs
|
2022-06-21 23:16:14 -05:00
|
|
|
|
2023-09-15 03:37:07 -05:00
|
|
|
out vec4 color;
|
|
|
|
|
|
|
|
in vec2 coords;
|
|
|
|
in vec4 fcolor;
|
2023-05-24 20:45:50 -05:00
|
|
|
in float segsize;
|
|
|
|
in float fill;
|
2023-09-15 03:37:07 -05:00
|
|
|
in float radius;
|
2023-05-24 20:45:50 -05:00
|
|
|
|
|
|
|
#define PI 3.14
|
|
|
|
|
2022-06-21 23:16:14 -05:00
|
|
|
void main()
|
|
|
|
{
|
2023-12-15 12:45:09 -06:00
|
|
|
float px = 1/radius;
|
|
|
|
float R1 = 1.f;
|
|
|
|
float R2 = 1.0 - fill;
|
|
|
|
float dist = sqrt(pow(coords.x,2) + pow(coords.y,2));
|
|
|
|
color = fcolor;
|
|
|
|
|
|
|
|
float sm = 1 - smoothstep(R1-px,R1,dist);
|
|
|
|
float sm2 = smoothstep(R2-px,R2,dist);
|
|
|
|
float a = sm*sm2;
|
|
|
|
color = mix(vec4(0,0,0,0), fcolor, a);
|
2023-12-20 17:20:29 -06:00
|
|
|
|
|
|
|
if (segsize<0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
float f = atan(coords.y, coords.x) + PI;
|
|
|
|
|
|
|
|
if (mod(f, segsize) < segsize/2)
|
|
|
|
discard;
|
2023-02-26 08:03:21 -06:00
|
|
|
}
|
2023-09-15 03:37:07 -05:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@program circle circle_vs circle_fs
|