I’m looking to simulate shallow water with waves breaking on a beach. It doesn’t need to be accurate or respond to physics in any meaningful way, it just needs to look good and get players in the mood.
One look at the asset store and you’ll see dozens of shaders made for rendering water and even a few that say they’re for ocean rendering. Most of these will talk about reflection, refraction, and underwater fog.
None of them look anything like this:

Or this:
Or this:
Mirror for first 30 seconds of 2nd video if you can’t see YouTube:
I don’t see anything under the water; refraction and underwater fog don’t apply. The reflection is so diffused we don’t even need to think about planar or screen-space reflections; it could basically be replaced with a single color, possibly attenuated by distance from the camera to fade from blue to a slightly darker blue. The only salient effects are the rolling waves themselves, spray and foam – and there is a LOT more spray and foam in a shallow water/beach simulation than in a deep ocean.
The first thing you’ll find on a search is NVIDIA WaveWorks: NVIDIA WaveWorks | NVIDIA Developer . This is a bit out of my price range for an indie developer. Also, all the demos/videos appear to be for deep-water simulations; if you’re trying to do a boat it would work fine, but the foam generation looks kinda wonky and the videos are very careful to never show a beach scene. And here’s why…
So back to the drawing board. Anything involving simulating every particle (SPH) feels like a no-go; you’d need to use way too coarse a grid to get playable frame rates, which wouldn’t scale to a whole beach scene. So what if the actual water simulation is done separately from the foam/spray? This thread here extensively discusses the rolling motion and shape of the waves themselves, and appears to be a decent model of that action:
That covers the large-scale wave deformation, but not the spray and foam. Most of what I’m seeing does particles for the spray (the alternative would be raymarching like volumetric clouds do but I don’t see a compelling reason to do that). Using particles for the foam also seems like an option. Here’s a very blurry video from 2010:
Sadly, I can’t seem to find much more info on that technique, because it looks really very good. That’s exactly what I want.
Another option I saw somewhere (can’t find link) was to use a 2D Navier-Stokes simulation on a texture for the surface of the water to simulate foam and project that over the actual wave surface as a foam density map. The issues here are how to properly spawn and dissipate the foam as well as modelling the undertow of the wave pushing and pulling the foam. If anyone has any links to something like that, I’d love to check them out, although it might end up being a “play with it until it looks decent” sort of thing.
A final option might be to use wave-particles:
I’ve prototyped that before (for a pool, not an ocean), so would be easy for me to port to Unity, then somehow integrate the vertex-based rolling waves and the foam/spray. The tricky part is that “somehow”; how would you generate the particles on the edges, or turn the WP collisions into actual foam that could be rendered, and places to emit spray particles? However, this gets the small details of the surface and collisions with rocks/surface outcroppings in a way that’s reasonably scalable, which is not necessarily true of the other techniques (Navier-Stokes isn’t cheap at all but the smallest scales), so it could look good both close up and far away.
Ultimately, I don’t know how worthwhile it is to pursue this. Since so many commercial games seem to ignore this, perhaps it’s an intractable problem with today’s hardware, or just so expensive to render that the rest of my jungle island would need to be a single billboarded sprite so the beach would look good ;-P. But if anyone has any other ideas or can point me to some specific, detailed info about how they achieved something like this, I’d love to hear your thoughts. I want big, crashing waves with huge foamy sprays, not weenie little gerstner waves disappearing into the sand.



