redmotion: January 2011

27 January 2011

ShiVa3d: Optimising 3d on Android

Just discovered "Delta Time".

In Shiva I'm applying 'Delta time' to anything and everything that moves in the game. You can do this by:-

1. Getting last frame time with something like this:-

local nTime = application.getLastFrameTime ( )

http://www.stonetrip.com/developer/doc/api/application-getLastFrameTime

2. Then whenever you apply movement or a physics force to something apply this calculation to the value:-  value*nTime*60 (the 60 being 60hz refresh rate).

Then, even if your device is only managing 10FPS you'll still have exactly the same play speed as if it was playing back at 60fps. It will also mean that playback is at the same speed on your device and in the editor, reducing the number of times you need to compile, copy over to and run on the target device. (My phone (its old) can't be used with the Shiva tools .apk)

3. Minimise the number and/or complexity of colliders - use Shiva box shapes with 100% transparent materials and collider attributes applied to them whereever possible. DO NOT just apply them to complex meshes or entire level models as it will quickly kill FPS.

My poor old HTC Hero can only muster a measily 10FPS but the game is still playable.

Which means I can hold off from buying a new phone for now. :-)