#blend mix #primitive triangle #cull none #depth off @vs vert in vec3 a_pos; uniform float radius; uniform vec2 coord; uniform mat4 vp; out vec2 coords; out float rad; void main() { vec3 pos = a_pos; pos.xy -= 0.5; pos.xy *= 2; coords = pos.xy; pos *= radius; pos.xy += coord; rad = radius; gl_Position = vp * vec4(pos,1); } @end @fs frag in vec2 coords; in float rad; uniform vec4 shade; uniform float inner_r; out vec4 color; void main() { float px = 1/rad; float blur = 1.0+px; float R = 1; float R2 = 1-inner_r; float dist = distance(vec2(0,0),coords); float sm = 1 - smoothstep(R-px,R*blur,dist); float sm2 = smoothstep(R2-px,R2*blur,dist); float alpha = sm*sm2; color = vec4(shade.xyz, alpha*shade.a); } @end @program circle vert frag