xxxxxxxxxx
47
let vs = `
precision highp float;
attribute vec3 aPosition;
void main() {
vec4 positionVec4 = vec4(aPosition, 1.0);
gl_Position = positionVec4;
}
`;
let fs = `
precision highp float;
uniform vec2 resolution;
uniform vec2 mouse;
void main() {
float r = 0.0;
float g = fract((pow((gl_FragCoord.x-resolution.x)/100.0,2.0)-pow((gl_FragCoord.y-resolution.y)/100.0,2.0))*0.2);
float b = 0.0;
gl_FragColor = vec4(r, g, b, 1.0);
}
`;
let theShader;
function setup() {
createCanvas(500, 500, WEBGL);
theShader = createShader(vs, fs);
noStroke();
}
function draw(){
shader(theShader);
theShader.setUniform('resolution', [width, height]);
theShader.setUniform('mouse', [mouseX, mouseY]);
quad(-1, -1, -1, 1, 1, 1, 1, -1);
resetShader();
}