drawPendulumStates = regl({
vert: `
precision highp float;
attribute vec3 uv;
uniform sampler2D positions;
varying float r;
varying vec2 shade;
#define TWOPI_INV ${0.5 / Math.PI}
void main () {
${
draw === 'θ phase space, (θ1 vs. θ2)'
? `
vec2 state = texture2D(positions, uv.xy).xy;
state = fract(state.xy * TWOPI_INV + 0.5);`
: draw === 'Similarity-transformed'
? `
vec4 statevector = texture2D(positions, uv.xy);
vec2 state;
state.x = dot(vec4(0.776140490509798, 0.3700898833514918, 0.4427594582202827, 0.6333677919749464), statevector);
state.y = dot(vec4(0.776140490509798, 0.3700898833514918, -0.4427594582202827, -0.6333677919749464), statevector);
state = state.xy * TWOPI_INV * 1.25 + 0.5;
`
: `
vec2 state = texture2D(positions, uv.xy).zw;
state *= vec2(1, 2);
state = state.xy * TWOPI_INV + 0.5;
`
}
gl_Position = vec4(state * 2.0 - 1.0, 0, 1);
gl_PointSize = 1.0;
}
`,
frag: `
precision highp float;
uniform float alpha;
varying float r;
varying vec2 shade;
void main () {
gl_FragColor = vec4(vec3(1.0), alpha);
}
`,
count: regl.prop('count'),
primitive: 'points',
depth: { enable: false },
uniforms: {
alpha: (ctx, props) =>
((20000 * props.ɑ) / Math.pow(textureSize, 2)) * (width / 600),
positions: regl.prop('src')
},
attributes: {
uv: { buffer: lookupBuffer }
},
blend: {
enable: true,
func: {
srcRGB: 'src alpha',
srcAlpha: 1,
dstRGB: 1,
dstAlpha: 1
},
equation: {
rgb: 'add',
alpha: 'add'
}
}
})