// water test with vertex colouring // use mouse to control perlin noise octaves and position in space // author: info@toxi.co.uk float yoff,zoff,ns=0.1,zs=8; void setup() { size(512,256); noStroke(); } void loop() { float nx,ny=yoff,z1,z2; // setup viewport background(20,40,50); translate(width*0.5,height*.55,0); rotateX(PI/3.25); scale(15); // ripple control noiseDetail(8,mouseY*(0.6/height)); // draw surface for(int y=-10; y<=10; y++) { nx=mouseX*0.005; beginShape(TRIANGLE_STRIP); for(int x=-25; x<25; x++) { z1=noise(nx,ny,zoff); z2=noise(nx,ny+ns,zoff); fill(0,z1*160,z1*255,pow(10,0.85+z1*2)); vertex(x,y,z1*zs); fill(0,z2*160,z2*255,pow(10,0.85+z2*2)); vertex(x,y+1,z2*zs); nx+=ns; } endShape(); ny+=ns; } // animate waves zoff+=0.045; yoff-=0.06; }