Hacker News new | past | comments | ask | show | jobs | submit login

Wow, that would be quite fun! How does one sim water in 3d effectively in this sort of case? Is it basically a 2d grid with a third "depth" variable and some simple rules like "where neighbor depth > mine: +1 to neighbor depth on tick" or something?

That approach has the downside that you can't have water jets or multiple layers of caves with lakes above each other. Most "voxel"/block-based games allow blocks to be filled with different levels of water and then have rules to spread it around.

2 Examples:

In Minecraft, there are source blocks and normal water blocks. Water spreads from source blocks towards the lowest point in the area and loses one level (from 7) each step. If you put water source blocks close together, new ones spawn between them. Water just "evaporates" after a few blocks: If you dig up from a cave with flat ground into an ocean, water will spill to the ground and flow 7 blocks. But that makes it easier to handle for players. Example: http://minecraft.gamepedia.com/File:Das_Waterfall.png

Details: http://minecraft.gamepedia.com/Liquids#How_liquids_work

Dwarf Fortress on the other hand has infinite water sources that also have pressure, so hitting a water source with a tunnel will fill your fortress up to the level of the source block, because the water spreads infinitely and also can go up bends. FUN! (Especially if you hit one with high pressure = producing a lot of water. First thing you notice is that the frame rate drops to slide show speed, a few frames later there's water everywhere)

If you block it off, it remains. (vs in Minecraft plugging all source blocks makes water disappear)

This is a more realistic approach, especially if the speed at which the sources produce water is limited and they are only used at the map edges to simulate inflow. Or one could look into finite element modelling and other fluid simulation techniques and try to adapt them for game usage.

The water simulation I have built has finite water and also simulates pressure correctly, as demoed in the past. However, on the downside it is infinitely elastic (a single drop will spread over a large plane, like oil in an ocean). The rendered water also does not correspond 1:1 with the actual water volume, so it can look buggy. And there are still a few minor bugs as well.

I noticed that it seemed to spread laterally much quicker than it dropped, which looked odd. I imagine modeling water in a performant and semi-realistic way is rather hard.

That's really cool. I wonder how you solve the elasticity problem in a way that is performant.

Cool info, thank you for sharing that's quite interesting!

Applications are open for YC Summer 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact