   Wave equations for water surface height field generation
  Has anyone here got a good equation to use for generating height fields for a water surface with waves?What I want is a mathematical function. The mathematical function should return the height by using as input the following:- wind speed (determines wave height and length)- wind direction (a 2d vector or degrees/radians according to some prechosen vector in the xz plane)- position x and z for the spot we need the height for- time (the function should preferably be cyclical in time, in that after a certain amount of time has past, so that if we hold all other input variables constant, increasing the time variable gradually would at regular intervals return the exact same answer).So I want to find an f(Vw, W->, x, z, t) that returns height y. It should be a smooth and continuous function - manipulating any of the input parameters smoothly enough should make the changes in return value of the function smooth enough.I assume it's a form of Perlin noise I should use. However, looking at a few images of real waves: http://www-evasion.imag.fr/Membres/Fabrice.Neyret/gallery/water_and_waves/waves-ocean/catalog.html...and one of the simplest of the Perlin noise examples:http://mrl.nyu.edu/~perlin/homepage2006/simplex_noise/index.html (this one is the best I've found but I'm not satisfied with using it for water, as it's supposed to be a rubber sheet and looks like it too :) )...I'm not sure at all how complex Perlin noise and with which parameters I should choose for creating a good water surface. What parameters should I choose? Also are there any good wave equations used also for non-realtime computations that I could simplify to achieve a good real-time result? Does anyone have sources with relevant fluid dynamics information? A game I think has rendered waves pretty well is Silent Hunter III. Something like that is what I'm ultimately striving for...   
  The Perlin example is really quite nice.  The curved surfaces are a bit smooth and the motion lacks continuity though which you would get with a differential equation approach.Finite Element or Finite Differences are 2 very popular ways of solving the simple differential equation for 2D waves (with the 3rd dimension waving)  Since you wouldn't need accuracy you might be able to do something nice in real time.  You can choose the grid spacing to evaluate based on your requirements but it could turn out to be too course for good detail and realism.  Use a NURBS routine maybe?A wild idea which could give you some amount of randomization and randomized detail which be to wiggle the grid points quasi-randomly.A combination of approaches might be ideal since the differential equations only diffuse an initial preturbation.  The Perlin seems to add a preturbation.   ;  Hello,I've been playing around with water rendering recently and came up with quite a simple method of generating an animated water surface on the GPU. I combine sin waves, in a method similar to that of fourier synthesis. Each wave has its own direction, velocity, phase, wavelength and amplitude.At present I wrote a program to generate 2D textures from input parameters and these then get combined using additive blending on a seperate render pass. This technique has some major drawbacks, it is very difficult (but not impossible) to get combined heightmap that is wrapable, and at distances close to the camera our lighting calculations look a little pixelated. These problems, I am hoping, will be solved by getting rid of the heightmap idea altogether and leaving the whole process in equation form, so that in our shaders we calculate our heightmap value, meaning we don't have an extra render pass, we don't have any issues with discrete steps along our equations, and we don't have any issues with wrapping. This should also get round some of the issues I was having with vertex shader texture lookups, it was required to generate a lower resolution floating point texture of the combined heightmap for use in the vertex shader.Here's some screenshots of the results I obtained from the inital heightmap idea... The whole method is a GPU implementation, nothing being written to the graphics card each frame.http://rbangs.blogspot.com/2006/03/fish.htmlRichard.   ;Quote:Original post by bangzhttp://rbangs.blogspot.com/2006/03/fish.htmlThat looks really good, unfortunately I still don't really understand how to implement such stuff (I am a newbie at shaders). AFAIK you can't generate geometry by vertex shaders, so are you passing some arbitrary vertices to the shader and then it generates the correct coordinates for the vertices? Or is the entire effect done with pixel shaders? I think that what I need is geometrical waves, so that it looks credible also when I add land and ships etc (Silent Hunter III seems to have geometrical waves). Some pixel shader effects I believe might be interesting for getting good reflections, refration and shadowing later, but so far I'm developing this stuff with - and for - an old computer which only handles vertex shaders but not pixel shaders, so in order for it to be compatible it may only use vertex shaders and fixed function pipeline. So I'm planning to use a single texture rather than pixel shader effects, and generate waves by geometry only. Thus the need for an equation which returns the correct height... As for the implementation, if I want it to generate the geometry in the vertex shader, I assume I must pass a big grid of vertices with undefined (or arbitrarily chosen) y coordinates that get their y coordinates generated by the shader (since the shader can't generate vertices). Or am I missing something? The level of detail stuff was going to be achieved using geomipmapping, but because heights vary for the waves I'd predefine the distance for each LOD based on the assumption that it's always maximum height difference within each block, so the grid I'd pass to the shader would have the same shape always.   ;  You can have a terrain grid to provide the vertices for a vertex shader to work on.   ;  When deciding on an algorithm for rendering my water I looked into some of the algorithms used in terrain rendering, although most of these seemed a little pointless to apply to water as there is a lot of wasted computation to get a nice distribution of vertices and this can be obtained using another, much faster method.We have a surface which we update the Y values of each frame, this surface is always centered at the cameras location on the XZ plane, but the Y position of this model changes with the camera. This sufrace can be tessellated however you wish, I choose to use clipmapping but I've also seen this implemented done using a radial grid.For my implementation I gained a nice performance boost from using a texture lookup for each Y value in the vertex shader. But vertex shader texture lookups aren't very supported in hardware, you'll need at least a GeForce 6 series (and ATI don't properly support this feature yet). I am hoping for more support with DirectX 10 with it's unified resource model.The moral of the story is, I think your going to waste a lot of computational effort if you start tessellating your surface on the fly using a method such as geomipmapping. A faster approach would be to use a surface which is already tessellated in the XZ plane and change the Y values for each vertex each frame. As you move around your world you would alter the X and Z values which you are looking up from to give the appearence that you are moving (despite having the geometry still centered on the cameras location).   