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.

Suppose you have a nice way to move your 2D particles in order to simulate a fluid (like water). Any ideas on how to render it?

This is for a 2D game, where the perspective is from the side, like this. The water will be contained in boxes that can be broken in order to let it fall down and interact with other objects. The simplest way that comes to my mind is to use a small image for each particle. I am interested in hearing more ways of rendering water.

share|improve this question

4 Answers 4

up vote 22 down vote accepted

Check out how PixelJunk Shooter did it (including simulation) in this presentation (PDF) at GDC2010.


Sample PixelJunk Shooter Image

share|improve this answer
1  
Didn't know PixelJunk...really a nice pres. Thank you! –  luke Mar 28 '12 at 11:51
    
A link to the trailer :) –  David Gouveia Mar 28 '12 at 12:40
2  
youtube.com/watch?v=HBPQ7GRPTEw –  Jimmy Mar 28 '12 at 20:16
    
What are SPU, PPU, SPURS ? –  Martijn Courteaux Apr 2 '12 at 15:35
    
@MartjinCourteaux: they're part of the PS3's Cell CPU. Think of them like GPU shaders, albeit there are some key differences. –  Sean Middleditch Apr 3 '12 at 19:13

George Duckett's answer is far more direct and really well presented if you need fully-simulated water in your game. For simulated shallow-water physics with minimal accuracy (less realism, more playful), this image gave me an incredible moment of clarity:

http://www.patrickmatte.com/stuff/physicsLiquid/

share|improve this answer
    
Simple and nice! Didn't really think to use such a simple post-processing step...just wonder if a device like iPhone will handle this. It seems to be a good starting point. Thx. –  luke Mar 29 '12 at 8:36
    
I can vouch for this approach. I used it once in a project and it worked beautifully. Add a bevel filter and you can have a nice meniscus on your blobs as well. –  scriptocalypse Apr 3 '12 at 21:18

Or, for a quick and easy approach: Use metaballs!

3d metaballs

share|improve this answer

Grant Kot has put some of his fluid simulation code up on Github with implementations in both javascript (canvas) and C++ with OpenFrameworks: https://github.com/kotsoft

He has a few demos up on his youtube account: http://youtu.be/HqWheJSEiaw

I have no idea how it works, but I know it runs fast and there's all sorts of variations to build with it. A good keyword to search for might be "multigrid particles".

share|improve this answer
    
I really like how Grant Kot simulates fluids! Even if the rendering is minimal, at least on the applet on that web pages. It as a lot of paremeters to control the simulation. Worth a deeper look at it. Thx. –  luke Mar 29 '12 at 20:13

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.