.Click to cycle through the number of octaves used. Refresh for a new random texture...
A fork of Gold rivers by Pierre MARZIN
xxxxxxxxxx
// Author Pierre MARZIN 01/2017
var gl,noctaves,c;
function setup() {
createCanvas(windowWidth, windowHeight,WEBGL);
gl=this.canvas.getContext('webgl');
gl.disable(gl.DEPTH_TEST);
noctaves=1;
initc();
test=new p5.Shader(this._renderer,vert,frag);//shaders are loaded
shader(test);//shaders are applied
}
function draw() {
test.setUniform("iResolution", [width,height]);//pass some values to the shader
test.setUniform("iTime", millis()*.001);
test.setUniform('iMouse',[mouseX,mouseY]);
test.setUniform("noctaves",noctaves);
test.setUniform("c",c);
shader(test);
box(width/2);
}
function mouseReleased(){
noctaves=noctaves==6?1:noctaves+1;
if(noctaves==1)initc();
}
function initc(){
c=[];
for(var i=0;i<22;i++){
if(i<19)c[i]=random(-10,10);
else c[i]=random(-1,1);
}
}