Saturday, September 26, 2015

Big update for Titans of Space on Gear VR!

A new version of Titans of Space is now on Oculus Store for the Gear VR:

No more compromises: full stereoscopic 3D is back, running at a smooth 60 FPS!

For those that weren't aware, since its release Titans of Space on Gear VR has always been rendered monoscopically, so both eyes are effectively seeing the same thing.   Basically an interactive 360 video with headtracking.   I did add an optional hybrid 2D/3D mode where only the cockpit could be shown in 3D, but performance of this was borderline, and subject to a bit of choppiness and tearing here and there.  Not ideal, and not something I would be excited to show to anyone, and I know many users felt the same!

So what's changed?  Why is Titans of Space now suddenly able to pull off full stereo 3D at a solid 60 FPS?  Several factors came into play:

  1. Oculus has been doing a stellar job with their Mobile SDK.  They, in combination with Unity, have introduced optimizations that have increased the time available for the CPU to do its work.
  2. Although Titans of Space Gear VR is now using Unity 5, I'm not enabling the checkbox for native VR functionality that comes with Unity (yet).  I'm using the Mobile SDK 0.6.1 that is intended for Unity 4.... with Unity 5.   Seems to have worked out great, and hopefully doesn't backfire later on.  Reason for doing this is because at least up through Unity 5.2.0p1, the native VR functionality still seemed to be underperforming, but it's possible that might have changed recently.  I also couldn't stay on Unity 4.6.x because I use a single Unity 5 project for both PC and mobile versions of Titans of Space.
  3. When the Gear VR innovator edition was first released, Samsung and/or Oculus had put strict limits on the CPU and GPU levels that a developer could choose to target.   For example, Titans of Space was running at CPU1/GPU3.  Max level for each is currently 3.   So GPU running at full speed, CPU running at reduced speed.   At the time, CPU2/GPU3 and CPU3/CPU3 were not valid combinations and trying to set those levels would be considered invalid and thus introduce chaos into the CPU/GPU clock speeds as it reverts to default throttling logic set up by Samsung for normal mobile phone usage.   Sometime in the last few months, those limits were removed.
  4. When Gear VR innovator edition was first released, changing the CPU/GPU levels at runtime resulted in a one-frame flicker as it resets the VR rendering state, which means that the levels had to be selected at load time (or during a fade out, etc), and remain that way.   Sometime in the last few months, this also changed -- the levels could be changed at will without any discernible impact on what the player sees.  This gives rise to the ability to dynamically change the levels at runtime based on what's going on in the app.
Monoscopic rendering is still an option but it's not the default -- this uses the least amount of CPU. And, to address the persistent performance issue for those with the Snapdragon Note 4 & Android 5.0.1 / 5.1, I raised the CPU level further for that configuration to compensate.

The bottom line is, a tiny bit more app optimization + SDK improvements + Unity updates + higher CPU clock level limits was what I needed to make 60 FPS stereo 3D work.   Huge sigh of relief on my part!   


...Until I remembered that higher CPU levels means the device warms up faster!   Which isn't great considering Titans of Space encourages users to take their time to look around and read about things.  Worse still, the tour is linear in nature (well, it has branches depending on the tour length you choose, but it's still basically linear).   So if the device happens to overheat in the middle of the tour, users may not bother trying to catch the rest of it once the device cools down.  Those that have stayed for the whole tour know that there's more than just the Solar System, and many users tend to think it's almost over when they get to Pluto.

My solution to this was to simply remember where the player was last time and give them the option to resume the tour.   It's an obvious feature that should have been implemented a long time ago (even without thermal issues), except for the fact that it's more complicated than it looks.   The tour involves objects moving around, objects changing scale, music changes, flight paths, info text, tweens and animations, and the state of tour at stop Z depends on everything that happened before that between tour stops A through Z.   I ended up having the app fade out and automatically (and very quickly) proceed from the beginning of the tour to where the user last left off.  A number of race conditions and other issues were exposed in doing this, and those were all very interesting to troubleshoot and fix. :-)

Users also have the option to toggle monoscopic rendering (to go back to the way it was before the update) which will be more efficient with CPU usage.


Anyway, beyond that, Titans of Space for Gear VR now has parity with the recent v1.8 update for the desktop version -- updates for Pluto, Ceres, info text for many planets and moons, a "smooth movement" option, and easier to read text.

Enjoy!