Extensions - sahilshahpatel/fluid-sim GitHub Wiki
Congratulations on completing your own fluid simulator! This chapter contains a few ideas for how you might extend it, but the list is by no means exhaustive.
User control
To practice web technology (JS/HTML/CSS) skills, you can add sliders, dropdowns, and buttons to add controls for the user. These could control, for example, your force coefficients or the number of jacobi iterations at each stage.
If you want to get even fancier, you could allow the user to choose the background and dye colors for extra customization!
Multipled dyes
The WebGL fluid simulation here looks very pretty. While we haven't looked into the source code to verify this, we think that they achieve the colorful look in part by allowing the dye to be a 3-dimensional vector (i.e. having red, green, and blue dyes).
To take full advantage of this you would want to generate a specific dye color for each user click and make sure to use that color within addForces.glsl
rather than a set color.
Improving our system of equation solver
As noted in the chapter on diffusion, we used Jacobi iteration for its simplicity. But there are other algorithms out there which are quick enough for our real time use case and have more accuracy. See NVIDIA's GPU Gems chapter for some suggestions including the conjugate gradient.
3D simulation
Moving the simulation to three dimensions would probably require a bit of work, but it's very possible. We have not tested this with WebGL, but 3D textures are available. The math would mostly be the same, but running the boundary checks would be different, and the rendering shader would be significantly different.
Multi-media simulation
This tutorial simulates a container full of liquid. If you wanted to simulate clouds or waves, for example, you would need to model the changing boundary between the fluid and another medium (e.g. air).
Arbitrary boundaries
Currently our boundaries are just the edges of the canvas. You could, for example, add a circular puck to the canvas which users can drag around and have it also interact with the fluid. This adds an arbitrary boundary, meaning that your simulation would have to take into account how the fluid reflects off the puck as it moves, just as the fluid reflects off the border walls.
Be creative!
This list is certainly not exhaustive! You can look online for other cool fluid simulations like this 3D water simulation to inspire you. Our External Resources page may also contain ideas on how to extend this project.