Skip to content

lucascompython/particle-simulation-2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2D Particle Simulation

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.

Demo

particle-simulation-2d-demo.mp4

Simulation Methods

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!

Build Locally

This project has the following build dependencies:

  • zig - for, well, the program itself
  • python3 - for dear_bindings and fetching the dependencies of Dawn
  • git - for downloading the submodules
  • rust - for compiling wgpu-native
  • clang - for compiling C/C++ code with LTO enabled and not conflict with the Zig/Rust compilers
  • cmake - for compiling SDL3 and Dawn
  • ninja - for compiling SDL3 and Dawn
  • 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

TODO:

  • Add Web support
  • Improve performance
  • Add mobile support
  • Make CI work nicely

Releases

No releases published

Packages

No packages published