Portals Rendering in VR (Unity / Oculus)

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.

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!)

Would you mind sharing a bit of your work ? So maybe each of us can like customize the solution and maybe find a workout?

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).

Alright, i will continue to do some search by my side. :confused:

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 :confused:

Anyone has figured this out yet?

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: Tom's Programming Blog: Portal Rendering with Offscreen Render Targets

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.

1 Like