### How to make a Realistic Water Simulation?

Simplest way of simulating water waves

The simplest traditional way of simulating water wave is done by using 2  normal maps(normal map is a texture which denotes the height of a point in a surface by its color). The normal map of the surface will be generated from these 2 normal maps by ping-ponging between them.

Shortcomings of above approach

Although this is a low cost simulation, it does not define any advance properties of surface like how the water react with the world(wind, ripples, collisions with objects … etc).   Also, it would generate a periodic pattern on water surface. Also, there would not be actual height difference in the wave surface because normal mapping does not change the height map of the surface, it fakes the lighting of bumps and dents. This only shows an illumination of a height difference in surface points.

How to improve?

• Improving normal map
Instead of ping-ponging between 2 normal maps to generate the bump of the surface, we can use a fast fourier transformation noise based approach to calculate displacement of each vertex. Based on that displacement, we can generate the normal map of the water surface.
• Vertex displacement
Based on FFT noise, we can calculate a displacement map. By applying this to the water surface, we can actually displace the vertices of water surface. This improve the visual quality of the wave while allowing other objects to interact with water.
Calculations related to above operations can be found here.

• Removing tiling
Even after using FFT to generate normal maps, there would be a periodic pattern on water surface. This can be avoided by the use of Perlin noise. (Perlin noise is a procedural texture primitive, a type of gradient noise used by visual effects artists to increase the appearance of realism in computer graphics.
Read more..... ). But using only perlin noise will reduce the details of the water surface at near sight. In order to prevent this, we can use a blending of FFT and perlin noise. This gives a acceptable quality in both near sight and far sight.

In previous section, I have only concerned about the shape of the water surface. Now, Let’s see how to improve the optical properties of the water surface.

Factors which affect the look of the water surface

• Reflection/Refraction
• Main color of water (this depends on suspended particles and stuff mixed with water such as algae,dust..etc)
• Water foams

Reflection
The reflection of water water surface is a major factor which decides how the water looks. In most cases, bright highlights of the water comes from sky. The most important factor we should implement in water reflection is Fresnel effect.
Fresnel effect is a quality of water surface which changes the amount of reflectance we can see

according to the viewing angle.

Water Foam

A foam is a substance that is formed by trapping pockets of gas in a liquid or solid. When we consider water, water foams are generated by trapping air bubbles in water. Those are generated around points which breaks waves and scatters around it.

These are the major factors we should consider when implementing water surface shaders. Proper realisation of these properties will give a nice realistic look to the water surface. But in game development the most important fact we should remember is, in water simulation is, in order to get a realistic look we should always combine the water and particle system. Specially in places which breaks water waves, we should use particle emitters. This would improve the realistic look in a great deal.

Here is my first attempt of ocean simulation