drawIt = regl({
vert: `
precision highp float;
attribute vec2 xy;
varying vec2 uv;
uniform mat4 view;
void main () {
uv = xy;
gl_Position = view * vec4(xy, 0, 1);
}`,
frag: `
precision lowp float;
uniform float f1;
uniform int nPnts;
uniform sampler2D ts0;
uniform sampler2D ts1;
uniform sampler2D ts2;
uniform sampler2D ts3;
uniform sampler2D ts4;
varying vec2 uv;
${reglUtil}
void main () {
// gl_FragColor = vec4(uv, 0, 1);
vec2 pnt;
vec4 texture;
float v = 0.0;
texture = texture2D(ts0, vec2(0, 0));
pnt = vec2((texture - 0.5)*2.0);
v += (texture.z-0.5)*2.0 * f1 / dist(uv, pnt);
texture = texture2D(ts1, vec2(0, 0));
pnt = vec2((texture - 0.5)*2.0);
v += (texture.z-0.5)*2.0 * f1 / dist(uv, pnt);
texture = texture2D(ts2, vec2(0, 0));
pnt = vec2((texture - 0.5)*2.0);
v += (texture.z-0.5)*2.0 * f1 / dist(uv, pnt);
texture = texture2D(ts3, vec2(0, 0));
pnt = vec2((texture - 0.5)*2.0);
v += (texture.z-0.5)*2.0 * f1 / dist(uv, pnt);
texture = texture2D(ts4, vec2(0, 0));
pnt = vec2((texture - 0.5)*2.0);
v += (texture.z-0.5)*2.0 * f1 / dist(uv, pnt);
if (abs(v - 0.0) < 0.001) {
gl_FragColor = vec4(0);
}else{
if (v > 0.0) {
gl_FragColor = vec4(v, 0, 0, 0.5);
} else {
gl_FragColor = vec4(0, 0, -v, 0.5);
}
}
// pnt = vec2(apnts[0]);
// // pnt = vec2(apnts[0], apnts[1]);
// // vec4 a = texture2D(pntsBuffer, vec2(0, 0));
// gl_FragColor = vec4(vec3(f1/dist(uv, pnt)), 1);
}`,
attributes: {
xy: [-1, -1, 0, 1, 1, -1].map((d) => d * 5)
},
uniforms: {
nPnts: regl.prop("nPnts"),
f1: regl.prop("f1"),
ts0: regl.prop("ts0"),
ts1: regl.prop("ts1"),
ts2: regl.prop("ts2"),
ts3: regl.prop("ts3"),
ts4: regl.prop("ts4")
},
count: 3,
depth: { enable: false }
})