Graphics Reference
In-Depth Information
How it works…
By combining multiple Gerstner waves of varying wave lengths and directions together,
we have been able to produce a reasonable simulation of ocean waves. The Gerstner
waves are an approximate solution to fluid dynamics, and our implementation is based
upon the following formula, which in turn is based upon Tessendorf 2004 .
Formula used to generate the Gerstner waves
A similar effect can be generated using multiple sine waves. However, the Gerstner waves
not only displace the vertices vertically, but also horizontally. In order to produce a more
natural result the vertices are displaced along the X and Z axes towards the crest of the
wave, resulting in a sharper peak and smoother trough, we can control the amount of
displacement through the steepness parameter of the GerstnerWaveTessendorf function.
The following screenshot shows three examples of waves, the first is a regular sine wave
(Gerstner wave with a steepness of 0.0), the second is the same wave except with a
steepness of 0.5, and the last is a wireframe of the same wave again with a steepness
of 1.0. See how the vertices in the wireframe come closer along the length of the crest.
When comparing a single wave to the gentle and choppy waves, it is fairly obvious that
a good simulation of a wave requires multiple waves of varying lengths, amplitudes,
directions, and possibly frequencies; these different individual wave definitions are often
referred to as octaves. By summing together the entire set of waves, we achieve a more
realistic and varied result. The gentle waves are generated using four octaves, while the
choppy waves are generated using six octaves.
Although we have generated the waves on the GPU, it is interesting to note that if we place a
ship (similar to the one in the following screenshot - section D) , we still need to compute its
movement as a part of the wider physics simulation. This would most likely occur on the CPU.
 
Search WWH ::




Custom Search