Since my last dev log, I’ve made quite a few changes to the fluid simulation which make it look completely different from the last dev log.
First, I added interaction with the particles, which makes things a bit fun but its real purpose was to make testing the simulation easier. After that, I spent some time tuning and improving the physics. I added stuff like viscosity and a repulsion force between particles, which made the particles behave more like an actual fluid and add more customisation.
While working on the physics, I also optimized the SPH simulation. I combined some of the neighbor searches and reduced unnecessary allocations happening every frame. This was pretty simple and made quite a difference.
Once the basic simulation was good enough, I decided to move on to WebGP to really make stuff run smoothly. Both the fluid simulation and particle rendering now run through WebGPU, which gives me a much better foundation for scaling the simulation to larger numbers of particles. Like before the simulation could not run smoothly at around 4000 particles while now I can go up to tens of thousands of particles and still have really good performance (unless the particles are too squished up).
After that, I finally started converting the simulation from 2D to 3D. This was relatively simple as I just had to go around the code changing Vector2s into Vector3s and accounting for the z axis but this made some other underlying issues more prominent. Like one of the biggest issues was particles stacking up against the boundaries walls that would repel other particles. I fixed that issue and made several other changes to get the 3D simulation behaving more naturally.
At this point, the project has gone quite a bit beyond the small Three.js experiment I originally started with. What I want to do next is to make the particles react to other objects and shapes in the environment. I want to try and make it eventually work with more complex shapes as well, so the fluid can flow around and interact with actual 3D objects rather than being restricted to simple boundaries. After which I’ll make the fluid look like water instead of a bunch of balls flowing around and then work on the environment.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.