A GPU particle simulation built on Kool Engine. The goal is to provide a simple API for writing arbitrary particle interactions as compute shaders.
These can run efficiently on most consumer hardware, including in browser using WebGPU. We provide a compiled version which uses Lennard Jones potential with parameters that can be configured live in the application.
- Pairwise interactions that can be configured differently for any pair of particle types
- UI for editing simulation parameters parameters live
- 2D/3D simulation
The particle simulation runs entirely on the GPU, with Kotlin code to setup the GPU pipeline, create shaders that compile down to different targets (OpenGL, Vulkan, WebGPU), and for application UI.
The pipeline on the GPU currently looks like this:
- Split particles into grid cells and sort them to be close together in memory
- Calculate net forces on particles by iterating through particles pairs (with n-particle interactions planned)
- Update positions and velocities using the velocity Verlet algorithm
- Every n steps, render all particles using instanced rendering
- Download the latest release
- Install Java 21 or above (ex. from here)
- Run in a terminal with
java -jar path/to/particles.jar
Or, try the browser release on a browser with WebGPU support (ex. Google Chrome)
- Clone this repository
- Run with
./gradlew run
(orgradlew.bat run
on Windows)