[HN Gopher] Simulating water over terrain
___________________________________________________________________
Simulating water over terrain
Author : ibobev
Score : 224 points
Date : 2025-02-06 14:15 UTC (8 hours ago)
(HTM) web link (lisyarus.github.io)
(TXT) w3m dump (lisyarus.github.io)
| FrustratedMonky wrote:
| Guess this explains why water effects in Minecraft are bit
| kludgy. It isn't so simple.
| adrianpluis wrote:
| interesting perspective. I see how this can get tedious even
| for a large business like Microsoft.
| AlotOfReading wrote:
| Water and lava in Minecraft were originally even simpler flood
| fills. If you dug into a source at max height (64) of the
| 256x256 map, it would flood the entire world with an expanding
| wall of death.
| joproulx wrote:
| Another take on fluid simulation (Coding Adventure):
|
| Rendering Fluids: https://www.youtube.com/watch?v=kOkfC5fLfgE
|
| I Tried Putting my Fluid Simulation on a Planet:
| https://www.youtube.com/watch?v=8nIB7e_eds4&t=817s
|
| GitHub: https://github.com/SebLague/Fluid-Sim?tab=readme-ov-file
| all2 wrote:
| That second one was a joy to watch. I thoroughly enjoy that
| kind of high level tour/discovery video.
| shreddit wrote:
| Each of his videos is a joy to watch. He has a very relaxing
| voice
| h1fra wrote:
| Game developers are truly on an other level
| ikety wrote:
| Always makes me feel like a CRUD monkey when I see this stuff
| all2 wrote:
| Add a water sim to your crud?
| m12k wrote:
| "This button lets you edit the blog post. This button saves
| it. And this one lets you pour a stream of water over it"
| magicalhippo wrote:
| "And this button turns your blog into a Doom map"
|
| (ie letters being walls, background the floor)
| bodge5000 wrote:
| Off topic, but the post mentions needing terrain manipulation for
| resource gathering.
|
| I always thought animal crossing had a clever and efficient
| approach to this without any terrain manipulation. You can chop a
| tree, and it'll dispense logs, but only so many before it
| essentially has a cooldown. You get the feedback and the finite
| resources, without expensive terrain manipulation.
|
| Of course that doesn't work for every game, and really works
| better on smaller maps, but something worth considering. Terrain
| manipulation is pretty expensive, if your game doesn't need it
| it's probably better to do without (again, a generalisation)
| setr wrote:
| The blog mentioned that strategy, in the form of gold ore in a
| gold ore boulder found lying around
|
| It a standard strategy for resource dispensation (though
| cooldown doesn't alleviate the infinite resource problem; it
| just slows it down), it's just... boring and unimpactful
| elliotbnvl wrote:
| This is super, super cool!
|
| I was experimenting with a similar idea recently with the help of
| o3-mini-high. I talked it through my idea for an algorithm, and
| it implemented and rendered it in 3D with no manual intervention
| (although I did prompt it a number of times):
|
| https://3d-water-sim.netlify.app/
|
| It's not perfect yet because I stopped playing with it, but it
| was improving significantly with each iteration.
|
| Fun fact, it implemented a working version of perlin noise
| correctly from scratch instead of pulling it from a CDN or
| something as part of this, for the terrain generation.
| matheist wrote:
| The waves when the water is first entering the area is called
| numeric dispersion, it's a consequence of discretizing. It can be
| mitigated somewhat by smoothing the entering wall of water so
| that there's not a sharp discontinuity.
| lisyarus wrote:
| Interesting, thanks! Is it kinda like the Gibbs phenomenon?
| matheist wrote:
| Take a look at the other reply, which says it's actually not
| dispersion. My mistake!
| semi-extrinsic wrote:
| I don't think so, the waves are actual shock waves which are a
| solution to the Riemann problem for the shallow water equations
| because they are nonlinear hyperbolic equations. You can find
| them even before you start introducing any numerical grid or
| discretization.
|
| See e.g. the classic exposition by Leveque:
|
| https://www.clawpack.org/riemann_book/html/Shallow_water.htm...
| matheist wrote:
| Very interesting, my mistake! I'm more familiar with
| acoustics and assumed it was the same phenomenon, but it
| looks like I jumped to a mistaken conclusion.
| pornel wrote:
| Storing values at the edges of cells makes the math simpler, but
| unfortunately makes a GPU implementation harder.
|
| In this setup one edge update affects two cells, so the cells are
| no longer trivially independent. It's still possible to update
| cells in parallel, but it requires splitting the update into two
| checkerboard-like passes.
| lisyarus wrote:
| It's true that it makes it more complicated on the GPU side in
| general, but specifically in this scenario everything works out
| just fine, mostly because all updates effectively ping-pong
| between flow & water height buffers, and you never change both
| in the same kernel.
| hgomersall wrote:
| It's nothing like that complicated. They just need to retuculate
| the splines.
| TheGRS wrote:
| Neat dive on this topic, and I appreciate calling out Timberborn!
| I'm obsessed with that game currently, big big big recommendation
| if you haven't checked it out yet. The water physics are like
| another character in the game and figuring out how to dam up a
| bunch of water to use in your engines and to water your fields is
| an essential part of the gameplay loop.
| vladms wrote:
| Nice explanation. I like the viscosity part, I implemented
| something similar a couple of years ago in an open source RTS
| game engine (test video at:
| https://www.youtube.com/watch?v=cQW8WXNpYXk), and without
| viscosity water was spreading thin and due to floating point, at
| some point it was spreading on flat surfaces and "evaporating".
|
| Also, the grid resolution required to obtain nice waves was a bit
| too much for the effort I put 5 years ago (probably needed
| another thread, etc.)
| lisyarus wrote:
| Very cool! Based on the video you're also doing some
| hierarchical subdivisions?
___________________________________________________________________
(page generated 2025-02-06 23:00 UTC)