Simulating Ocean Waves

News (August, 31): We are working on Scratchapixel 3.0 at the moment (current version of 2). The idea is to make the project open source by storing the content of the website on GitHub as Markdown files. In practice, that means you and the rest of the community will be able to edit the content of the pages if you want to contribute (typos and bug fixes, rewording sentences). You will also be able to contribute by translating pages to different languages if you want to. Then when we publish the site we will translate the Markdown files to HTML. That means new design as well.

That's what we are busy with right now and why there won't be a lot of updates in the weeks to come. More news about SaP 3.0 soon.

We are looking for native Engxish (yes we know there's a typo here) speakers that will be willing to readproof a few lessons. If you are interested please get in touch on Discord, in the #scratchapixel3-0 channel. Also looking for at least one experienced full dev stack dev that would be willing to give us a hand with the next design.

Feel free to send us your requests, suggestions, etc. (on Discord) to help us improve the website.

And you can also donate). Donations go directly back into the development of the project. The more donation we get the more content you will get and the quicker we will be able to deliver it to you.

2 mns read.

How does it work?

As you will see in this chapter, making an implementation of the Tessendorf paper doesn't require any complicated code or magic Fourier transform library. We believe this is the first and only document on the internet that makes it readily available to anyone (and that probably deserves a little donation) if you can afford it).

How does it work? The first thing we recommend you to do is to have a look at the original paper entitled "Simulating Ocean Water" (by Jerry Tessendorf). It is readily available on the internet. The paper was published in 2001 (a long while ago already).

As mentioned in the introduction, the main idea is that the motion of waves can be decomposed into frequencies (using for instance from measured data the forward discrete Fourier transform that we studied in the previous chapter). By applying the inverse operation from this very specific set of frequencies, which you can look at as the unique signature of the way ocean waves move, we can thus reconstruct an ocean surface. Very simply put, if you know the recipe of a dish, you know how to make that dish. We showed such example in the previous chapter: if you know the frequencies that are making up an image, you can reconstruct this image from theses frequencies. The principle is the same excepted that in this particular case we will reconstruct a patch of ocean water.

If we want to represent a patch of ocean surface, you can guess that what we will need to do is move the vertices of a 3D grid up or down (vertically, along the y-axis). You can see this operation as a form of displacement. The question is thus "how do we compute the height of these vertices to have a resulting mesh that actually looks like an ocean surface?"

xx