31 lines
913 B
GLSL
31 lines
913 B
GLSL
vec3 circle(in vec2 _st, in float _radius, vec3 color){
|
|
vec2 dist = _st-vec2(0.5);
|
|
return color-smoothstep(_radius-(_radius*0.02),
|
|
_radius+(_radius*0.02),
|
|
dot(dist,dist)*4.0);
|
|
}
|
|
|
|
vec3 box(vec2 width, vec2 height) {
|
|
height = vec2(0.5) - height*0.5;
|
|
vec2 he = height+0.001;
|
|
vec2 uv = smoothstep(height, he, width);
|
|
uv *= smoothstep(height, he, vec2(1.0)-width);
|
|
return vec3(uv.x*uv.y);
|
|
}
|
|
|
|
// Inspired by (but modified)
|
|
// http://thndl.com/square-shaped-shaders.html
|
|
#define TAU 6.28318530718
|
|
vec3 polygon(int n, float size, vec2 pos, vec3 color, float rot) {
|
|
float e = 0.01;
|
|
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
|
st.x *= u_resolution.x/u_resolution.y;
|
|
st = (st-pos)*2.;
|
|
float a = atan(st.x,st.y)+rot;
|
|
float r = TAU/float(n);
|
|
|
|
float d = cos(floor(.5+a/r)*r-a)*length(st);
|
|
|
|
return color-smoothstep(size-e,size+e,d);
|
|
}
|