[column width=377px margin_left=120px margin_top=80px]
Figure 1: Above water
Real Time Water
In this project we try to render a terrain with an ocean around it. The camera should be able to move both above and below the water. Even though the water is just a big plane surface, with the right shader it looks like a big ocean with small waves on top (Figure 1). To create the water effect we use several passes.
The first pass is a refraction pass, where everything that is below the water level is rendered into a framebuffer object. The next pass is the reflection pass, where everything above the water level is rendered into a new framebuffer object. To make it look like a reflection in the water, the scene is turned upside down and clipped at the water level. In the final pass we render the scene as normal and with the water plane, where the reflection and refraction layers are projected onto. This method is based on a similar method in .
Figure 2: Below the water surface.
When we think about water, we think about it as a clear fluid, but in reality, water has a slightly blue color.
[column width=377px margin_left=46px margin_top=80px]
We can only see this color if we look through enough water. This means that the amount of tint we should use, is depending on how much water we are looking through (Figure 2). There are four situations we have to take care of (Figure 3). If we are below water level and looking through the water plane, or not. If we are above the water and looking through the water plane or not.
Figure 3: The camera can be below the water level looking through the water plane or not. It can be above water level looking down through the water plane or not.
If we are above the water and looking through the water, the amount of tinting is based on the distance from the terrain to the water plane. We do the tinting while drawing the terrain, this way we know the position of the terrain and can easily determine the distance to the terrain. The distance to the water plane can be determined using a ray-plane intersection test. If we are below the water and not looking trough the water plane the tinting is also done when drawing the terrain. The amount of tinting is simply the distance to the terrain. When we are below the water and looking through the water plane, it is difficult to tint the terrain when the camera is just below the water level and some of the screen is above water and some is below. Instead we do the tinting while drawing the water plane and the distance is the distance from the camera to the water plane.
This movie shows a small fly through of the scene.
 Tiago Sousa. Generic Refraction Simulation. In GPU Gems 2.