r/GraphicsProgramming • • 21m ago

Community Boat wakes from a height-field wave sim in viewport-lib-liquid

Post image

Ripple and wake sim. The water and ripple simulation extends the method described in [How to write a Height-Field Water Simulator](https://www.youtube.com/watch?v=hswBi5wcqAA) by Ten Minute Physics.

It's a damped wave equation on a 384x384 grid:

h_next = h + k(h - h_prev) + (c·dt/dx)² · L(h)
L(h) = h_left + h_right + h_up + h_down - 4h

with k just under 1 for damping.

Spherical colliders push the water, giving the ripple effect as the boat moves. I found that it looks a lot better if, instead of pressing a dent in at the new position each step (which gives little splashes), the dent is lifted where the sphere was and pressed in where it is now. The difference is added to both `h` and `h_prev`, so the water gets carried along rather than splashed, and the wake trails behind. A second channel marks where things have been and fades over a few seconds, which draws as the foam trail.

It's a fairly simple method but gives a nice result.

https://github.com/grimandgreedy/viewport-lib-liquid

4 Upvotes

1 comment sorted by

•

u/AutoModerator 21m ago

Recently updated rules. Please check that your post is in compliance with Rules 1, 4, 5, and 6 on the sidebar. TL;DR:

  • No showcases.
  • Disclose AI usage in post or project.
  • Present a topic to talk about, e.g. how something works.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.