prosperon/source/shaders/circlefrag.glsl

39 lines
635 B
Plaintext
Raw Normal View History

2022-06-21 23:16:14 -05:00
#version 330
in vec2 coords;
out vec4 color;
2023-05-24 20:45:50 -05:00
2023-05-12 13:22:05 -05:00
in float radius;
2023-05-16 01:31:13 -05:00
in vec4 fcolor;
2023-05-12 13:22:05 -05:00
in vec2 pos;
2022-06-21 23:16:14 -05:00
2023-05-24 20:45:50 -05:00
in float segsize;
in float fill;
#define PI 3.14
2022-06-21 23:16:14 -05:00
void main()
{
2023-05-24 20:45:50 -05: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;
// if (dist < R2 || dist > R1)
// discard;
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);
if (segsize<0)
return;
float f = atan(coords.y, coords.x) + PI;
if (mod(f, segsize) < segsize/2)
discard;
}