3D Particle Simulator

Made this last night procrastinating from my exam revision. The blue spheres are ‘gravity wells’ which pull particles in. Red spheres repel particles. If anyone has any idea how I could turn this into some sort of game let me know lol.

(video quality is ass)


Not bad. Is this made with shaders?

Nah, they’re just geometries in the scene with some bloom & glow :slight_smile:

Mmh, and how does it scale?

Not very well at all. O(particles*gravity wells). I’m rendering 4000 particles here with 30 gravity wells.

I had to do a similar thing for this for one of my final year uni projects, only rendering the scene in 2D through vga manually (lol) and exporting all of the mathematics to an FPGA to speed things up. I was able render 12,000 particles with 50 attractors and 10 walls at 30fps.

Just took a few extra lines of code to port my solution to 3D and make the camera follow one of the particles

If each particle is a separate geometry then you will get mountains more performance by updating a single mesh of particles instead.

I’d guess you should be able to do 10s of thousands that way.

Hmm, how’s that? If all particles in are a signle mesh would I have to update the vertices of each triangle of each particle individually?

Point sprites may make that easier so you only need to setup a single vertex per sphere.

You could alter the default particle emitter I suppose (which already does the triangle movement setup), but I doubt one can set each particle’s location via the influencer system. You’d probably have to take it apart slightly.

Yep, which is still faster than making the GPU draw separate objects. Each geometry is a separate draw call. They are expensive. Get it down to one draw call and you can be a lot faster.

I don’t know what your particles are, though. Personally, I’d have used point sprites so that each one is just one vertex. Maybe you have reasons for making them triangles, though.

The reason is that I know very very little about 3d games.