2D Fluid Simulation with Portals
Controls:
- Click and drag flow with the mouse to add color and movement.
- Click on the middle of a portal to move it.
- Click on the edge of a portal to rotate it.
- Use "A" to switch between visualization modes.
- Use "S" to change if or witch color should be injected.
- Use "D" to change simulation speed.
Note: The web-version seems to run quite poorly, for reasons I can't be bothered to figure out. Consider downloading the program for higher fps.
The implementation of the fluid is very similar to the algorithm suggested in "Real-Time Fluid Dynamics for Games" by Jos Stam. Though there are some minor modifications:
- I ignored the diffusion term. The integration scheme is stable without it and physical accuracy does not have priority. So there is no reason to include that term.
- I keep the value of the "pressure", convect it like the other values and use that as an initial condition for the next iteration. Though I didn't test if this actually works better.
- I put the loops into shaders, so everything runs on the GPU.
- I added portals.
The movement of the portals works the following way. A fluid-volume is transported when it crosses the portal-surface, which is assumed to be a line. When a fluid-volume is transported its momentum is rotated based on the relative orientation of the portals and momentum is added based on the relative speeds of the portals to each other (aka Option B).
A short demonstration video:
Updated | 5 days ago |
Published | 7 days ago |
Status | Released |
Platforms | HTML5, Windows |
Author | MechanicsDriven |
Genre | Simulation |
Made with | Unity |
Download
Click download now to get access to the following files:
Development log
- Tiny Update6 days ago
Leave a comment
Log in with itch.io to leave a comment.