Search Unity

Google Cardboard SDK Base Performance

Discussion in 'AR/VR (XR) Discussion' started by fffMalzbier, Apr 22, 2015.

  1. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    I got working on some demo applications for the Google Cardboard with the Google Cardboard SDK.
    My problem is the performance, vr does not feel good i you only have 20 fps.
    I use a Galaxy S4 and that should be able to draw the scene in 60 fps+.
    So i did make a test scene, completely empty with two setups for comparison.
    1.Cardboard sdk 32 - 43 fps
    2. 2 Cameras each half the screen 60 fps+;

    Looks like the Cardboard sdk is eating a lot of performance.
    What is your experience with the sdk and the resulting performance?
     
  2. 4ringz

    4ringz

    Joined:
    Apr 22, 2015
    Posts:
    13
    Using Cardboard and a Galaxy S6, I'll test this out soon and update. Interested to see results. Have you checked Profiler to see what's eating the performance? I'm assuming it's somewhere in their script packages.

    Edit:

    I made a preliminary, not-very-scientific test by throwing enough animated characters in my demo scene that the FPS came down below 60. Did one demo with the Cardboard rig, another with two cameras and no Cardboard:

    Android with Cardboard SDK: ~22-26fps
    Android without Cardboard SDK: ~23-27fps

    In Editor with Cardboard SDK: ~35-39fps
    In Editor without Cardboard SDK: ~33-35fps

    So I'm not seeing much of a performance hit here, if any.
     
    Last edited: Apr 22, 2015
  3. dolims

    dolims

    Joined:
    Sep 13, 2014
    Posts:
    61
    Try turning off the distortion correction (Cardboard.SDK.nativeDistortionCorrection = false, or clear the checkbox in the editor). What kind of frame rate does that yield?
     
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Without the nativeDistortionCorrection enabled i get 60 fps in all my scenes, (probably capped by refresh rate).

    Thats kind of dumm... Without the nativeDistortionCorrection the image has a strong Distortion.
    Kind of wired that the native plugin part is slowing it down so much.

    The question that come up are:
    Any way to fix the native plugin performance?
    Any way to run the effect as a image effect if the native plugin cant be fixed.
     
    Last edited: Apr 23, 2015
  5. dolims

    dolims

    Joined:
    Sep 13, 2014
    Posts:
    61
    The process of distortion correction is that the frame is first rendered into a texture with a wide-angle camera based on the viewer's FOV, and then the captured texture is rendered to the screen with a fragment shader that does the barrel distortion. This barrel distortion is done to counteract the pincushion distortion caused by the lenses. But full-screen fragment shaders are a bit costly on mobile devices, hence the performance loss. An image effect would do the same thing, just from within Unity. It is going to have about the same performance. I know efforts are being made to optimize this phase, and some people are trying other approaches like warping the geometry before rendering. And manufacturers continue to increase the graphics horsepower of the phones. Hopefully this will continue to get better.
     
  6. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    I would have guessed that the way to go over a native plugin is done to increase the performance of the process but if it does not , why did they go all the way to make a plugin, for something that could be done in unity itself.
     
  7. dolims

    dolims

    Joined:
    Sep 13, 2014
    Posts:
    61
    The Java SDK existed first. The Unity SDK was written on top of it, which saved a lot of time not having to reimplement all that it did. There's a lot going on in the Java SDK, like reading the device profile (the QR code, which affects the distortion parameters), handling the Android lifecycle events, integrating the gyro with bias filtering, handling the magnet trigger detection, and so on.
     
    fffMalzbier likes this.
  8. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    Any update?
     
  9. tachen

    tachen

    Joined:
    Jul 2, 2013
    Posts:
    9
  10. TKDHayk

    TKDHayk

    Joined:
    Dec 22, 2015
    Posts:
    130
    I just started using Carboard SDK so i'm not an expert. But it seems your'e comparing Cardboard SDK to your own stereoscopic setup. Cardboard SDK does more than stereoscopic display. It also needs to communicate with the gyro in the phone. Ive also tried using the durovis dive cardboard Plugin, which gives me better performance than cardboard SDK, and for some reason, a much better 3d effect. it may be worth checking out. let me know how it goes.
     
  11. crash664

    crash664

    Joined:
    Nov 22, 2012
    Posts:
    91
    I would like add an update to this issue. I also had very similar problems with Google Cardboard SDK. I had a somewhat complex (still simple enough for 60fps on an S6) scene, but it would always drop below 40fps on high res screens. If it didn't start on low framerate, it would quickly drop down once the phone heated up. I believe the culprit was googles rendering pipeline. The fill rate is what kills the performance on mobiles (or at least a large contributor.)

    I noticed Google just recently updated their cardboard site and I guess have updated the SDK (hard to tell, they don't have version releases available). So I downloaded it again, and reintegrated it into the same scene, and its now running at 60FPS on the S6 and holding steady.

    I assume they optimized their rendering pipeline. There's a good chance it'll get even better once Unity provides native support for their SDK (as they have for Oculus.)

    Hope this helps.
     
    TechnicalArtist likes this.
  12. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Have the same problem with my LG G4.
    Sadly it did not get better with the new SDK in my case.

    Do you use the native or the unity distortion correction?


    That would be indeed nice.
     
    Last edited: May 27, 2016
  13. crash664

    crash664

    Joined:
    Nov 22, 2012
    Posts:
    91
    I always use Unity distortion because native has never worked for me.