Skip to content

cyprus327/psim-compute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

CPU/GPU Particle Sims

Simple particle simulation where the particles are all attracted to one point and don't interact with one another.

The CPU simulation is written in Odin using raylib for rendering, and the GPU simulation is written in C and GLSL, using a compute shader for particle calculations and raylib/rlgl for rendering.

Usage:

CPU Sim:

  • Install Odin, if not already installed
  • Clone this repo
  • Run odin run cpu

GPU Sim: NOTE: The is in C instead of Odin because I had to recompile raylib's source to be able to use GLSL version 430, and Odin has raylib as part of it's vendor library so instead of going down the rabbit hole of how to recompile that I just wrote it in C.

  • Install Git, GCC, Make, and CMake, and ensure sure your computer supports OpenGL 4.3 or higher
  • Clone raylib, git clone https://github.com/raysan5/raylib
  • cd raylib and edit CMakeLists.txt, adding to the start of the file set(GRAPHICS=GRAPHICS_API_OPENGL_43)
  • Recompile raylib with the edited CMakeLists.txt (e.g. mkdir build && cd build && cmake .. && make && sudo make install)
    • If not installed already this tutorial details how to install raylib on any platform
  • Compile and run following the tutorial mentioned above

GPU Screenshots with 2^23 (~8,000,000) particles

the screenshots don't do it justice, it looks much better moving but I can't screen record on this laptop

gpsim4 gpsim6 gpsim3 gpsim7 gpsim5

CPU Screenshots with 200,000 particles

~50 FPS on my old laptop

psim1 psim7 psim2 psim3 psim4 psim5 psim6

Releases

No releases published

Packages

No packages published