Results 1 to 10 of 39

Thread: Trouble porting liquid simulation to Pascal - AARRGGHH!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Water simulation on pixel/block map has been in my interest for long time. I did some experiments long ago, but they weren't that great. However that tutorial you linked (http://w-shadow.com/blog/2009/09/01/...id-simulation/) was quite good, only that it was explained way too complicated.

    Lets say we do water for pixelmap. For performance and memory reasons we want to have running water in a separate array like particles, and still water (100% of pixel in water) drawn to pixelmap. The particles try to divide its water to different down, left and right, and if they can't move and go full 100% of water they solidify into pixel to that spot.

    The particle could have the water amount represented as byte (0..255), where 255 is full. Down direction is first priority. It attempts to move down if there is no particle at that spot, but if is, it adds all its water to that particle at down. How do you know what particle is down and that pixel reserved, is 1 problem. I'd propably solve it with per-pixel word map, each 0..65k telling particle index in that spot. It's much faster than going the whole particle array through checking for position, but takes more memory and limiting amount of max particles.

    Next there is left and right. They must be considered simultaneously so that the water is split evenly to all 3 positions, self, left and right. Well, here it doesn't propably even matter how you do the math, it will look cool anyway and spread the water in all cases. You can even split all water to left and right and leave current position empty, if they had room to take it all. Or you can calculate it so that water level in all 3 blocks is made as close to each other as possible, with water you have usable from the current particle.

    Could add that it might look pretty nice if water that is falling down would split it to left and right about 20% of its amount. It will make little shower effect, because it may look boring to see water flow down 1 pixel wide line.

    Oh, when doing for-loop for dynamic particles like this, you must go through it from ParticleCount-1 downto 0. It will otherwise act weird.
    Last edited by User137; 27-08-2011 at 03:54 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •