Composition layer transparency
Composition layers are drawn in order from most negative to most positive. A completely opaque area of a layer obscures any layers already drawn. To use alpha blending to allow lower layers to show through upper layers, you must manually configure camera, HDR, and Post-processing settings:
If you do not configure these settings correctly, the following types of layers might not render correctly:
- Underlays (layers with compositing order < 0)
- Transparent layers
- Projection Eye Rigs
Tip
Layers that are drawn underneath the main scene are sometimes called underlays and those that are drawn on top are sometimes called overlays. While the XR Composition Layers package doesn't use these terms explicitly, you might see them used in other XR literature. The main camera renders to the default scene layer, which always has an order of zero. Layers with a negative order are drawn underneath this layer and correspond to underlays. Layers with a positive order are drawn on top and correspond to overlays.
Note
Compositing in the Editor is emulated by shaders and can produce different results than the hardware compositor on an XR device. Always verify your layer setup on device.
Configure the camera for transparency
Unity renders the main camera to the default scene layer, which is drawn at order zero. By default, the camera background is completely opaque and obscures anything in layers with a negative order value. Set the camera background to transparent to allow layers with a negative order (underlays) to be seen.
To configure the main scene camera in an XR scene to render with a transparent background:
- Select the Camera GameObject in the scene Hierarchy (typically under XR Origin > Camera Offset).
- Adjust settings based on your render pipeline:
- Universal Render Pipeline (URP): In the Environment section, set Background Type to Solid Color.
- Built-In Render Pipeline: Set Clear Flags to Solid Color.
- Open the Background color picker and set A (Alpha) to
0
.
The same considerations apply when you render objects to a render texture and use that texture as the source of a composition layer. If you want layers underneath to be visible in the background areas, you must set the rendering camera's background color to be transparent.
Note
The cameras of the Projection Eye Rig use a transparent background by default.
Configure High Dynamic Range (HDR) settings
In order to store information to the alpha channel, the format of the render texture the scene is rendered to must contain an alpha channel. Some HDR rendering formats drop alpha channels for improved performance, but this can prevent layers underneath the default scene layer from being visible.
If you are using HDR, ensure your graphics Quality or Tier settings are set to allow the scene to be rendered with an alpha channel. Otherwise, you must disable HDR in the project settings.
Refer to HDR Tone mapping component for information about the Composition Layers tone mapping component.
Universal Render Pipeline (URP)
To change HDR settings when using URP:
Tip
By default, the PC_RP Asset configures URP settings for standalone builds (Windows, macOS, Linux), while the Mobile_RP Asset optimizes settings for Android builds. Ensure you modify all the correct RP Asset and Renderer for your target platform.
Locate your project's render pipeline assets. (By default these assets are stored in the
Assets/Settings
folder in the Project.)For each render pipeline asset:
- Select the asset to view its properties in the Inspector.
- In the Quality section, enable or disable HDR.
- If you enable HDR, set HDR Precision to 64 Bits.
Disabling the HDR setting in a render pipeline asset
Modifying the HDR Percision setting in a render pipeline asset
Note
If the Inspector doesn't show the HDR Precision setting, you must change the Advanced Properties preference to All Visible:
- Open the Unity Preferences window.
- Select the Graphics section.
- Set the Advanced Properties setting to All Visible.
Built-In Render Pipeline
To change HDR settings when using the Built-In Render Pipeline:
Open the Project Settings window.
Select the Graphics section.
Locate the Tier Settings for Built-In.
Click the Open Editor button to open the Tier Settings editor.
Change the HDR settings to the desired value for each tier that your project uses:
- Deselect the Use Defaults option.
- Enable or disable the Use HDR option.
- If you enable HDR, set HDR Mode to FP16.
FP16 mode in Graphics Tier Settings
Refer to Graphics settings for the version of Unity that you are using for more information about changing graphics settings.
Configure Post-processing settings
Post-processing effects in URP may discard alpha channel data. To preserve the composition layer alpha channel, enable Alpha Processing or disable Post-processing entirely.
To enable Alpha Processing:
Locate your project's render pipeline assets. (By default these assets are stored in the
Assets/Settings
folder in the project.)For each render pipeline asset:
- Expand the Post-processing section, if necessary.
- Enable Alpha processing.
Enabled Alpha Processing setting in a render pipeline asset
To disable Post-processing:
- Locate your project's Universal Renderer Data assets. (By default these assets are stored in the
Assets/Settings
folder in the project.) - For each renderer data asset, uncheck the Enabled option in the Post-processing section.
Post-processing disabled in a renderer data asset
Refer to Post-processing in URP for more information about Unity post-processing features.