Position Invariant Texture Mapping

While a finite-element hydrodynamics simulation would to be the best approach to create realistic looking waves, the hardware just isn't there yet to calculate this in real time. Also the majority of the current methods to dynamically generate realistic looking wave (such as Tessendorf 2001, Simulating Ocean Water using inverse FFT Transformation and vertex displacement) can only be used for rather shallow waves and cannot be applied to breaking or collapsing waves.

The alternative was to model the large scale waves as independent meshes and programmatically move them across the water surface, while creating the small scale details trough overlayed normal maps in the fragment shader. As the water particles in a gravity driven wave generally only move up and down (opposing common sense and general opinion), moving wave meshes using a translation invariant texture mapping proved to be a computationally inexpensive and realistic looking solution, while still giving the correct physical behaviour for the buoyancy physics discussed in the previous blog post.

Unity already provides a technique for translation invariant texture mapping called "texture projection" (used for cookies etc). But as the name states this is vertical projection of the texture onto the mesh surface and would result in a vertical tearing of the texture on steep slopes of the wave. 

By using the size and position of the wave to calculate an adequate texture space transformation it is possible to map the texture in such a way that it seems to remain stationary on the edges while "wrapping" around the deformation in the center of the uv map. This however requires that the uv map always spans the whole 0.0 - 1.0 of the texture space in both directions.

Using meshes to represent the wave also makes sense because the vertical movement of a two dimensional cross-section of a surfable wave (breaking from left to right or opposite) is basically independent and can be seen as a time-shifted version moving along the horizontal axis. This means the whole animation of a breaking wave could possibly be create by only showing an different horizontal subsection of the whole wave according to time.