N-Body Simulation: Testing a 3D Scene using the GPU Compute Shader




I finally completed my first compute shader, and thought the visual output looked quite cool! This only uses the GPU for all physics and graphical computation, the CPU is basically idle. The program only runs 16,384 bodies, but that’s pretty decent given that you’d have to do serious optimization (brute forcing, no trees etc) on the CPU to get the same throughput (and probably still couldn’t achieve it at real-time rates anyway).

Compute shaders allow you to use the GPU to do a bunch of the heavy-lifting in your code, to the degree that the GPU has any capacity over and above whatever graphics-specific things you are throwing at it.

If anyone has any questions on how to get compute shaders like this up and running, more than happy to help – I found the examples online and in books are riddled with errors or aren’t very user-friendly. This was done in OpenGL / GLSL / C.

Other Social Media stuffs:

https://www.twitch.tv/s0llygaming

https://www.instagram.com/s0lly.gaming/
https://github.com/s0lly
https://www.patreon.com/s0lly

Youtube original link

Leave a Reply

Your email address will not be published. Required fields are marked *