float circle(in vec2 _st, in float _radius){ vec2 dist = _st-vec2(0.5); return 1.-smoothstep(_radius-(_radius*0.01), _radius+(_radius*0.01), dot(dist,dist)*4.0);}float box(in vec2 _st, in vec2 _size){ _size = vec2(0.5) - _size*0.5; vec2 uv = smoothstep(_size, _size+vec2(0.001), _st); uv *= smoothstep(_size, _size+vec2(0.001), vec2(1.0)-_st); return uv.x*uv.y;}float cross(in vec2 _st, float _size){ return box(_st, vec2(_size,_size/4.)) + box(_st, vec2(_size/4.,_size));}float lines(in vec2 pos, float b){ float scale = 10.0; pos *= scale; return smoothstep(0.0, .5+b*.5, abs((sin(pos.x*3.1415)+b*2.0))*.5);}//
float shape(vec2 st, float radius) { st = vec2(0.5)-st; float r = length(st)*2.0; float a = atan(st.y,st.x); float m = abs(mod(a+u_time*2.,3.14*2.)-3.14)/3.6; float f = radius; m += noise(st+u_time*0.1)*.5; // a *= 1.+abs(atan(u_time*0.2))*.1; // a *= 1.+noise(st+u_time*0.1)*0.1; f += sin(a*50.)*noise(st+u_time*.2)*.1; f += (sin(a*20.)*.1*pow(m,2.)); return 1.-smoothstep(f,f+0.007,r);}float shapeBorder(vec2 st, float radius, float width) { return shape(st,radius)-shape(st,radius-width);}//
mat2 rotate2d(float _angle){ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle));}mat2 scale(vec2 _scale){ return mat2(_scale.x,0.0, 0.0,_scale.y);}vec2 tile(vec2 _st, float _zoom){ _st *= _zoom; return fract(_st);}vec2 brickTile(vec2 _st, float _zoom){ _st *= _zoom; // Here is where the offset is happening _st.x += step(1., mod(_st.y,2.0)) * 0.5; return fract(_st);}vec2 truchetPattern(in vec2 _st, in float _index){ _index = fract(((_index-0.5)*2.0)); if (_index > 0.75) { _st = vec2(1.0) - _st; } else if (_index > 0.5) { _st = vec2(1.0-_st.x,_st.y); } else if (_index > 0.25) { _st = 1.0-vec2(1.0-_st.x,_st.y); } return _st;}float random (vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898,78.233)))* 43758.5453123);}// Based on Morgan McGuire @morgan3d// https://www.shadertoy.com/view/4dS3Wdfloat noise (in vec2 _st) { vec2 i = floor(_st); vec2 f = fract(_st); // Four corners in 2D of a tile float a = random(i); float b = random(i + vec2(1.0, 0.0)); float c = random(i + vec2(0.0, 1.0)); float d = random(i + vec2(1.0, 1.0)); vec2 u = f * f * (3.0 - 2.0 * f); return mix(a, b, u.x) + (c - a)* u.y * (1.0 - u.x) + (d - b) * u.x * u.y;}vec2 random2(vec2 st){ st = vec2( dot(st,vec2(127.1,311.7)), dot(st,vec2(269.5,183.3)) ); return -1.0 + 2.0*fract(sin(st)*43758.5453123);}float noise (in vec2 st) { vec2 i = floor(st); vec2 f = fract(st); // Four corners in 2D of a tile float a = random(i); float b = random(i + vec2(1.0, 0.0)); float c = random(i + vec2(0.0, 1.0)); float d = random(i + vec2(1.0, 1.0)); // Smooth Interpolation // Cubic Hermine Curve. Same as SmoothStep() vec2 u = f*f*(3.0-2.0*f); // u = smoothstep(0.,1.,f); // Mix 4 coorners percentages return mix(a, b, u.x) + (c - a)* u.y * (1.0 - u.x) + (d - b) * u.x * u.y;}#define NUM_OCTAVES 5float fbm ( in vec2 _st) { float v = 0.0; float a = 0.5; vec2 shift = vec2(100.0); // Rotate to reduce axial bias mat2 rot = mat2(cos(0.5), sin(0.5), -sin(0.5), cos(0.50)); for (int i = 0; i < NUM_OCTAVES; ++i) { v += a * noise(_st); _st = rot * _st * 2.0 + shift; a *= 0.5; } return v;}float plot(vec2 p, float v){ return smoothstep( v-0.02, v, p.y) - smoothstep( v, v+0.02, p.y);}