← Back to Projects

Compute Shader Particle Sim

An OpenGL compute-shader pipeline simulating millions of particles in real-time.

A final project for a Computer Graphics course. Below is a demo video, initially rendering 2,250,000 particles at 120 frames per second.

The core idea is to use a compute shader to update all particle positions on the GPU without CPU intervention. Heavy masses, bounding spheres, and user-controllable elements are updated on the CPU through ImGui, but all physics calculations run on the graphics card via a Shader Storage Buffer Object (SSBO).

Surprisingly, the physics computations are very fast compared to OpenGL's rendering of the actual particles, so they are rendered as GL_POINTS to reduce frame times. Future work includes adding per-particle mass, testing various storage objects (textures, array buffers), and interlacing data for better memory coherency.

Other potential extensions include turbulent flow simulation, 3D flocking simulation, and ensuring the compute shader is the true performance bottleneck.

C++ OpenGL GLSL Compute Shaders ImGui GLEW GLFW GLM