Coding a Realtime Fluid Simulation in Unity [Pt. 2]

Опубликовано: 16 Октябрь 2024
на канале: Code With Ajay
8,039
174

The last time I made a video about how to code a fluid simulation using SPH, it was pretty slow so I made this follow-up video that will hopefully help you understand how to optimize it using a dynamic hashed grid, the core technology used is Smoothed Particle Hydrodynamics, and everything is written from scratch in Unity using C# and Compute Shaders.

If this video gains some interest I'll release a third part on how to realistically render this fluid in a performant way.

The editing on this one is a bit rough, was in a rush so please forgive me for that :)

I'll see you all next time ✌

---
Project Links
---
GitHub: https://github.com/AJTech2002/SPH-Uni...
Base Project: https://github.com/AJTech2002/SPH-Uni...
FluidRayMarching.cs : https://github.com/AJTech2002/SPH-Uni...
---
Information Links
---
SPH Paper: https://matthias-research.github.io/p...
Sebastian Lague Raymarching:    • Coding Adventure: Ray Marching  
Thread Groups Medium Article:   / compute-shader-indices  
Nvidia Dynamic Hashed Grids: https://on-demand.gputechconf.com/gtc...
Bitonic Merge Sort:    • Bitonic Sort - Sorting Algorithms Min...  
Spatial Hashed Grids:    • Spatial Hash Grids & Tales from Game ...  
---
Timestamps
---
Intro: (0:00)
SPH Explanation: (0:34)
Dynamic Hashed Grid Explanation: (3:19)
Setting up for Optimization: (4:00)
Hashing Setup: (6:51)
Bitonic Merge Sort: (7:46)
Compute Cell Offsets: (8:55)
Density & Pressure Calculation: (14:13)
Apply Optimization: (10:38)
Testing & Bonus: (11:26)