xxxxxxxxxx
// https://www.udemy.com/course/learn-glsl-shaders-from-scratch
var mainShader;
const clock = new THREE.Clock();
function preload() {
mainShader = new p5.Shader(this.renderer, vShader, fShader);
}
function setup() {
createCanvas(min(windowWidth, windowHeight), min(windowWidth, windowHeight), WEBGL);
}
function draw() {
shader(mainShader);
mainShader.setUniform("uMousePos", [mouseX / width, mouseY / height]);
mainShader.setUniform("uTime", clock.getElapsedTime());
mainShader.setUniform("uTileCount", map(constrain(mouseX, 0, min(windowWidth, windowHeight)), 0, width, 1, 100));
noStroke();
plane(width, height);
}
function windowResized() {
resizeCanvas(min(windowWidth, windowHeight), min(windowWidth, windowHeight));
}