This guide covers how to implement compositor layers in your Unreal application. For additional information, see Compositor Layers.
Overview
In Unreal, compositor layers are implemented through the Stereo Layer API. Note that the Stereo Layer API is only supported for Oculus Headsets on Unreal versions 4.13 and later.
By default, compositor layers are always displayed on top of all other objects in the scene. You may set compositor layers to respect depth, causing them to be occluded by scene elements that are closer to the camera, by enabling Supports Depth. If you are using multiple layers, use the Priority setting to control the depth order in which the layers will be displayed, with lower values indicating greater priority (e.g., 0 is before 1).
Note that enabling Supports Depth may affect performance, so use it with caution and be sure to assess its impact.
Samples
To see examples of compositor layers in Unreal, check out the following:
Layer Sample for a basic illustration of using UMG on quad layers and cylinder layers.
Scene Sample for how to use compositor layers for a main menu and with passthrough.
Phanto for use of a compositor layer as a game round pop-up.
Creating a Compositor Layer
To create a compositor layer:
Create an Actor and add it to the level.
Select the Actor, select Add Component, and choose Stereo Layer.
Under the Stereo Layer options, set Stereo Layer Type to Quad Layer, Cylinder Layer, or Equirect Layer.
Set Stereo Layer Type to Face Locked, Torso Locked, or World Locked.
Set the overlay dimensions in world units in Quad Stereo Layer Properties or Cylinder Stereo Layer Properties.
Select Supports Depth in Stereo Layer to set your compositor layer to not always appear on top of other scene geometry. Note that this may affect performance.
Set Texture to the texture that should be rendered as a compositor layer. Set Quad Size or Stereo Layer Shape values as appropriate to adjust the size of your compositor layer.
To connect the compositor layer to a UMG UI widget:
Create a Widget Blueprint and modify it to include your desired UI elements.
On the same Actor that contains the Stereo Layer, select Add Component, and choose Widget.
In order to preserve user expectations, align the Widget to your already-created Stereo Layer by adjusting Widget Draw Size and Pivot to match the bounds of the Stereo Layer’s Quad Size.
Disable Render in Main Pass for the widget. It will be rendered in-scene via the Stereo Layer component.
Add logic like the following Blueprint, which updates the Stereo Layer with the texture of the widget, to your Actor containing the Widget and Stereo Layer components:
You may add up to 16 compositor layers to Meta Quest applications. Any additional layers beyond this limit will not be rendered.
Layers Sample
The LayerSample, available from our Unreal GitHub repository, illustrates the use of VR Compositor Layers to display a UMG UI. For more information, see Unreal Samples.