Simple computational fluid dynamics solver in #quadplay, the retro fantasy console. I'll release as a source sample in the next update. This was quite an optimization puzzle to get running at 60 Hz.

I make little doodles like this as examples and then tend bootstrap game jam projects with them. This one is going in the other direction. It is based on code from a game jam 10 years ago, where it ran in a pixel shader at massive resolution.

@morgan3d May I ask how does it work? At first glance looks like wave equation with wave speed proportional to depth or something like that.

@lisyarus It is a Verlet integrator for Navier-Stokes equations, which is a fancy way of saying a simple hack like the Game of Life for distributing energy. This is a classic demoscene hack.

I originally modeled the wind waves that way but it was too hard to get the constants stable for parameterized wind speed and direction. So, I compute the wind waves analytically using the water depth to create refraction.

@morgan3d Thanks! Are there any resources on that classic demoscene hack? :)
2D Water

@morgan3d Yeah, judging by the code it's solving the wave equation (https://en.wikipedia.org/wiki/Wave_equation) which IIRC can be derived from Navier-Stokes as an approximation to surface waves (maybe through the shallow water equation).

I did a similar thing here, although it doesn't have water-like rendering, and uses explicit Euler instead of Verlet (i.e. stores height & velocity per cell): https://lisyarus.github.io/webgl/waves.html

Wave equation - Wikipedia