Why is Graphics.PresentAndSync taking so long? Woah that’s a lot of hotspots in overdraw view. Are you sure you need 80 particles a second in this effect? Optimize! Reduce! Make it faster!
We’ve been performing bucket loads of optimization this week while working with the profiler. If the difference between Unity Pro and Free was just the profiler, I think we’d still be happy, because it is such a powerful tool that we have been in desperate need of for a while. We are learning more and more about its magic, for instance, did you know that you can disconnect your device after building to it and Unity will continue to profile your game wirelessly in real time while it runs? Heresy!
Optimization is really something that needs to be considered from the beginning of a production cycle, as we’ve lamented over removing or completely changing so much of our work to ensure that it will run okay in a real-world setting on real-world devices. We’re suffering the consequences of not testing each round of changes on actual devices instead of our super-powerful-by-comparison desktops, and our design decisions going forward and now subject to testing on several target devices to gauge their performance impact before being implemented. This is definitely a design philosophy that we hope to improve upon in future games.
We discovered that overdraw was our biggest killer for mobile devices, which is where you draw a sprite with transparent pixels over another sprite with transparent pixels and it requires extra processing to figure out the resultant colour. There is an overdraw view in Unity that shows hotspots of where overdraw is occurring (pictured in this post’s header) and ours was disturbingly white at the beginning of the week. We’ve revised all of our particle effects and layered sprites to reduce performance on low end devices by over 100% (~20 fps being brought up to 45-50fps), which is a performance boost that only indie game developers could boast.
We’ve also had to reduce the fidelity of the morphing vector grid behind the actual game grid. It’s constructed using a physics simulation of masses and springs, and it was taking too long to calculate their movement every frame. The new grid has been reduced down to 6×10 tiles or 5×9 nodes to align with the game grid perfectly, and now responds to the player’s input only rather than being affected by each individual entity in the world.
On top of mountains of optimization, we’ve dramatically changed the gameplay in order to ramp the intensity up to 11. The game moves a lot faster, with the player’s base speed being increased by about 30% and fragments spawning 3x more often. There’s a new swipe control system to compensate for these changes, so that you can now change directions much faster or chain together multiple turns without taking your finger off the screen. Moment-to-moment gameplay has become much more intense, and session times are much shorter, which we find translates to more addictive and rewarding play.
We hope to have a new, stable build ready for our alpha testers by the end of next week alongside a new video demonstration of the changes since alpha. We still have a few large hurdles (such as an interactive tutorial) to cross before the beta build is ready to roll, but that due date is looming closer every day…