This project is built with Zig
, SDL3
, Dawn
/ Wgpu-Native
and ImGui
.
This project is a rewrite of this project that used Raylib and performed all the calculations on the CPU.
I'm making this project with the goal of learning modern graphics programming and the differences between graphics library stacks.
A 3D version of this simulation that uses Rust
+ Winit
+ Wgpu
+ Egui
, can be found here.
particle-simulation-2d-demo.mp4
The simulation can run on different methods, such as:
- CPU - Works everywhere but has limited performance
- GPU (Compute Shaders) - Only works on native and WebGPU (no WebGL support) but has much better performance
I wanted to add another GPU method, namely Transform Feedback since it is (I think) pretty the most performant method for this simulation that can run on WebGL, but I've found it difficult to implement in wgpu
. Here is a discussion about it. Still looking into it!
This project has the following build dependencies:
- zig - for, well, the program itself
- python3 - for
dear_bindings
andfetching the dependencies of Dawn
- git - for downloading the submodules
- rust - for compiling
wgpu-native
- clang - for compiling
C
/C++
code withLTO
enabled and not conflict with theZig
/Rust
compilers - cmake - for compiling
SDL3
andDawn
- ninja - for compiling
SDL3
andDawn
- And development packages of multiple things like OpenGL, X11, Wayland, libc++, etc.
git clone https://github.com/lucascompython/particle-simulation-2d.git
cd particle-simulation-2d
zig build make-deps # Will fetch the submodules and build the dependencies (SDL3, ImGui, Dawn, Wgpu-Native)
zig build run
# OR
zig build run -Doptimize=ReleaseFast # for release build
- Add Web support
- Improve performance
- Add mobile support
- Make CI work nicely