Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
3  
What type of game are you making? The ASCII game Dwarf Fortress has a surprisingly complete and accurate water systems, incorporating flow, pressure, and waterwheels. Doing so in a 3D rendered game would be a challenge. –  Jon of All Trades Mar 19 '13 at 12:59
    
@JonofAllTrades. I make a 3D rendered game. –  danijar Mar 19 '13 at 16:21
    
I found a 2D game which is based on water dynamics. It's called Vessel and there is a gameplay video on Youtube. This may help people who are looking for some inspirations for their water implementation. –  danijar Mar 30 '13 at 12:19

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
    
Thanks for your answer! I wonder if this approach would be sufficiently fast. It's about a 3d video game with many features aside like animation, physics simulation and AI. But the results of the technique you described would be amazing. Do you have experience implementing this? –  danijar Mar 19 '13 at 16:28
    
It's already been implemented in some 3D games, so it really depends what you mean by "reasonably fast". If you're worried about how it will fit in your game, then I suggest you start actually making your game and tackle that hurdle when you get to it. I have some experience in this domain, but I haven't developed it in the context of games. –  Mokosha Mar 19 '13 at 17:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.