[RELEASED] Portals for VR

Hi,

I’ve spent the better part of my holidays and free time creating and optimizing a set of shaders and scripts to get Portals working in VR. Optimized in a way that it can run smoothly on Oculus Quest 2.

It’s built for URP and Single Pass Multiview VR compatible.
Portals can be traversed without a single glitch in VR through walls.

Fully working scene preview, easily modify the Shadergraph materials.

Shaders supports animated transparency and animated refraction for some really cool effects.

Alpha maps baked into your albedo textures can be used to open up the textured portals as you walk towards them.

Portals are recursive, meaning you can see a portal through another portal through another portal and so on.

Lots of care and attention has been given for portals to be seamless in VR, standing in the center of a portal with 1 eye on the left side and the other on the right works perfectly even with large near clipping values on your camera.

Portals can be completely flat planes occupying the same space as a wall and still have no clipping issues.

Many options to tweak performance. Change the resolution, modify the layermask, limit AA and Blend gradually to a static color over a set distance.

Includes a system for objects to traverse through the portals, tested with VRIF and easy to integrate with other Interaction frameworks and character controllers.

The video shows some assets (like the hands) from the excellent VR interaction framework asset. These are not included. However a simple VR demo cameraController and portalgun example is included to get you started.

Currently tested in VR on:

  • Oculus (Meta) Quest 1 and 2 (Desktop and on-device)
  • Valve Index / Vive - SteamVR
  • Oculus XR set to Multiview
  • OpenXR set to SinglePass Instanced

For a detailed compatibility list and instructions please read the documentation (see link below)

Documentation here
Youtube channel with demo material
An example APK for Quest 2

8481677--1127738--Recording 2022-10-01 at 12.16.19.gif

1 Like

Does this support Single Pass Instanced in VR? I am looking for a shader that can handle refractions in SPI.

Oh I see this is not compatible with the built in render pipeline.

Hi Tom, looking at the DemoScene for AR, and there’s a shader in there that isn’t in the documentation. I’m far from a rendering expert so was wondering if you could quickly explain what the DepthMaskForAR material and associated shader is for? I see it’s applied to a large cube that sits on the floor level (or maybe -0.5 below) as well as on one of the portals I believe. Thank you for any insight and for this very cool asset.

Hi Verne,

have a look at the result of that scene in the video above.

the depth mask will mask out (make invisible) all geometry that is behind it. in the AR demo scene this means the large sphere with the “outer space” area is not visible below you when you’re standing on top of it. making the AR camera layer that is in the background visible so you can see the real world.

the depth mask inside the portal in the ship does the same thing, make sure you can see the real world instead of more space background.

hope the video makes it a bit more clear.
Thanks for the support!

Best regards
Tom

1 Like

Thank you, Tom! One more quick question for you, as I’m now trying to achieve a certain effect which perhaps this asset isn’t designed for, but just wanted to ask… Is there any way to “tone down” the portal zoom effect? What I mean is, I’d like the avatar in the attached pictures to appear large in the portal frame regardless of where the user camera rig is located relative to the portal. Like a normal window, basically. However even if I place the avatar super close to his respective portal, there’s still a dramatic zoom effect as I move my camera rig towards/away from its portal, almost like viewing through a super wide lens even when <1m from the portal. In summary, just wondering if your asset provides any control over this, or if I’m better off using stencil shaders or something to achieve this effect? :slight_smile: Thanks!


I don’t really get what you mean and the pictures don’t make it much clearer. If they show what I think they’re showing its just completely wrong and there is probably something not set up correctly.

The idea of the portals is that they act as a window in another world. there should be no zoom effect. maybe you’re using a spectator camera and it’s not tagged correctly so the perspective is incorrect?

best to send me an email so we can schedule a quick screenshare, probably something small.

1 Like