"The most realistic sailing simulator ever made"
 
Become a pioneer !!
Stay informed
Access beta versions
Subscribe

In depth: Simulating waves, part 2

Posted on June 23rd, 2016 by Richard Knol

After some very long hours and lots of coffee the wave height now varies per location. Yay! That means lower waves in shallow water and behind islands and high waves in deep open water.

As mentioned in the previous post we do this by creating a depthmap of the ocean and passing it to the shader as a texture. The texture has a resolution of 128 x 128 pixels and is refreshed every time the land is updated. It covers an area of 7500 x 7500 meters which is about 20km x 20km in reality (far distances are logarithmic).

Here you can see this depth map. The red value of the depth map is used to determine the color of the water (shallow water has a brighter color and deep water is darker). The scale from black to red is pretty steep because water turns dark very quick as the water gets deeper.

The depth is also used to determine the wave height. This is shown in blue.

But waves will build up slowly behind shallow areas, so we need to apply a post process effect that smears the shallow areas out in the direction of the waves. This is shown in the green value.

When we combine the green and blue values you can see the slow wave build up effect better.

Merging the green value (wave height) and red value (depth for water color) and ignoring the blue (we don't need that anymore) we get this depthmap.

But the image is only 128 pixels and covers 20km. That means each pixels covers a very big square region. We need more detail in the center of the image and less detail near the edges. In other words: a logarithmic scale.

But the image is only 128 pixels and covers 20km. That means each pixels covers a very big square region. We need more detail in the center of the image and less detail near the edges. In other words: a logarithmic scale.

And here's what it looks like inside Sailaway. You can see the differences in sea color between shallow and deep water and you can see there are hardly any waves behind the island, eventhough it blows 17 knots.

We also added a depth indicator in the dashboard that shows the amount of water below the keel in meters or feet. This depth varies with the boat heel and is also affected when the boat is lifted or dropped by a wave. (DPT indicator at the top of the screen)

And uhm... better trust what it says, because this happens if you don't pay attention.


Curious? Want to know more? Subscribe and gain access to early releases and stay informed.
Previous article Next article