This is a Unity project that demonstrates a dual-camera overlay rendering system.
It composites the rendered outputs of two Virtual Cameras with alpha blending, and outputs the final result to the Main Camera.
This project is useful for applications such as:
- multi-perspective VR/AR visualization
- mixed overlay UI + world rendering
- experimental multi-camera composition pipelines
This Unity project implements a dual-camera overlay system that composites two independent camera outputs into a single final view.
In this project, two environments (Env1 and Env2) are rendered separately by two Virtual Cameras.
Their outputs are then alpha-blended (transparent overlay composition) and displayed through the Main Camera.
This allows two different scenes (or layers) to be visually merged in real time.
↓ Alpha-blended composition (Dual Camera Overlay) ↓
The transparency of each camera layer can be adjusted dynamically, enabling smooth blending and flexible visualization of multiple camera perspectives.
This project was developed and tested with the following environment:
- Unity: 2022.3.28f1
- Render Pipeline: Built-in Render Pipeline
- XR Interaction Toolkit: 2.5.4
- XR Plugin Management: 4.5.4
- OpenXR Plugin: 1.10.0
- Stereo Rendering Mode: Multi Pass (Single Pass is NOT supported)
Follow the steps below to run the Dual Camera Overlay system.
Add the DualCameraCompositor component to your Main Camera.
Under the following hierarchy:
XR Origin (XR Rig) ├── Camera Offset │ ├── Main Camera │ ├── Virtual Camera 1 │ └── Virtual Camera 2
Create two standard Unity Camera objects:
Virtual Camera 1Virtual Camera 2
In the DualCameraCompositor inspector, assign:
- Virtual Camera Env 1 →
Virtual Camera 1 - Virtual Camera Env 2 →
Virtual Camera 2
Assign your scene objects to Unity Layers (e.g., Env 1 and Env 2), then set the Layer Masks:
- Layer Mask Camera Env 1
- Layer Mask Camera Env 2
This determines which objects are rendered by each Virtual Camera.
Press the Unity Play button to run the system.
The outputs of the two Virtual Cameras will be alpha-blended and displayed through the Main Camera.
This project allows you to configure which objects are rendered by each Virtual Camera using Unity Layers.
In the Dual Camera Compositor component, you can specify:
- Layer Mask Camera Env L: the Layer rendered by Virtual Camera 1 (Env 1)
- Layer Mask Camera Env R: the Layer rendered by Virtual Camera 2 (Env 2)
This makes it possible to separate two environments (or two object groups) into independent camera outputs.
In addition, you can control the transparency of each camera output individually:
- Alpha Env L: transparency of Env 1 output
- Alpha Env R: transparency of Env 2 output
By adjusting these alpha values, the two camera views can be blended smoothly in real time.
Below is a summary of the parameters available in the DualCameraCompositor component.
| Category | Parameter | Description |
|---|---|---|
| Virtual Cameras | Virtual Camera Env 1 | Camera used to render Env 1 (left layer). |
| Virtual Cameras | Virtual Camera Env 2 | Camera used to render Env 2 (right layer). |
| Layer Settings | Layer Mask Camera Env 1 | LayerMask used by Virtual Camera Env 1. Only objects in this layer will be rendered. |
| Layer Settings | Layer Mask Camera Env 2 | LayerMask used by Virtual Camera Env 2. Only objects in this layer will be rendered. |
| Main Camera Clipping Planes | Main Camera Near Clip | Near clipping plane value for the Main Camera. |
| Main Camera Clipping Planes | Main Camera Far Clip | Far clipping plane value for the Main Camera. |
| Alpha Settings | Alpha Env L | Alpha blending weight for Env 1 output. (0 = invisible, 1 = fully visible) |
| Alpha Settings | Alpha Env R | Alpha blending weight for Env 2 output. (0 = invisible, 1 = fully visible) |
| Render Textures | Render Texture Width | Width of the internal RenderTexture used for each Virtual Camera. |
| Render Textures | Render Texture Height | Height of the internal RenderTexture used for each Virtual Camera. |
| Render Textures | Depth Buffer | Depth buffer bit depth used for the RenderTextures (e.g., 24). |


