Search Unity

Possible Optimization for Rift

Discussion in 'AR/VR (XR) Discussion' started by Todd-Wasson, Apr 9, 2015.

  1. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    I figured out a way to get a big increase in FPS with the Rift which in my case is finally enough to peg my scene at 75 fps without getting the drops to 37. This will only help you if you're slaving the OVRCameraRig to another object with a camera on it like I do with the purpose of activating/deactivating the OVRCameraRig depending on whether or not the Rift is detected. In effect I have had the OVRCameraRig and one other camera active anytime the Rift is running. If you're not doing that and only have one camera active at a time, then disregard this post.

    That parent camera still affects rendering performance significantly which was not something I was expecting to happen. By adding a short script to turn the parent camera component off when the Rift is detected, I got nearly a 50% increase in frame rate. In my case the parent camera object (a regular camera, not a Rift cam) is part of a larger DoNotDestroyObject in which case changing scenes reactivates the camera component on that object. So I just do a quick check in FixedUpdate in a script attached to that object to make sure it stays turned off. It's not the most efficient way, but it works for now. I'm now able to run the scene at an acceptable frame rate by tweaking the tree LOD's a bit.

    Frame rate test results below. This is a scene with a lot of SpeedTree trees, mostly at a distance at which they're billboarded:

    Parent camera object active (extra camera): fps ~73 batches 1220 saved by batching 8700
    Parent camera object not active (no extra camera): fps ~107 batches 903 saved by batching 6850

    It appears that the existence of an active parent camera triggers a lot of possibly unneccessary processing. Maybe this would be a no-brainer for you folks, but to my thought process it wasn't an obvious thing to do. I would have thought since that camera component is not really being used for rendering that it would have no effect. In desperation I tried turning it off and it worked. I hope this helps someone else. :)