Wednesday, September 3, 2014

Titans of Space has been ported to Samsung GearVR

To me, Oculus and Samsung's partnership in bringing the GearVR into existence is pivotal in the rebirth of VR, especially when it comes to going mainstream, and I couldn't be more proud to be a tiny part of it as an early developer.

I thought I would go into detail of some of the challenges I faced while porting to the GearVR.  Since I did not create something from the ground up for mobile, and instead started with something that many are already familiar with, it was quite an undertaking to port the experience to a mobile device while still retaining the essence of the experience.  I had never touched an Android device beforehand, so it was all new. But, you know what they say about a deadline and a project!

While mobile devices today are getting more powerful by leaps and bounds, I quickly learned that porting something originally made for the PC to a mobile device and still have it run at 60 FPS was not an easy task. A lot of game systems required a rewrite, which I basically was going to do anyway so this was simply great motivation to get started.   It's just amazing to me that Unity can build games for a mobile phone using pretty much the same project that I've been using to build for PC's. To get things running fast though, Oculus provided a lot of helpful performance tips for the early developers. I ending up having to do several things:

----

1) Drop the vertex count way down. I started with 4.5 million vertices (across both eyes) and brought it down to 100K total (50K per eye). Had Carmack not explicitly said to target 50K per eye, I honestly never would have taken such a strict limitation seriously, but it really helped.  Most of the 4.5 million was in the cockpit detailing, the planets and stars, and the individual stars in the background. In Titans of Space for DK1, there are nearly 200K vertices used for rendering the background stars. This made them look pretty clean especially when zooming in, but definitely not an option for mobile. I stuck a custom LOD system on the planets and stars and tuned it the best I could to use the minimum number of vertices to give the appearance of a sphere at varying sizes and distances.

2) No more layered cameras. Before this, my usual approach was to render the cockpit on top of the "external" view of planets and space etc. That approach made it extremely easy to keep the player at the origin (to avoid jittery geometry), easy to keep the player at 1:1 scale (to avoid near plane clipping while also needing to have giant far clip planes for the planets and stars), and easy to decouple the ICD of each camera layer so that the player can feel like he's normal size but the surrounding space can feel huge even if it isn't huge within Unity's coordinate system.

 With those conveniences taken away, I redesigned it all to work with a single camera setup. This required reworking how the big stars are renderered at distance, it required implementing a floating origin, it required turning the individual stars into an actual pre-rendered skybox. Fortunately skyboxes finally work in VR as of Unity 4.5+ -- I just had to set up my own skybox rendering system to get a high quality cubemap (4K on a side), with real stars and milky way background lined up perfectly etc.

3) Pay attention to texture limits. No more 8K textures (which were only occasionally helpful anyway), and I had to be careful not to use too many uncompressed textures. Uncompressed textures are great for closeup detail with the zoom feature, and for normal maps that don't pop in and out, but they eat up a lot of storage space and memory, which are somewhat limited on a mobile device. I had to choose more carefully which textures to leave uncompressed.

4) Reduce draw calls down to ~100 or lower at any one time.  In Unity, things that share materials and don't move (static) can be batched, but there's not a whole lot that can be made static in Titans of Space now. The cockpit and everything in it used to be static and thus was very batchable, but not anymore due to not using layered cameras.  To make things worse, dynamic batching was broken for me on the mobile device for a few Unity versions and/or mobile SDK versions, and that forced me to be even more aggressive with this at the time.  I mainly addressed this by simplifying the cockpit and removing the debris field that surrounds the player.

5) Make shaders more mobile friendly.  There were a few nice-to-have features that I decided weren't worth the GPU cost, like having the limb of a gas giant ever so slightly translucent.  There's no point in having a giant, uh... gas giant be rendered on top of everything else as a transparent object -- the resulting overdraw hits fill-rate limits very easily so that had to go.  Planets like Earth also have a lot of overdraw. In the DK2 version, Earth has clouds that float above the surface, but the GearVR version just has the clouds combined with the surface texture.  The base of the cockpit is no longer translucent.  Lots of little compromises like that.

6) Figure out how to use one project to support both DK2 and GearVR. The Titans of Space project is about 5 GB in size and it's a huge pain to switch back and forth between Standalone PC and Android platforms, but I wanted to keep it all in one project as most of the changes I make for one platform apply to the other. However, there are a ton of details that differ, such as the level of detail in the cockpit, the nicer looking Earth vs the mobile-friendly Earth, certain options, etc.

I've kept a checklist of things to do every time I switch platforms, and I've automated other things via a central "is this a mobile build or not" checkbox and scripting defines.   There are some things I would do differently with the project knowing what I know now -- like making more use of prefabs to swap in and out depending on the platform rather than just activating/deactivating parts of the scene hierarchy.

In any case, the end result is, what you see on DK2 is what you see on GearVR, with the exception of a few changes to the cockpit and other easy-to-miss features that don't significantly impact the experience.

----

I learned a lot from the Oculus/Samsung partnership. Thanks to their combined wizardry, I have great hopes for compelling and rock-solid VR experiences on a mere mobile device. It's been both fun and maddening to watch /r/oculus speculate on the various rumors that had been swirling around. I have zero doubt that a new mainstream household activity has just come into being: taking the GearVR over to the couch to relax in VR. Also, being able to walk over to a family member (with device in hand) and say "hey check this [entirely other world] out" is cool too. :)

Sunday, August 17, 2014

New things

Titans of Space v1.52 with DK2 support has been released, and details + a download link can be found at  www.TitansOfSpaceVR.com.   Thanks to the wonderful VR community, I've received a few pages worth of feedback already, so expect further updates and improvements in the coming weeks.

I also wanted to share a link to KentBye's Voices of VR Podcast, where I explain why there hasn't been a new Rift Demo Round-up for a month, among other things.  :)



Monday, July 28, 2014

How to launch DK2 Unity demos

Since the "Direct HMD Access from Apps" Rift display mode does not seem to be working 100% yet, I've had to fiddle around quite a bit to figure out how to launch demos properly.

UPDATE:  For demos built with SDK 0.4.1 or newer, this is all *less* of a problem, but the below checklist is a great fallback.   There are still quite a few demos that do things differently, so I would like to recommend the "Unofficial VR Game Manager/Launcher by Bilago", which can be found here.  It can be a great help to experiment with what makes a demo tick, and then remember those settings for next time.

So after some trial and error, below is the checklist I go by now.



Note that this checklist assumes the following:
  1. You are using Windows 8 (though it may apply to other Windows versions),
  2. The Unity demo you are trying to run was built with DirectX11 turned off,
  3. You're using a single monitor + your DK2 (known issue that multi-monitor config results in judder).



1. Rift Display Mode: "Extended Desktop to the HMD" (via Oculus Runtime in your system tray)


2. Turn your DK2 *ON*.

3. Windows Desktop Mode: "Extend" (via "Second Screen" sidebar via Windows Key + P)





4. Main monitor: Primary, i.e. "This is your main display" (via Screen Resolution window, by right clicking on an empty area of your desktop)


5. DK2 monitor: Not primary, Landscape orientation.  (Most users with a simple monitor set up like mine will need to use Landscape, but others have reported needing to use Portrait or Landscape (Flipped), etc.  Whatever works for you -- the point is to feel free to change Orientation.)  Make sure the Rift display in this window is light blue like your main monitor.  If it's small and dark, it usually means you didn't set your desktop to "Extend".   If you did set your desktop to Extend and you're still seeing this, switch back to "PC Screen Only" and then back to "Extend", and then it should pick it up.



6. To run a Unity demo, use the DirectToRift executable that hopefully came with the demo in question.  The demo should then pop right up onto the DK2.   If you get any judder, get out of the demo, turn the Rift off and back on, then try again.

If anyone finds that this checklist doesn't hold true in all cases, please let me know.


Sunday, July 20, 2014

Rift Demo Round-up: Jul 6th - Jul 19th

Below is a list of 27+ free native VR demos, all with playable downloads right now, that have come out of the community in the last 2 weeks - either as new demos or significant updates to older demos.

These demos come in various shapes and sizes, some more polished than others, and many with excellent ideas.   I am sure the developers would love to hear your thoughts, even if just a one-liner to let them know someone is playing them.

Here we go, in alphabetical order:

New Demos:


Updated Demos:

(includes new demos that have been updated already)
(Green denotes an epic update, does not apply to new demos)


Drash's Top 5:

(in no particular order, only applies to new demos)



Please note that the Top 5 list is merely my own personal opinion, and only reflects how I feel about an overall experience after playing it.  I am not able to play 100% of these demos, so please take this list with a grain of salt.   Lastly, there are more than 5 awesome demos in this list -- it was a tough decision to pick only 5!

As always, if I missed any, please let me know.


Sunday, July 6, 2014

Rift Demo Round-up: Jun 22nd - Jul 5th

Below is a list of 34+ free native VR demos (57+ if you count the 24 small demos by Jose), all with playable downloads right now, that have come out of the community in the last 2 weeks - either as new demos or significant updates to older demos.

These demos come in various shapes and sizes, some more polished than others, and many with excellent ideas.   I am sure the developers would love to hear your thoughts, even if just a one-liner to let them know someone is playing them.

Here we go, in reverse alphabetical order:

New Demos:


Updated Demos:

(includes new demos that have been updated already)
(Green denotes an epic update, does not apply to new demos)


Drash's Top 5:

(in no particular order, only applies to new demos)



Please note that the Top 5 list is merely my own personal opinion, and only reflects how I feel about an overall experience after playing it.  I am not able to play 100% of these demos, so please take this list with a grain of salt.   Lastly, there are more than 5 awesome demos in this list -- it was a tough decision to pick only 5!

As always, if I missed any, please let me know.


Sunday, June 22, 2014

Rift Demo Round-up: Jun 8th - Jun 21st

Below is a list of 32+ free native VR demos, all with playable downloads right now, that have come out of the community in the last 2 weeks - either as new demos or significant updates to older demos.

These demos come in various shapes and sizes, some more polished than others, and many with excellent ideas.   I am sure the developers would love to hear your thoughts, even if just a one-liner to let them know someone is playing them.

Here we go, in alphabetical order:

New Demos:


Updated Demos (includes new demos that have been updated already):


Drash's Top 5 (in no particular order, only applies to new demos):



Please note that the Top 5 list is merely my own personal opinion, and only reflects how I feel about an overall experience after playing it.  I am not able to play 100% of these demos, so please take this list with a grain of salt.   Lastly, there are more than 5 awesome demos in this list -- it was a tough decision to pick only 5!

As always, if I missed any, please let me know.


Sunday, June 8, 2014

Rift Demo Round-up: May 25th - Jun 7th

Below is a list of 50+ free native VR demos, all with playable downloads right now, that have come out of the community in the last 2 weeks - either as new demos or significant updates to older demos.

These demos come in various shapes and sizes, some more polished than others, and many with excellent ideas.   I am sure the developers would love to hear your thoughts, even if just a one-liner to let them know someone is playing them.

Here we go, in reverse alphabetical order:

New Demos:


Updated Demos (includes new demos that have been updated already):


Drash's Top 5 (in no particular order, only applies to new demos):



Please note that the Top 5 list is merely my own personal opinion, and only reflects how I feel about an overall experience after playing it. I am not able to play 100% of these demos, so please take this list with a grain of salt.  Lastly, there are a lot more than 5 awesome demos in this list -- it was a tough decision to pick only 5!

As always, if I missed any, please let me know.