drawPoints = regl({
depth: { enable: false },
stencil: { enable: false },
frag: `
precision mediump float;
varying vec4 fill;
void main() {
vec2 cxy = 2.0 * gl_PointCoord - 1.0;
float r = dot(cxy, cxy);
if (r > 1.0) discard;
gl_FragColor = vec4(fill);
}
`,
vert: `
precision mediump float;
attribute vec2 position;
attribute vec2 velocity;
attribute vec4 color;
uniform float tick;
varying vec4 fill;
void main() {
vec2 newpos = vec2(position.x + velocity.x * tick, position.y + velocity.y * tick);
gl_PointSize = 2.0;
gl_Position = vec4(newpos, 0, 1);
fill = color;
}
`,
attributes: {
position: {
buffer: points,
stride: vertSize,
offset: 0
},
velocity: {
buffer: points,
stride: vertSize,
offset: 8
},
color: {
buffer: points,
stride: vertSize,
offset: 16
}
},
uniforms: {
tick: ({ tick }) => tick
},
count: numPoints,
primitive: "points"
})