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][x+1]) / 2) -
new-water[y][x] -= new-water[y][x] shr x
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…
Thanks so much in advance!
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:
It’s 2D, but very cool.
There’s a nice water demo here too:
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!
I downloaded that collection. It’s awesome!
And the Water example you made is impressive…
I think I learn it from there.
Thanks so much again!