# Water Simulation

Hi everyone!

I am trying to do a shallow water simulation, with waves and etc.
However, I have searched the whole internet and I either find a model that itâ€™s either too simple or either too complicated.

This next model works is without waves, and given initial conditions of the old-water matrix, it produces a single wave until the water estabilizes and ends completelly flat. My problem is that to generate another wave i have to change the values of the matrix abruptly and that looks really bad and unrealistic, and waves dissapearâ€¦

for y := 1 to height - 1
for x := 1 to width - 1
new-water[y][x] = ((old-water[y-1][x] +
old-water[y+1][x] +
old-water[y][x-1] +
old-water[y][x+1]) / 2) -
new-water[y][x])
new-water[y][x] -= new-water[y][x] shr x
end
end

How can I make a continous moving water?

And is there anywhere I can find a more sophisticated model hat involves turbulences (that is waves with crests). (maybe a Navier-Stockes system simplified with numerical methodsâ€¦ )

Hope anyone can help me on this oneâ€¦

Check out the IHV web sites for cool water demos.

Youâ€™re really limited by the hardware you have. The latest techniques sample textures in vertex shaders, so youâ€™ll need shader model 3.0 capable hardware to do that sort of thing.

If youâ€™re stuck with old hardware, check out the Aqua demo:
http://www.darwin3d.com/gdm1999.htm

Itâ€™s 2D, but very cool.

Cheers

Thereâ€™s a nice water demo here too:
http://glbook.gamedev.net/moglgp/code.asp

Cheers

Thanks!
Kind of a hard topic!

Cool demo! I think Iâ€™ll stay 2Dâ€¦

Why stay 2D?

I wrote that water demo and associated part of the book, the actual animation part is just simple stuff like summed sine waves of different amplitudes frequencies and orientations on an array of vertices. After this is done the cross product is taken to calculate the mesh normal per vertex.

The rendering portion draws this mesh in 3D and uses the view vector and normal to calculate things like the reflection and refraction factors (and underwater fog), but you can simply lift that code from the demo, itâ€™s all there & very simple to extract.

Dorbie thanks for everything!