Material point method in Vulkan

During the lat weeks I implemented with a few other students at university a simulation for soft-body dynamics and really basic fluids using the material point method (in short MPM). The goal was to use different sizes for individual particles which would decrease or increase their specific area of impact.

It pretty much works like this:

👉 1. You have an amount of particles which you spread around to represent a specific volume (for example a sphere or a cube but it could be any mesh really). Then you give each particle a mass, velocity, position and volume. The particles will pass in their area of impact their information about mass and velocity into a grid data structure as weighted impulse and weighted mass depending on the distance between each grid cell and your particle.

👉 2. The next step is to adjust forces to the grid cells and collect data in the area of impact of each particle from cell back to the particle. Then you calculate from that the new velocity of the particle and move it regarding to its next position.

Those steps will be repeated each time step, potentially giving you similar results as in our video on YouTube. 😅

But there can be certain issues which can take quite some time to fix. We used the Vulkan framework (VkCV) I mentioned in a post last year to not mess with typical boilerplate code and to reduce compatibility issues with different operating systems and compilers. However that doesn’t mean all GPUs and drivers will play nicely, does it? At least debugging some mistakes in your shaders won’t get easier. 😞

In the end I can only recommend checking for barriers in your compute shader when you use shared memory and don’t expect floating point types to do anything related to math properly. Otherwise you will get a lot of explosions but no soft-body or fluid. 😅

Also don’t expect empirical values of certain materials to work because let’s face it, your time step will probably be discrete and it will probably be too big. 😨

Anyway this little project is done, the code will be open-source (of course) and gets merged into the repository of the VkCV framework. So anyone interested can give it a try and play around with a wobbling cube. 😉

Read original article

Popular posts from this blog

GNUnet Messenger API: March

GNUnet Messenger API: September

GNUnet Messenger API: December