Search Unity

Portals Rendering in VR (Unity / Oculus)

Discussion in 'VR' started by Exctazy, Jan 16, 2020.

  1. Exctazy

    Exctazy

    Joined:
    Oct 24, 2017
    Posts:
    9
    Hello everyone, i'm working on a game that need the player to be able to go through different portals. I want the portals to render the otherside. I found the exact tutorial that i needed from Brackey's channel :


    But because i'm working on VR, his project is not enterily working. The problem is that the view in the portals have distortion. I think it's because i'm only using the Center eye of the OVRCameraRig, and i'm not using the Left and Right eyes, neither using a render texture on theirself. But when i tried it didn't worked. When i try to put several OVRCameraRig in the scene, my OVRPlayerController stop working (can't move my hand nor move myself).

    I dont know where to search neither where to begin to solve that problem.

    Thanks in advance for your help.
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I worked hard last year to find a portal solution for VR that actually worked, but without much success. I ended up writing my own based on overlapping the geometry and clipping the rendering with a custom shader, and this mostly works, but there's a brief flash when transitioning, and the framerate drops whenever one of these portals is in view.

    If somebody comes up with a solid portal solution for VR that performs well, they will make a fortune. (Or at least, I will buy it!)
     
  3. Exctazy

    Exctazy

    Joined:
    Oct 24, 2017
    Posts:
    9
    Would you mind sharing a bit of your work ? So maybe each of us can like customize the solution and maybe find a workout?
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I really don't think the approach I used is the right approach. In addition to the performance problems, it places big constraints on how your level is laid out (all geometry for the different spaces has to overlap, with a custom material for each one... trust me, it's a PITA).
     
  5. Exctazy

    Exctazy

    Joined:
    Oct 24, 2017
    Posts:
    9
    Alright, i will continue to do some search by my side. :/
     
  6. avandenberg

    avandenberg

    Joined:
    Nov 22, 2018
    Posts:
    23
    Did you manage to figure this out in the end? I'm trying to do something similar but I need to get a mirror in VR using Unity's XR plugin... Been searching for a while and so far no luck :/
     
  7. diegodaly

    diegodaly

    Joined:
    May 25, 2017
    Posts:
    7
    Anyone has figured this out yet?
     
  8. davesmeathers

    davesmeathers

    Joined:
    Aug 18, 2015
    Posts:
    7
    In the Room VR we used the same solution as JoeStrout: geometry on one side of a portal would use an "inside portal" shader, and geometry on the outside would use an "outside portal" shader. In the fragment shader we do a simple test to see if you're looking through the portal and clip() the geometry based on the test. This was just about fast enough to run on Quest.

    I haven't seen Brackeys tutorial but I would imagine it's a similar technique to the way we do portals in the non vr room games, which you can read about here: https://tomhulton.blogspot.com/2015/08/portal-rendering-with-offscreen-render.html

    To make this work in VR you could set up two additional cameras (left eye and right eye), rather than just one, to render the portal view. In the fragment shader for the portal surface you need to select the correct texture for the current eye using stereoTargetEyeIndex. I think I made a working prototype of this (it was a while ago) but it's too slow for mobile VR.
     
    JoeStrout likes this.