Orbitus
- 2 Devlogs
- 1 Total hours
A high-performance particle physics engine simulating real-time N-body gravitational mechanics.
A high-performance particle physics engine simulating real-time N-body gravitational mechanics.
Figuring out OpenGL compute shaders took a bit of reading, but today I finally got the galaxy moving! I ripped out the old VBO and moved all the particle data into an SSBO (Shader Storage Buffer Object) so I could bypass the CPU completely. I wrote a custom compute shader to handle the gravity math between all 1,000 stars, and now they actually orbit the center mass in real-time at a smooth 60 FPS. (I did spend like 40 minutes debugging a completely white screen, which turned out to be my central black hole particle scaling to 1,000 pixels wide and swallowing the entire window lol..). Next up is probably optimizing the compute shader or adding some basic camera controls so I can zoom in on the physics.
Getting the window to open up in version 0.1 was cool but today things actually started looking like a real engine. I scrapped the basic triangle data I had made in v0.1, and generated an array of 10,000 Particle structs on the CPU using glm. To make it look like an actual galaxy, I biased the random distribution so the stars clump densely in the middle and fade to blue on the outskirts. Right now, they are just sitting motionless in a VBO on the GPU so tomorrow I’m going to look into the OpenGL documentation to figure out how to compute shaders to simulate gravity! (also had to reset the project on hackatime a few times since it was mistakenly picking up a lot of my other desktop projects in the dashboard so yea..)