frag = await glsl`
#extension GL_OES_standard_derivatives : enable
${shader}
#pragma glslify: random = require('glsl-random')
float wireframe (float parameter, float width, float feather) {
float w1 = width - feather * 0.5;
float d = fwidth(parameter);
// float looped = 0.5 - abs(mod(parameter, 0.1) - 0.5);
float looped = 0.5 - abs(mod(parameter, 0.5) - 0.5);
// float looped = abs(mod(parameter, 0.5));
return smoothstep(d * w1, d * (w1 + feather), looped);
}
uniform float scaler, shapeScaler, shapeRotation, wireFrameWidth, wireFrameFeather;
uniform vec4 curveColor;
varying vec3 vposition;
void main () {
float d = 0.0;
float x, y;
float a = 0.001 / scaler / sqrt(vposition.x*vposition.x + vposition.y*vposition.y);
// a = 0.0;
for (int i=0; i<100; i++) {
x = a * (random(vposition.xy * 10.0 * float(i))-0.5);
y = a / shapeScaler * (random(vposition.xy * (-10.0) *float(i))-0.5);
d += f1(vposition+vec3(x, y, 0.0), scaler, shapeScaler, shapeRotation);
}
d /= 100.0;
float k = pow(exp(-wireframe(d*1.0, wireFrameWidth, wireFrameFeather)), 4.0);
vec4 c1, c2, rgba;
c1 = vec4(d * 0.0);
c2 = curveColor;
// 0.0 -> c1, 1.0 -> c2
rgba = mix(c1, c2, k);
gl_FragColor = rgba; //vec4(rgb, 1.0);
}`