We’ve been working extremely hard on the particle physics project. A work-in-progress version of the simulation will be at the Science Festival! Saturday, October 8th, 10am-3pm. This simulation will be in the Cube. Come check it out!
Before I dig into what we’ve been working on, insert obligatory pretty video:
The main to-do list we’d like to accomplish before the Science Festival:
1. Me – Get all the particle sprites for the different kinds of particles
2. Me – Color code the path lines in coordination with the particles
3. Me – Get the full Belle II detector model in, albeit combined and completely opaque.
4. Tanner – implement draft of sound (OSC communication of particle data is complete, so he can pick it up and make it sound awesome)
5. Topher, Jesse, Sam – Make a flyer for audience to pick up on their way in
6. Topher, Jesse, Sam – Make all the images for the particle sprites, so I have them to import (there’s around 120 different kinds of particles!)
We’ve had 3 team meetings now, which are extremely helpful now that we have a full team on board. This includes:
Christopher (Topher) Dobson – senior, physics education
Jesse Barber – junior, physics
Samantha (Sam) Spytek – senior, physics education
Tanner Upthegrove – ICAT staff, sound
Zach Duer (me) – ICAT staff, visualization / organization
Dane Webster – faculty, school of visual arts
George Glasson – faculty, school of education
Leo Piilonen – faculty, physics
Nicholas Polys – faculty, computer science
Todd Ogle – master of all things, TLOS
Just in the past few weeks, Sam and Topher have picked up on the game very quickly and set out with Jesse to do a lot of work developing the educational aspect of the simulation. In the next update I will go into more detail on that.
In the meantime, I’ve been working my butt off optimizing the simulation to keep a decent frame rate. There were 3 major bottle-necks. I’ll detail them here, along with the solutions:
- The model, with all its 400,000+ individual objects slowed the frame rate down to about 10FPS. It’s a CPU problem – the GPU breezes through it, since it’s only about 2million polys. The CPU is struggling with this due to the number of draw calls. A lot of the objects are duplicates (the same mesh with the same material, but a different transform). This lets Unity reduce the number of draw calls by batch rendering, but just the process of doing that batching slows it way down. To maintain 60FPS, the full draw cycle has to happen in 16 milliseconds or less, so if there’s one thing that takes 0.01 milliseconds but it happens a few thousand times, it’s a huge problem. I’m still working on this, but in the meantime, I’m combining each major layer of the BelleII detector into a single object and setting it to an opaque material. Although this process takes some time, after I’m done the frame rate should be back up to a steady 60FPS
- The lines rendered to show the paths that the particles will take over the course of the simulation, the “pathlines” as I’m calling them, take too long to render if rendered individually. For the complex events, we’re talking about something like 4 million lines. Even if they’re done in one draw call, it’s still just too slow if done every frame. With just rendering these lines, it dropped the framerate to about 3FPS. So, instead I purchased a package from the Unity Store called FastLineRenderer. Since all the lines are known when the simulation starts, I can send them all to FastLineRenderer, and it converts them into a series of meshes (something like 64k lines per mesh). This shoots the framerate back up to almost 60FPS.
- I needed to optimize the script controlling particle movement. Yesterday and today, I completely rewrote the thing to eliminate the need for certain loops that were bottlenecking. I won’t go into any more detail now, but the resulting code is, in my opinion, much cleaner and easier to read, AND it’s a lot faster.
All that put together, and you can how smooth the above video is. Not all the meshes from the Belle II detector are finished combining, so I just threw in the Electromagnetic Calorimeter for that video. The framerate never dropped below 50FPS. I’m pretty proud of that.
Oh, and I put Lucas Freeman’s (mostly complete) Cube model in the project too, so that vastly improves the aesthetic quality.