• Register
Post news RSS Optimization in progress

Here are some details of our ongoing optimization efforts. Some of our steps really brought the framerate significantly up, some where just useless programming exercises - well, not useless in terms of improving coding skills, but no benefit to framerate.

Posted by on

Currently switching back and forth between optimization and fixing the levels so they play well on a mobile device. We didn't expect optimization to take so much percentage of our time, but 10 fps on a mobile device just won't cut it. We decided to go with a fancy, wow-effect camera and it comes at a price. :)

Special Camera Needs

We are using a fisheye distortion camera, which zooms into whatever is in its centre, and leaves all objects outside a certain radius undistorted, but shifted outwards. Imagine a big magnifying glass in the centre of the screen.
If we would simply apply this transformation to the whole view, it would leave us with banana-shaped or sausage-shaped or smiley-mouth shaped planets between the centre and the undistorted outer regions. Not very nice. Martin's planet graphics have deserved better ...
So we apply the bubble distortion to the atmosphere of the planet, BUT keep the planet in the centre circle-shaped (NO BANANA) AND thus have some interpolation magic going on in-between.
This gives us our zoom effect, but keeps the planet graphics original. Looks awesome, but needs some optimization love, especially on mobile devices.


For each of our particles we have to check if they are in the attraction zone of a planet. So we had some piece of code that simply iterated through all the planets. Now, Ladies and Gentlemen, welcome the PlanetAreaLookup class which makes a rough grid (20x20 for one star system) that for each grid gives you back an array of planets intersecting it.

From checking against say 45 planets I went down to 4 at worst and 1 at best. Gave me around 10 fps improvement on my PC.

We are getting there. Soon, so soon.

Other Lookup Tables

We tried a couple of other look up tables to improve performance. The distortion transformation mentioned above is radial, i.e. it takes the vector from the camera center to the point to be distorted and stretches the vector by a distortion function. I tried a 1d lookup for that with linear interpolation between the sample points, which is a ted faster for few sampling points (although it also looks a bit worse), but ends up with no gain when increasing the number of sampling points. Not entirely sure, why ...

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.