Abstract

We introduce an automatic optimization approach for the simulation of large-scale coastal water. To solve the singular problem of water waves obtained with the traditional model, a hybrid deep-shallow-water model is estimated by using an automatic coupling algorithm. It can handle arbitrary water depth and different underwater terrain. As a certain feature of coastal terrain, coastline is detected with the collision detection technology. Then, unnecessary water grid cells are simplified by the automatic simplification algorithm according to the depth. Finally, the model is calculated on Central Processing Unit (CPU) and the simulation is implemented on Graphics Processing Unit (GPU). We show the effectiveness of our method with various results which achieve real-time rendering on consumer-level computer.

1. Introduction

Water is a common and important element in nature. It is also frequently encountered in games and other 3D virtual environments. A lot of attention has been paid to rendering water realistically, but the effectiveness of large-scale coastal water is typically limited in games. Large-scale water is often simply modeled to decrease computer cost, so there are not enough details, such as surf, foam, spray, and so forth. More details are needed to ensure the visual effect in today’s computer games and 3D virtual environments.

Methods of coastal water simulation can be classified into physically based methods and geometry based methods. Physically based methods mainly solve the shallow-water equations (SWE) with a grid-based or particle-based solver, which requires more than thousands of grid cells or particles [1]. A typical grid-based simulation is developed by Playne et al. [2]. They solve the SWE on multiple graphics processing units (GPUs) and give a standard parallel scheme for realistic fluid simulations. A hybrid grid which consists of regular cells near the water surface and tall cells on the bottom is given by Chentanez and Müller [3]. This method can handle most water phenomena while reducing computation time. It is implemented on a GPU and can get a good real-time performance. Ojeda and Susin [4] simulated shallow-water with the algorithm based on the Lattice Boltzmann Method (LBM). They enhanced the shallow-water scene [5] by adding lower details, surface foam, caustics, and so forth. A fast shallow-water is developed by Abbasov [6]. He constructed a discrete model after numerical simulating a three-dimensional (3D) shallow-water model. This method can greatly simplify the computation by adjusting the cell fill factor upon a sloping shore. The particle-based methods are more suitable for simulating small-scale water with higher details, such as breaking waves [7], water flows into empty regions [8], and interaction of water and rigid objects [9]. Geometry methods usually use a series of shapes to simulate shallow-water. They have been used for a long time. Gerstner model is applied by Fournier and Reeves [10] to the computer graphics field and improved with the elliptic function. However, the water shape he obtained cannot be curved in his simulation. A procedural model for breaking wave in coastal water is provided by De Lima et al. [11]. They generate a wave map and add it to water surface. This method can efficiently simulate the coastal water. Luo et al. [12] put forward a kind of 3D Gerstner wave model with the 3D Bezier curved. These methods can generate a realistic coastal water scene, but they still cannot meet the real-time requirement when large bodies of coastal water need to be rendered. A hybrid shallow-water that combines grid-based and particles based simulation is provided by Chentanez and Müller [13]. Longo et al. [14] gave a review for turbulence in the swash zone and discussed the measurement techniques and generation of breaking waves. There also have shallow-water simulations using a depth-integrated [15], spectrum [16, 17], 2D Boussinesq equations [18], video-based method [19], and so forth. The geometry based methods are suitable for large-scale real-time water because of simple computation. However, these methods cannot simulate the vertical movement, such as curved waves and breaking waves. Although the above methods can get a nice shallow-water scene, they have some limits to meet the requirements of large-scale real-time shallow-water simulations.

In order to realize large-scale real-time shallow-water simulations, we analyze the coastal water modeling, height field map generation, ocean wave mesh generation, and rendering. We find some solutions to enhance the real-time performance of the simulations. Our contributions of this paper are as follows:(i)A construction of the hybrid model that allows the simulation of arbitrary domain scales by coupling of deep water and shallow-water waves.(ii)An adaptive optimization of water surface grid that can efficiently reduce unnecessary grid cells under the coastal terrain.(iii)Implementations of our method and water surface effects, such as surface foam and reflection, with the shader language on GPU.

This paper is organized as follows. We present our hybrid model in the next section. The optimization of water surface grid is shown in Section 3. In Section 4, we present the implementation of our method. Then, we show our rendering results and discussion in Section 5. Finally, we conclude and explore avenues of future work in Section 6.

2. Hybrid Coastal Water

When the terrain depth (Depth, ) is greater than half of the wavelength (), the water is called deep water; otherwise, the water is called shallow water when is less than , and the intermediate zone shown in Figure 1 is the transition zone.

To achieve a realistic coastal water scene, this paper selects the deep water model based on FFT [20] and the shallow-water model based on geometry [21], and the automatic fusion algorithm is used to couple the two water waves in the transitional zone.

2.1. Deep Water

The FFT method based on Phillips spectrum first gets a series of double frequency sine waves whose amplitude and phase are relevant and then gets the height of every grid point on the ocean face by calculating with FFT.

Assuming that there are discrete points on the plane, the vertical offset of the discrete point at time iswhere , , , , , and is the height amplitude Fourier and can be calculated with the Phillips spectrum:

The height amplitude Fourier at time iswhere and are Gaussian random numbers that meet mathematical expectation 0 and variance 1.

The height amplitude Fourier at time iswhere .

Actually, in real motion of an ocean wave, the continuous changes of wind direction lead to extrusion between waves which make it become sharp at the top of waves and flat at the bottom following the rolling wave effect. The height map generated by our method is the result of stacking of multiple sine waves. Top of wave is too flat and not real, so we need to add a roll wave model. The model can be realized by changing the position of the grid in the horizontal direction. Here we use the amplitude of the ocean wave to get the offset of discrete point in a horizontal direction:

But this method needs one more FFT, and we simplify it for accelerated computing:where is the size of the FFT grid, is the number of FFT grid, and is the wave-height map. The deep water simulation based on FFT is shown in Figure 2(a).

2.2. Shallow-Water

Compared to the deep water, shallow-water is more complicated due to the effects of seafloor terrain. Its crest line and amplitude will change as the depth decreases. This greatly increases the difficulty of water modeling and rendering. On account of the real-time requirement, this paper uses an improved Fournier model based on geometry instead of the physically based model.

Fournier proposed that the motion trails of water points gradually change from circular to elliptical with the decreasing of seabed depth based on the classical Gerstner model. He established the Fournier wave model and applied it to computer graphics. And then he realized the 3D visualization of coastal water. For the sake of rendering of coastal water, including curved waves, Wang et al. [21] made an improvement of Fournier’s model and could quickly simulate coastal water and curved waves at different wind speeds. The formula is as follows:

Among them, the plane is a vertical surface wave, the point is the static position of a wave point, is the wave amplitude, is the angular frequency, and are the major and minor axes of the ellipse, , is the slope of seafloor terrain, is the deep water wave number, denotes the wave number at the point , , and is the wind direction.

In order to realize the curved waves, the wave parameters when moving need to be adjusted:When When

And the limit on the long axis iswhere and is the thin coefficient of the waveform. Its value is 1 by default. The higher the coefficient is, the thinner the waveform is. denotes the angular at the wave trough and is the curved coefficient with a minimum of 1.

The final coastal water is shown in Figure 2(b).

2.3. Coupling of Water Waves

In order to make the transition of deep water waves and the shallow ones smooth, we use the automatic coupling algorithm to couple the two waves when the depth is in the range of to . The fusion algorithm is shown as follows:where is the terrain depth of the grid vertex at the current time. and are the heights generated by the deep water and shallow-water model.

From the formula, it can be seen that the coupling algorithm will guarantee a smooth transition from deep water to shallow-water. The hybrid water after coupling is shown in Figure 2(c).

3. Water Surface Grid Automatic Simplification

When the water is rendered, grid model is usually used to simulate water surface. Yin et al. [22] divided the surface into a dynamic one and a static one. The dynamic surface is formed by grid points and revolves around the viewpoint, and the outer space of the dynamic surface is the static surface. Hinsinger et al. [23] presented an adaptive surface grid model. Cui et al. [24] improved the adaptive grid model and put forward a trapezoidal grid model. Johanson and Lejdfors [25] proposed a projection grid model and used it to simulate the water surface in world space.

The above studies of wave multiresolution grid did not take the influence of terrain into account. However, shallow-water will not appear under the land terrain, so the surface grid under the land should not be computed and rendered. In order to prevent the unnecessary expense, we proposed an improved multiresolution grid by detecting whether grid points are under the land. Then, rendering of coastal water will be accelerated after reducing computation consuming.

3.1. Multiresolution Grid

Multiresolution grid refers to grids with different levels of details (LOD) existing in different regions. It can greatly improve the efficiency of the grid generation without losing the details. Therefore, multiresolution grids are commonly used in real-time rendering of large-scales of water and terrain.

In the coastal scene rendering, a part of the water surface grid is always under the terrain. But the former researches usually use the same grid; they did not make changes to the grid. The general grid is shown in Figure 3.

The grid points covered by terrain will be calculated, generated, and automatically culled by the rendering system. There is no problem in vision, but the process of computing, generating, and culling can severely affect the real-time performance.

3.2. Grid Improvement

In order to avoid unnecessary computation, the grid points are detected in advance to ensure whether they are covered by terrain or not when the water surface grid is generating. If they are, the next computation step will be not processed; if not, then continue. The detection will last until the whole grid is generated. Because the coastal terrain is static, the detection does not need to be repeated. Then, the speed of generation and rendering of water can be improved.

In the case that coastline data are known, the cover situation can be judged according to the relationship between the grid points and the coastline. The detection process is as follows:

If & , the grid point is not covered by terrain, or it is covered and will not need to be computed.

However, the coastline data cannot be generally obtained. Then, the collision detection technology will be used to detect whether the grid point is covered by terrain. The collision detection process is shown in Figure 4.

In the process, the collision detection system sends a vertical line from above the grid, and we can manage to keep an account of the height of the point relative to the horizontal line when the line collision with the terrain.

If , the grid point is not covered by terrain, or it is covered and will not need to be computed. The final grid is given in Figure 5.

4. GPU Implementation Method

In order to rapidly generate large bodies of near ocean wave scene, graphics hardware shader language is used in rendering. The water height map data are obtained by the calculating of shallow-water model. Then, it is loaded in the vertex shader and is fused with Perlin noise. Final water height and offset in horizontal direction are computed. Each vertex normal vector and color data are calculated in the pixel shader, so the water scene is realized. The surface reflection and foam effect are also added to increase the scene fidelity.

4.1. Rendering Based on Height Field Map

The curved model can be computed to obtain the height and horizontal offset of each vertex. The result will be saved in a height map. Each pixel of the height map can store a vertex information. It is expressed by the formula

The height field map data can be read and interpolated in the vertex shader, and Perlin noise is added; then, the final vertex information is expressed by

In the pixel shader, the vertex normal vector and color are calculated, the vertex transparency is computed according to the depth:

Here fresnel denotes the fresnel reflection coefficient.

The water surface will be getting more and more transparent with the decreasing of depth. The value of 0 means fully transparent. In this paper, the minimum transparency value is 0.6.

4.2. Realization of the Reflection and Foam Effect

The rendering scene above sea level is rendered to a texture through the RTT (render to texture) technology. The reflection texture is loaded in the pixel shader, and then the reflection effect of the wave surface is realized by using dynamic texture mapping technology. The specific calculation formula is as follows:

Foam will be intermittently generated at the wave crest when the wave is moving. And foams appear in the trough and crest of the waves during wave run-up and run-down [14]. So we applied two different methods to achieve the effect of foam. We load a transparent foam texture and simulate the dynamic foam effect by controlling the offset speed of texture with texture mapping technology. The implementation detail and rendering result are shown in Box 1 and Figure 6:

5. Results and Discussion

To evaluate our method, we have created several typical coastal water scenes on a 2.66 GHz Core i7 and NVIDIA GTX 560. The hybrid water model is computed on CPU, and the rendering is implemented on GPU. The results are shown in Figure 7. In Figures 7(a) and 7(b), the thin coefficient is 1.0, while its value is 1.2 in Figures 7(c) and 7(d). Compared with 1.0, the waveform is thinner with the coefficient of 1.2. But there is a problem that the waveforms will be crossed when the coefficient getting higher. It is the limit of our method, and we will research it in future work. The foam effects are different in the crest and trough of waves. In our method, foam at the crest moves forward and foam at the trough moves backward. So we can simulate the huge amount of bubbles fast. Table 1 lists the performance values of different examples. Since the model is geometric and the rendering is implemented with shader language, our method makes it possible to simulate a large-scale coastal water scene at a stable frame rate of 60 frames per second.

The comparison with the references’ methods is shown in Table 2. Ojeda’s method [4] is based on physics. It can handle arbitrary underlying terrain and interact with dynamic rigid bodies. They compute the water model both on CPU and on GPU, but only the result on GPU can meet the requirement of real-time performance. Another problem of our method is that it can only get the simulation of small-scale shallow-water. Luo’s method [12] used a Bezier curve, so it is based on geometry. They can get a nice real-time middle-scale coastal water after GPU accelerating. However, they need to design a coastline before rendering. Once the rendering is begun, the coastline cannot be changed. As our method can get a high frame rate, we will not need a GPU based computation of the water model. We can also handle any underlying terrain since the model is computed in real-time. Furthermore, we also consider the deep water when the depth is getting larger. It can also help to make the coastal scene more real.

One drawback of our method is that the rendering results lack higher details. The geometric based model is not the same as the physically based model, and it cannot simulate the higher details, such as splash and breaking dam. The other problem is that the waveform will become crossed if we do not limit the thin coefficient. However, our method offers a high rendering speed even on an ordinary graphic hardware. This can allow more consumer-level computers to run the coastal water simulation.

6. Conclusions

In this paper, we present an automatic optimization approach for the rendering of large-scale real-time coastal water. A hybrid coastal water model is estimated for large-scale coastal water according to the depth of water. The deep water is also considered in our hybrid coastal water. Unnecessary grid cells are simplified by our automatic simplification algorithm. Finally, we implement our method on GPU by using shader language. The reflection and foam effect are also added to the water surface to enhance the final rendering result.

There are several ways to further improve the visual appearance of the coastal water. The extraordinary detailed effects like waterfall, breaking dam, and splashes are needed to be complex modeled by using particles systems. The interaction with rigid bodies is also a challenging work in the future.

Competing Interests

The authors declare that there is no conflict of interests regarding the publication of this paper.