It's free to join Gamasutra!|Have a question? Want to know who runs this site? Here you go.|Targeting the game development market with your product or service? Get info on advertising here.||For altering your contact information or changing email subscription preferences.
Registered members can log in here.Back to the home page.    

Search articles, jobs, buyers guide, and more.

By Lasse Staff Jensen and Robert Golias
Gamasutra
September 26, 2001

Introduction

Shallow Water Waves

Rendering

Godrays

Printer Friendly Version

 

Letters to the Editor:
Write a letter
View all letters


Features

Deep-Water Animation and Rendering

Shallow Water Waves
All of our shallow water simulations are based on [17] where Kass and Miller use a simplified set of equations to simulate ocean waves. If we look at the horizontal velocity in 2D and assuming, among other things, that the water volume can be described by a height-field we end up with the following set of equations:

Were G is gravity (and other global forces), h is the height of the water surface, d is the depth, and u is the horizontal velocity of a vertical column of water. We can also combine these two equations. Start by differentiate Equation 2-11 with respect to x and Equation 2-12 with respect to t:

Now substituting the partial cross-derivative of Equation 2-14 into Equation 2-13 we end up with:

Using finite-differences we can discretisate this as:

Now that we have turned the partial-differential equation into a second order ODE we will solve it using a first-order implicit method. First we will use finite-differences to discretisise the first- and second order time-derivatives of h:

We are solving for hi so we will rearrange Equation 2-17 and substitute it into Equation 2-18:

And substituting Equation 2-16 into this we get:

The last discretisation done is to treat the depth as constant during iteration, so one ends up with the following linear system:

Where A is given by:

Now this matrix gives a symmetric tridiagonal linear system, which can be solved relatively fast, see [6] for more info. Expanding Equation 2-14 to 3D is done by substituting the partial derivative of h with respect to x with the Laplacian:

And it’s solved exactly as the 2D case simply by splitting it up into two systems - one dependent on x and one on y.

Surface Waves
The last level of animation detail we use is strictly 2D surface waves. If we take our height-field from earlier and constrains the water to a fixed depth, Equation 2-22 reduces to:

Where |V| is the velocity of the wave (across the surface). Let hx,yt be the height of the grid at position x and y at time t, then Equation 2-23 can be discretisised using central differences as [3]:

As shown in great detail in [3] this can be animated with just a few arithmetic operation per grid-element

Mixing of the models
Ideally we would like to use NSE for all the water dynamics, but even solutions of order O(n)4 is still too computational expensive for real-time purposes. Instead we decided to use NSE for surface details only, restricting the problem to two dimensions. As mentioned before, the core of our animation is the FFT-water algorithm. This provides us both with large waves, used for the actual geometry, and with small waves optionally used for bump mapping. While the waves generated in this way look very realistic, they have one inherent problem – floating objects cannot interact with the water in any way. This is where the other models come in! We implemented both the shallow water model as described in the section on Shallow water waves and the “traditional” simple surface water as described in the section on surface waves. The shallow water method has several very advanced properties – it takes depth of the surface into account (resulting in waves slowing down and aligning with the coast line) and it can simulate water that floods previously dry areas. However, we didn’t intend to use the model for these large-scale effects and for small waves, around floating objects, the simpler model seems (at least subjectively) to give better results (as well as being a bit easier to control).

For mixing the FFT and physics water, we simply take the geometry from the FFT algorithm and superimpose on it the geometry resulting from the physics model (that’s computed only around floating objects). Although not physically correct, this provides us with the results we desire.

Buoyant Rigid Objects
For adding a rigid object that interacts with the water surface, we need to apply buoyancy to the object and waves to the water surface.

One method for approximating buoyancy is described for example in [3]. As known, according to Archimedes, the force of buoyancy is equivalent to the weight of water displaced by the floating objects. To approximate the displaced volume, we represent the object by a series of patches described by the coordinates of their centre, their area (a) and their normal (N). Then for a given patch (if it’s centre lies in the water), the volume of displaced water can be written as:

  V = a(Pwater - Ppatch_center)N

where Pwater is the point on the water surface and Ppatch_center is the position of the centre of the patch. Now, for simplification, we can assume that this force has always direction of the water surface’s normal at the given sampling point. Thus the force applied to the centre of our patch is:

  F= rvNwater

where r is the water density. We apply this force to the given point using the standard equation for rigid object physics, as described for example in [13]. There are also two other forces that we should try to simulate. First, floating objects don’t slide freely on the water because of drag. We approximate it for each patch using equation:

  Fdrag= ßaV

where ß is constant and V is velocity of the patch centre relative to the water. Also, when object with proper shape moves on the water, it rises out from the water, depending of it’s shape, orientation and velocity (this effect is best seen on boats).

We use the following equation to approximate this effect:

  F = -ja(N.V)N

where j is another constant. Note that we use bilinear interpolation of values defined in the grid, to obtain all quantities connected to the water surface, at arbitrary points on the surface.

While this covers the way water affects floating objects, there should also be feedback going in the opposite way. The proper solution would be to take the object into account directly in the physical equations used for animating the water surface, but since values entering these equations don’t represent the complete mixed water anyway, we decided to use another approach. First, for all grid elements touched by any object, we temporally increase the damping factor in the wave model used for object interaction (this creates a wave “shadow” – i.e. place in which waves don’t spread). Secondly, we compute the change in depth of the floating object between the last and current frame, and feed this difference back to the water surface as direct displacement of the surface. With correct scale of this effect, we get both waves from objects that falls into the water and waves formed behind moving objects (such as boats).

______________________________________________________

Rendering


join | contact us | advertise | write | my profile
news | features | companies | jobs | resumes | education | product guide | projects | store



Copyright © 2002 CMP Media LLC. All rights reserved.
privacy policy | terms of service