Category: Samsung Gear VR

Unity Debug Diaries: Camera Glitch in Unity VR

I have been doing a bunch of VR work lately and working with the Gear VR in particular. The Gear is actually a nice piece of kit and I can’t wait to get my hands on the Oculus Go coming out… soon. As of this post, the Gear VR has the largest market penetration of any VR headset. One bug that I encountered that was tricky to nail down, was an optical glitch when moving from one part of my app to the next. It looks like an uninitialized RenderTexture, different every time and with glitchy artifacts everywhere.

Turns out the culprit was render scale, now known as XRSettings.eyeTextureResolutionScale. ETRS (because I’m not typing it out every time) is great for getting “free” anti-aliasing on everything in your scene. It basically renders at whatever ETRS is set to (eg:1.0, 1.2) and then downscales to 1 for the final blit. Since its a downscale (bilinear I think), its best never to exceed 1.5 or things will start to look crunchy. If you just want to downscale, use XRSettings.renderViewportScale, which is way cheaper than ETRS. It can only accept values from 0 to 1, hence downscale. By doing this, you would trade visual fidelity for performance.

Back to the issue at hand, changing eyeTextureResolutionScale at runtime will cause a new texture set to be made for each camera, and those textures are uninitialized. That means that it has been allocated space in memory, but whatever was occupying that memory is still there. This creates the weird memory artifacts that you see for…




Unity Debug Diaries

Linear & Gamma Color Space in Unity & VR

Color space will come up sooner or later in your journey through game development. Unity has many great resources about this topic so it’s really futile for me to try and do it better. What I will do is give you the synopsis. Gamma is the old way and Linear is new. Use linear colorspace where ever you can. Its supported by most new GPUs and screens. On mobile, its supported on OpenGL ES 3+. The catch is, as of the time of this doc, mobile VR and especially, the GearVR. Turns out that there is a known issue, found on this Oculus thread, with the Qualcomm divers on Android. So Oculus, both in person and on forum encourage you to use Gamma for GearVR and Go.

That’s not all though. If you are like me and you are switching branches in GIT often, the Unity color space setting sometimes does not stick. This was especially evident in a recent project where we upgraded to 2017. In Unity 5, the color space setting had been changed a couple of times but what we were seeing as linear was not actually correct. When we did the upgrade, the color space was still strange until we toggled the setting. So if your color looks weird, toggle that setting first before you do a major overhaul.