Tic-Tac-Toe Project Write Up

Steven Yates
Sep 8, 2018 · 4 min read

Introduction

This article describes the issues and considerations taken into account while optimising a mobile virtual reality Tic Tac Toe game developed in Unity 2017.2.0f3 using the Google VR software development kit (GVR) v1.70.0. This project brief was to optimise the game to run at 60 frames per second while preserving all the original gameplay mechanics, the start and restart functions, the artificial intelligence (AI) bot and the AI moves.

Stages of optimisation

After having tried to optimise this VR experience with little success and without a clear and logical path, I decided to start again and solve each issue one at a time.

Initially the gameplay ran at inconsistent frame rates and was below 60fps, both on the computer and on the mobile device. The images below show screenshots of the computer and mobile views, where the computer version was running at a high rate, yet the mobile at an extremely low rate.

Models

In the first version of this game the models (furniture, AI bot and elements of the room were all created using high quality artwork with a large number of polygons per object.

Frame rate on computer and mobile iPhone 5 early in project

The room and all its elements were swapped for lower quality images with far fewer polygons and the room objects were set to static.

There was a noticeable improvement in the framerate, as the images below depict with the rate increasing from 27 to 59 on the computer and from 16 to 25 on the phone.

Screenshots showing noticeable improvement in framerates in both computer and mobile views

Texture optimisation

Each of the objects in the room was reconfigured by assigning their textures with an appropriate texture map. The frame rate on the computer increased marginally to 60fps and the mobile view to 29.

Screenshots showing improvements on the computer and mobile phone

I made a minor modification by removing the environment reflections, which made a significant impact by reducing the number of setpass calls to 12 and the number of shadow casters to 0.

Script modification

The built-in performance profiler was still indicating that CPU usage was being impacted by something in the scripts. I moved all the physics based code in the player holdpiece and headControl scripts into fixed update functions which seemed to make for smoother gameplay, but did not have a big impact on the frame rate. A linear interpolate function (Lerp) was also included which had a visible positive impact on the smoothness of the profiler graphing. While still not reaching 60fps, it is evident that the game was becoming more optimised and closer to its goal reaching 42fps, but dropping down to 35 at times. The image shows 38fps.

Mobile view with improved but less than optimal framerate

Other enhancements

In an attempt to reduce the frame rate even further I made a few additional enhancements to the lightmapping settings, such as changing the lightmapper to progressive and adjusting the lightmap resolution. This had a minor effect on the frame rate pushing it up slightly.

Conclusion

While many optimisations were made to the Tic Tac Toe game, it remained a challenge to increase the frame rate to 60fps on an old mobile phone. I would have removed some of the graphic elements and exchanged a number of static objects for even lower poly models than were provided if I was going to release this game to a real target audience. This experience has made it clear that collectively every successive improvement, even if minor, has a corresponding successive performance improvement. And this takes time, effort and skill.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade