xxxxxxxxxx
var gl, noctaves, c;
let pg;
function preload() {
maskImage = loadImage('mask.png');
}
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
imageMode(CENTER);
gl=this.canvas.getContext('webgl');
gl.disable(gl.DEPTH_TEST);
initc();
test=new p5.Shader(this._renderer, vert, frag);//shaders are loaded
shader(test);//shaders are applied
}
function initc() {
noctaves=int(random(4,10));
c=[];
for (var i=0; i<22; i++) {
c[i]=random(-10, 10);
}
}
function draw() {
test.setUniform("iResolution", [width, height]);//pass some values to the shader
test.setUniform("iTime", millis()*.0002);
test.setUniform('iMouse', [mouseX, mouseY]);
test.setUniform("noctaves", noctaves);
test.setUniform("c", c);
shader(test);
box(width/2);
image(maskImage, 0,0,width,height);
}
function mouseReleased() {
//noctaves=(noctaves==7)?7:noctaves+1;
//if(noctaves==7)initc();
initc();
}