Wednesday, December 28, 2016

What concepts are there for interactive water?



I want water to be a gameplay object in my game. The player should be able to take in in a bucket and tip it out somewhere in the world. Water should flow in some way so that it can be used to build rivers and transport game objects or to create particular apparatuses. It's comparable to the game Minecraft where you can build cool things involving water or just create just some small waterfalls. However, there my game isn't made out of blocks so there is smooth terrain.



In most games water is simply placed at a given height. That works well for lakes and Oceans, but for flowing rivers and usage in apparatuses this concept is to limited. In Minecraft water is implemented as a block which spreads inside the blocky grid, too. That approach is a bit more what I need to realize my idea but I don't use these blocks and therefore such water simulation would look very misplaced.


What concepts of representing water which the player can interact with in the mentioned manners are there? How can I realize oceans, rivers, buckets and so on with one general approach? There shouldn't be an infinite amount of water. If you fill your bucket, the volume of the lake the water was taken from should decrease unnoticeable. Moreover if the player would place water somewhere that volume of water should never go missing.



Answer



If you're looking to have not a lot of water move over a terrain, then your best bet will likely be some form of Smoothed Particle Hydrodynamics (or SPH). In this formulation, you simulate a set of particles as they adhere to the laws of hydrodynamics (namely, the Navier-Stokes equations). There is a great series of articles written about this from Intel:


http://software.intel.com/en-us/articles/fluid-simulation-for-video-games-part-1


Rendering your particles as fluid will likely be done using some sort of metaball formulation. You can get a good intuition from this article. The basic technique is described here, and what you can expect it to look like is something like this although it will depend how you write your shaders.


For larger bodies of water, I suggest looking at this tutorial which outlines some of the techniques used to generate a large body of water. You can combine this with the previous method to have fluid that flows into large bodies of water too.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...