Boilerplate performance improvements
I spent the last couple of days making some under-the-hood improvements to boilerplate. If I did my job right, you shouldn't notice the change at all.
I rewrote part of the graphics engine to use OpenGL. Previously rendering time was evenly split between rendering the background cells, pressure shading and drawing the shuttles. Now rendering the background is basically instant (thanks webgl), and updating pressure is only slow when the simulation steps (like below), which only happen once every 200ms. The aggregate result is about a 3x framerate improvement. Rendering the CPU I'm working on went from 7fps up to 20fps - which is a big jump, but there's plenty of room left for improvement. There's no reason it shouldn't be a smooth 60fps all the time. The slow parts now are updating pressure (2) and rendering shuttles (3). The next optimisation target will be the shuttle drawing code. Its currently implemented by a hairy lump of canvas. I'm tossing up between using SVG or rendering that in webgl as well.
This is what simulation step frames look like now. Normal frames only have the shuttle drawing(3) visible in the trace. Rendering the background and the pressure is so fast it doesn't show up at all.
I'm using PNG instead of JSON to save data on disk. It turns out PNGs are very efficient at losslessly storing 2d grids of information (!! who knew). The result is a 50x decrease in file size.
Before (500k):
After (9k):
Other fun facts:
I also installed Windows 10 the other day, and boilerplate worked straight out of the box. That was shocking and delightful. Everything stopped working again when I moved to webgl because its still behind the experimental-webgl flag (fixed now). But other than that, great work MS. I might keep using Edge as my default browser in windows.
Now that I've spent a couple of years teaching graphics programming, I understand linear algebra enough to write my matricies out directly.
I know its unreadable but I don't care. I did the calculations myself using pen & paper. I know matricies well enough that I'm capable of that now. (It almost worked first time, too.)