# Implement Water Ripple effect

I am doing my master’s thesis and have chosen to implement water ripple effect. The best example of what I am trying to achieve is: madebyevan.com/webgl-water/
This demo encompasses several effects as denoted by the author:

[ul]
[li]Raytraced reflections and refractions
[/li][li]Analytic ambient occlusion
[/li][li]Heightfield water simulation
[/li][li]Caustics
[/li][/ul]

Currently, I want to implement the “Heightfield water simulation”. I’ve found lots of articles and discussions (cannot post them due to a restriction on the number of links that a forum topic could contain) but cannot see the most right way to implement it. Saw several physics formulas - model the water surface as an elastic membrane with low stiffness or use Navier-Stokes еquations. Most of the tutorials speak how to simulate arbitrarily moving water but not water ripples.
Could you point me to the most correct maths/physics and OpenGL practices for simulating water ripples?

Did you already take a look at this? It discusses a simple pseudo code implementation of height map based water surfaces.

Yes, it was the first thing to read. But as you start reading it you find the following:

Initialize u[i,j] with interesting function

First question: what is this? Is it to fill a map with arbitrary height values, so that I have initial non-calm water which I later on modify by:

v[i,j] +=(u[i-1,j] + u[i+1,j] + u[i,j-1] + u[i,j+1])/4 – u[i,j]

Which means - add the average sum of all surrounding pixels, or vertices, and then subtract that of the center one. So, they probably initialize the mesh vertices’ heights using the “interesting function” and they later on modify the already initialized vertices’ heights. This leads to simulating water, not simulating water ripple. That is why I wrote:

Most of the tutorials speak how to simulate arbitrarily moving water but not water ripples.

So, this and another several tutorials were the first I saw. Then read someone speaking about sinc and sombrero functions, which are actually fading sin in 1D or 2D respectively. These are more close to what a math representation of a water ripple should look like. Here’s a sample code of the heightfield simulation you gave link about: www.roxlu.com/2013/024/height-field-simulation-on-gpu
It cites the same tutorial you gave link about but older I think: www.cs.ubc.ca/~rbridson/fluidsimulation/GameFluids2007.pdf

Probably, I should better read the tutorial becase this video illustrates the given heightfield effect: www.youtube.com/watch?v=mh4ouyoMlL8

Yes. You initialize the height field with initial wave crests to propagate. The formula you quoted is for updating the height map each frame what generates the wave effects.

This does simulate water rippling. You apply the above formula each frame for propagating the waves. The waves are implicit in the height map values.

[QUOTE=caravanio;1262780]
So, this and another several tutorials were the first I saw. Then read someone speaking about sinc and sombrero functions, which are actually fading sin in 1D or 2D respectively. These are more close to what a math representation of a water ripple should look like. Here’s a sample code of the heightfield simulation you gave link about: www.roxlu.com/2013/024/height-field-simulation-on-gpu
It cites the same tutorial you gave link about but older I think: www.cs.ubc.ca/~rbridson/fluidsimulation/GameFluids2007.pdf

Probably, I should better read the tutorial becase this video illustrates the given heightfield effect: www.youtube.com/watch?v=mh4ouyoMlL8[/QUOTE]
The height map based approach does not explicitly deal with waves. Waves and ripples are an emergant propperty of the simulation. Those other things you mentioned
actually work with explicit matematically representations of waves.