float XvelChange=L.z-R.z;This is exactly the discrete form of the partial differential equations at Wikipedia for the shallow water wave equations.
float HtChange=L.x-R.x;
vec4 N=C;
N.x+=vel*XvelChange;
N.z+=ht*HtChange;
vec4 blur=0.25*(L+R+T+B); /* neighborhood average */Instead, Wikipedia recommends pushing back against velocities: big velocities will tend to damp out this way, but you need to add so much viscosity, nothing interesting happens. Piles of tar are not known for their cool ripples.
new=(1.0-blurFrac)*new+blurFrac*blur;
float vel=0.2, ht=0.2; // constantsInitial conditions make a big difference: if you have nonzero X and Y initial velocity, then your waves will move at that velocity.
vec4 N=C;
N.x+=vel*(L.z-R.z); // height gradient
N.y+=vel*(B.z-T.z);
N.z+=ht*(L.x-R.x+B.y-T.y); // velocity divergence
Er, JavaScript or WebGL doesn't seem to be running, so basically all you're going to see is the bare code...
|
|
|