VR Stereo Layers

Choose your OS:

Virtual Reality (VR) Stereo Layers allow you to send a separate Texture to the VR Head Mounted Display (HMD) and have it re-projected in a separate rendering pass than the rest of the project. This is extremely useful for User Interface (UI) elements that you want to attach to the HMD but not be affected by post processing or anti-aliasing. In the following document, we will go over how you set up and use Stereo Layers across all VR Platforms that are supported.

Supported Platforms

VR Stereo Layers are supported on all VR platforms that Unreal Engine 4 (UE4) supports which include:

Platform Differences

Since the native VR platforms expose different features, the behavior of Stereo Layers can vary between platforms. This section lists most of them by the implementation.

  • World Locked: The layer position is in game world coordinates.

  • Tracker Locked: The layer position is relative to the real-world tracking space around the player

  • Face Locked: The layer stays in the same place in the HMD view regardless of position or rotation.

Another way to view the position types is by which aspects of the player position and rotation are taken into account when calculating the layer position relative to the view point:

Position Type

World location

Head Position

Head Rotation

World Locked

Yes

Yes

Yes

Tracker Locked

No

Yes

Yes

Face Locked

No

No

No

Steam VR

  • Only supports the Quad stereo layer shape.

  • Does not support the No Alpha flag to ignore the alpha channel. A workaround is to ensure that the texture does not have an alpha channel or is one-hundred percent opaque.

  • Performs backface culling on all layers, the layer is not visible from the reverse side.

  • When multiple layers have the same priority, layers are rendered by average distance from the HMD view.

  • Inside UE4 Textures used in Stereo Layers must be set to UserInterFace2D (RGBA) or they will not show up.

Oculus VR

  • Only supports the Quad stereo layer shape.

  • Supports the Support Depth flag on World and Tracker locked layers.

  • The Oculus plugin treats all Stereo Layers as intersecting the scene. This makes the layers behave as if the Support Depth flag is always set to true. To re-order which layers are rendered on top of other, you will need to physically move the layers you want to render first closer to the camera.

Gear VR

  • Implements all three shape types.

  • Supports the Support Depth flag on World and Tracker locked layers.

  • When multiple layers have the same priority, layers are rendered in a non-defined order. If you care about the ordering, use different priorities.

Other VR Platforms

Currently, all other VR platforms share a default layers implementation which will support the following.

  • Only supports the Quad stereo layer shape.

  • Mixing Face locked layer priorities with World and Tracker locked layers by setting the vr.StereoLayers.bMixLayerPriorities console variable is not supported.

  • When multiple layers have the same priority, layers are rendered in a non-defined order. If you care about the ordering, use different priorities.

Layer Shapes

Only layer shape supported on all platforms are quadrilinear layers. In addition to those Gear VR supports Cylinder and Cube layers.

Layer Draw Order

The Stereo Layers exist outside the game world and are layered based on the Priority setting on each layer. Layers with higher priority are rendered on top of layers of lower priority. Additionally, face locked layers are always rendered on top of World or Tracker locked layers regardless of priority. This is different from UE 4.16 and earlier, where all layer types were mixed together. To get the old behavior, set the vr.StereoLayers.bMixLayerPriorities console variable to 1.

Layers will always be rendered on top of the 3D scene, Oculus Rift and Gear VR support mixing World locked and Tracker locked layers with the scene however by toggling a Supports Depth flag. This flag is ignored on all other platforms.

Stereo Layer Setup

To use Stereo Layers with your VR Pawn, you will need to do the following.

  1. Open up the Pawn that you want to use Stereo Layers with and then go to the Viewport panel.

    Click for full image.

  2. Click on the Add Components button from the drop-down list that is displayed and search for the Stereo Layer Component.

    Click for full image.

  3. Now drag the Stereo Layer Component on top of the Pawn's camera to make it a child actor of the camera.

    VRSL_Pawn_Setup_03.png

  4. Select the Stereo Layer Component from the Components list and then in the Details Panel under the Transform section, set the X value of Location to 100 so that it is easy to see in VR.

    Click for full image.

  5. Over in the Details Panel, expand the Stereo Layer section.

    Click for full image.

  6. Inside of the Content Browser locate a Texture that you would want to display and click on it to select it. Then back in the Pawn Blueprint under the Stereo Layers section, press the small white triangle next to the Texture input to use that Texture the Stereo Layer should display.

    Click for full image.

  7. Next press the Play in VR button to launch your project in VR. When you put your HMD on you should see the Texture you specified in Texture input being displayed in front of you. The Texture should also follow your HMD precisely and as quickly as you can move your head around like in the video below.

    If the Texture you selected does not show up when your project is viewed in VR, make sure you are using the correct Texture Compressions settings. If you are unsure what those settings should be for the HMD you are using, please check out the Stereo Layers Texture Compression Settings section.

Stereo Layers Texture Compression Settings

Depending on which HMD you are using you will need to make adjustments to the Compression setting that is used for the Texture to be displayed. Below you will find more information about which Texture Compression settings are needed for Stereo Layers to display correctly on various HMDs.

Click for full image.

HMD Name

Required Texture Compression Settings

Oculus Rift

None

Gear VR

None

HTC Vive

UserInterFace2D (RGBA)

PSVR

None

Stereo Layer Properties Breakdown

Stereo Layers have some properties that affect the way in which it is rendered. The following table breaks down each one of these settings and its effect on the Stereo Layers.

VRSL_Prop_Breakdown_00.png

Setting Name

Description

Live Texture

True if the stereo layer texture needs to update itself every frame (scene capture, video, etc.).

Supports Depth

True if the stereo layer needs to support depth intersections with the scene geometry, if available on the platform.

No Alpha Channel

True if the texture should not use its own alpha channel (1.0 will be substituted).

Texture

Texture displayed on the stereo layer (if stereoscopic textures are supported on the platform, and more than one texture is provided, this will be the right eye).

Quad Preserve Texture Ratio

True if the quad should internally set its Y value based on the set texture's dimensions.

Stereo Layer Type

Specifies how and where the quad is rendered to the screen.

Stereo Layer Shape

Specifies which type of layer it is. Note that some shapes will be supported only on certain platforms!

Priority

Render priority among all stereo layers, higher priority render on top of lower priority.

Left Texture

Texture displayed on the stereo layer for left eye, if stereoscopic textures are supported on the platform.

Quad Size

Size of the rendered stereo layer quad.

UVRect

UV coordinates mapped to the quad face.

Cylinder Radius

Radial size of the rendered stereo layer cylinder.

Cylinder Overly Arc

Arc angle for the stereo layer cylinder.

Cylinder Height

Height of the stereo layer cylinder.