prosperon/shaders/circle.cg

45 lines
717 B
Plaintext
Raw Permalink Normal View History

2024-05-30 17:12:54 -05:00
#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;
out vec4 color;
void main() {
float px = 1/rad;
float R = 1;
float R2 = 0.90;
float dist = sqrt(dot(coords,coords));
float sm = 1 - smoothstep(R-px,R,dist);
float sm2 = smoothstep(R2-px,R2,dist);
float alpha = sm*sm2;
color = vec4(shade.xyz, alpha*alpha);
}
@end
@program circle vert frag