Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

VR Upcoming VR optimisations

Discussion in '5.4 Beta' started by JonDadley, Jan 12, 2016.

  1. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    In the 5.4.0b1 thread it was mentioned that future betas would include "VR Performance Optimization".

    Is there any word on what the VR optimizations are? And how big a performance impact we are likely to see? I have a VR project that could really benefit from some engine side optimizations so it'd be great to know what we can expect!
     
    EyePD likes this.
  2. robinb-u3d

    robinb-u3d

    Unity Technologies

    Joined:
    Jul 13, 2015
    Posts:
    20
    Hi Jon

    Currently when Unity performs a render from a VR enabled camera in Unity it will internally perform one set of culling and then in turn render the left eye and then the right eye. The optimizations we are working on internally at the moment move most of Unity over to performing only one rendering pass that will render to both eyes at the same time. This packs both eye targets into one double wide target and when it gets to Unity's render thread we will at the last possible moment double up the render call again binding appropriate matrices and setting up the viewport to render to the correct half of the double wide target for each eye.

    If you look at your current VR project in the Unity profiler you should see that on the Main Thread each camera ("Camera.Render") that is enabled for VR will generate two sets of "Drawing" markers one for each eye. The second of those markers should go away with the optimizations enabled so reducing the VR "Drawing" time by 50%. We are also seeing a large reduction in the time spent on the GfxWorker Render Thread as a result of this optimizations as well.

    Currently we are targeting Oculus Rift and PlayStation VR with this round of optimizations, we'll be looking into optimizations for GearVR a little further down the line.

    Hope this is of some use.

    Robin
     
    Kronnect, codestage, Elecman and 8 others like this.
  3. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    Thanks for the detailed post! That sounds fantastic and will be a huge benefit to my projects (the dual 'drawing' calls are the biggest perf impact for me). Really looking forward to seeing this feature come online :)
     
  4. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Are there any plan to support the Multi resolution rendering system from Nvidia? and their SLI system to render one eye per frame. It seems like that would fit good with the work you are doing using only one render pass for both eyes.
     
  5. Thomas-Pasieka

    Thomas-Pasieka

    Joined:
    Sep 19, 2005
    Posts:
    2,174
    This is excellent to hear @robinb-u3d . Any idea on when this is going to be available?
     
  6. yezzer

    yezzer

    Joined:
    Oct 30, 2009
    Posts:
    143
    What great news. Very promising indeed.
     
  7. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666

    Any support for Native Cardboard in the near future?
     
  8. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Are these performance optimizations designed in a way that will make it possible to also have them in 3rd party packages, like e.g. the SteamVR Unity Plugin?
     
  9. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    390
    Does it reduce the Draw Call to half?
     
  10. GUNAIR

    GUNAIR

    Joined:
    Aug 8, 2013
    Posts:
    4
    Are these the optimizations you meant - now in Beta 5.4.0B5:


    "VR: Optimized Single-Pass Stereo Rendering available in Player settings"

    Could somebody please try / compare it and share the results here ?
     
  11. Thomas-Pasieka

    Thomas-Pasieka

    Joined:
    Sep 19, 2005
    Posts:
    2,174
    I guess we don't get an answer to our questions....
     
  12. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
  13. sambickley

    sambickley

    Unity Technologies

    Joined:
    Jan 9, 2014
    Posts:
    250
    Hey all!

    Check out Joachim's part of the Vision Summit 2016 Keynote, starting from 41:26. But if you want the improvements to rendering summed up in one image:



    Yes, this was announced in the keynote video, above. No timescale given just yet, however.

    The double-wide work will only be available for integrated VR solutions, not plugin ones. As you've already noticed though, integrated support for Vive will be coming in the future.

    Currently, the number of draw calls on the render thread will remain the same, but have been heavily optimised which should reduce render thread overhead.

    Initial work is now available in 5.4.0b5, see "VR: Optimized Single-Pass Stereo Rendering available in Player settings" in the release notes, however 5.4.0b6 is the version that the above data was captured from. Work is continuing on this right now, and will see further improvements and optimisations throughout the 5.4 beta and release cycle.
     
    DevDuFF, mgooding, jashan and 3 others like this.
  14. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    325
    Hi Sam,

    What is the normal time frame for beta releases, how long until we can try b6 out? :)
     
  15. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    yes, I would love to know this as well, this is great news!
     
  16. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    Typically we've been seeing betas every 1 - 2 weeks so I'd imagine we'll have it pretty soon.

    By the way, big fan of Lunar Flight, your latest updates look great :)
     
  17. sambickley

    sambickley

    Unity Technologies

    Joined:
    Jan 9, 2014
    Posts:
    250
    As @JonDadley said, our beta release cycle means we usually have a new release every week, although this can sometimes take longer if we've encountered some issues that we deem too severe to allow the release to go live straight away.
     
  18. ScottF

    ScottF

    Vice President, Platforms

    Joined:
    Jul 31, 2013
    Posts:
    96
    You can expect Valve support added during the 5.4 Beta period but we don't have a specific date of which beta drop it will be added in. There are still a few logistics to work out to align updates to Valves existing asset store plugin to ensure a smooth transition.
     
    mgooding and jashan like this.
  19. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    That is very great news! As I am also developing for PlayStation VR, I cannot jump into 5.4 beta too early, anyways (unless some magic happens) but almost certainly will as soon as this is ready (primary platform ATM is HTC Vive, we expect PlayStation VR to be released after HTC Vive, so that's why we primarily focus on the later).

    I know I've been bugging you since the alphas ... but ... just to be sure: Will we keep the TrackedObject components when using the SteamVR plugin? Or even better: Could we finally have native VR support in general done with a component-based approach instead of (just) "checking Virtual Reality Supported"?

    A very significant part of Unity's awesomeness is in its component-based approach and especially for locally social VR games but also from a software-engineering perspective, adding "TrackedObject" and "HmdCamera" components to a camera that should be controlled by tracking and rendered to VR would be very much preferable to a checkbox in the player settings changing the behaviour of every camera (and having no way to disable built-in tracking, for example, to replace it with custom tracking ... or have a tracked camera render to a normal monitor instead of the HMD ... or have a camera tracked with a controller render to the social screen ... and so on ;-) ).

    Also, why was the functionality that tracked cameras base their tracking on zero changed (I missed that change because I wasn't using the native VR integration until recently)? If you really need a camera with an offset in position and or rotation, you can always parent it with an object that does this ... but there's quite a few cases where you'll want the camera to have some position / rotation when not in VR that should be zeroed when in VR.
     
  20. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    This optimization apply for google cardboard also?
     
  21. ScottF

    ScottF

    Vice President, Platforms

    Joined:
    Jul 31, 2013
    Posts:
    96
    At this time no these optimizations will not help with Cardboard when using their asset store plugin. We have just announced we plan to add official Cardboard support in the future but do not have a release date set. Keep an eye on the public Roadmap as it will be added soon.
     
    TechnicalArtist and SAOTA like this.
  22. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    I just quick tested the "Optimized Single-Pass Stereo Rendering" and saw some interesting speed-up. But then, it totally fails with the "Ceto Ocean system". The transparent part is only rendered on one eye as far as I can see...
     
  23. Alex-Lian

    Alex-Lian

    Guest

    Bug report # please?
     
  24. oscabrg

    oscabrg

    Joined:
    Jul 17, 2015
    Posts:
    21
    seems b6 got released with "Graphics: Graphics jobs can now be enabled"..
    I assume this means render loop jobs from slide past week..
    also this includes "double wide rendering also" from slide?
    i.e. we can achieve the 5.4+RL+DW perf from slide above?
     
  25. ScottF

    ScottF

    Vice President, Platforms

    Joined:
    Jul 31, 2013
    Posts:
    96
    Just to clear up how the slides map to actual editor settings:
    "Single-Pass Stereo Rendering" maps to the gains of "Double Wide Rendering"

    "Graphics Jobs (Experimental)" maps to Render Loop Jobs

    For the Jobs the actual improvement you see is effected by the number of cores a platform has. So for example you will not see this big of a gain on a mobile platform with 2 cores as you would on a PC or Console with 6-8 cores.
     
  26. oscabrg

    oscabrg

    Joined:
    Jul 17, 2015
    Posts:
    21
    thanks..
    graphics jobs works in all modern graphics APIs (i.e. OGL Core, D3D11/12 and Metal)?
     
  27. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Currently graphics jobs are only enabled on PC (Win/Mac/Linux) and console (PS4, XB1) build targets. What exactly kinds of jobs they do depends on the graphics API used:
    • DX12 is the only one right now that has "fully native" job support; that is the job threads directly create DX12 command buffers. PS4 and Metal should follow soon, but not quite ready yet. OpenGL will not, since it can't.
    • All other APIs (no matter which ones, so up from DX9 even) create "our own" command buffers from the job threads, with one "rendering thread" that actually executes the calls into the graphics API. So that thread pretty much stays the same as the render thread that was always there in Unity; the only difference is that rendering logic that was happening on the main thread before is now multi-threaded.
     
  28. ccsander

    ccsander

    Joined:
    May 17, 2013
    Posts:
    44
    I decided to give 5.4 beta a go to try out these optimizations. In my case I'm using layered left/right-eye VR cameras to achieve some per-eye effects on top of regular both-eye VR camera. layer 0 is both eye cam, and then I have layer 1 left and right cams that draw on top of both-eye cam. I'm finding if I turn on single pass stereo rendering it really screws up the left/right cams. The left/right cam rendering is skewed in a really odd way. Is it expected that left/right cams will no longer work if this is enabled? If not I can try to post a bug and testcase that shows this.

    On a positive note, overall CPU rendering overhead does seem to be reduced in 5.4 compared to 5.3. And DW rendering did seem to also give further performance gains. I'm not seeing as much gain as the slides show, but any improvement is welcome. I didn't show any gain with graphics jobs enabled, but I'm not running DX12 on the machine I tested with.

    Thanks
    ccs
     
    Todd-Wasson likes this.
  29. Justin-Wasilenko

    Justin-Wasilenko

    Joined:
    Mar 10, 2015
    Posts:
    103
    Sad to hear this isn't making it to the Gear VR right away, but also at least good to know and not to count on it.
     
  30. ccsander

    ccsander

    Joined:
    May 17, 2013
    Posts:
    44
    I decided to run and post some benchmarks on 5.4.0b7 and compare to 5.2.3p3 if anyone is interested. I posted over on Oculus forums. The results look similar what Unity is claiming, which is phenomenal. Note that if your application is GPU-bound, you will still be GPU-bound. These updates mostly help clear the CPU main thread for your own game logic.

    https://forums.oculus.com/viewtopic.php?f=37&t=30095&p=331893#p331893

    ccs
     
    Todd-Wasson, Aras and SAOTA like this.
  31. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Wow... I have to retest it. Had some glitches with the Ceto Ocean system (and no, I haven't put up a bug report... we're going to GDC and we're working on our game demo).
     
  32. joe1016zw

    joe1016zw

    Joined:
    Apr 11, 2015
    Posts:
    3
    It seems like that would fit good with the work you are doing using only one render pass for both eyes.



    .................................................................................
    www.casesam.co.uk
    Samsung Galaxy S7 case
     
    Last edited: Feb 25, 2016
  33. dougmuir

    dougmuir

    Joined:
    Nov 3, 2015
    Posts:
    2
    With the VR optimizations, will there be some way to render separate content for each eye (for example, stereo skyboxes)? For my use case, a shader uniform which indicated which eye was rendering would be sufficient (maybe even ideal).
     
  34. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    ccsander, thanks a lot for redoing your tests. I was hoping you'd do that.

    30% increase in speed from 5.2.3p3 (the version I'm currently on)? Wow. :D
     
  35. Kaspar-Daugaard

    Kaspar-Daugaard

    Unity Technologies

    Joined:
    Jan 3, 2011
    Posts:
    150
    Yes, there will be a shader uniform (unity_StereoEyeIndex) and you can create a camera that only renders to one eye.
     
  36. Justin-Wasilenko

    Justin-Wasilenko

    Joined:
    Mar 10, 2015
    Posts:
    103
    Has anyone done in recent testing with the latest Beta to benchmark the optimizations again? Specifically looking for any Gear VR related benchmarks.

    Haven't seen any other information aside from what was posted in this thread back in February.
     
  37. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,351
  38. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah been doing it since 2001 or something - rendering my rt to mesh grid for distortion, for lighting, for vignetting on the cheap, old trick. I don't think it actually will change desktop performance any. Mobile? most probably would gain at least half a millisec on some devices and it all counts!
     
  39. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Not quite they are displacing and distorting the scenes geometry so it renders with a barrel distortion aligned with the viewport. The article even goes into how simple meshes e.g. squares/cubes need to be subdivided or tessellated so they can be barrel distorted.

    I'm guessing that you would have to do this is a final pass after the shadows, lighting effects have been calculated. It would bump up mesh complexity and polycount quite a bit.
     
  40. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    @robinb-u3d Hey, Robin!

    Could you please confirm you're still not targeting GearVR in 5.4.0 (and current RC1)?

    Thanks!