WebXR Export

WebXR Mixed Reality Capture

Using Mixed Reality Capture in WebXR requires different parts to work together. In this page we will go over the different parts and settings to make it work in a project.

General info

Mixed Reality Capture is used to merge between the real world and the virtual world, by positioning a real camera feed inside the virtual environment and displaying the outcome in a spectator display. In this WebXR solution, we made sure that WebXR Export can support Spectator mode and had the code of the Mixed Reality Capture feature in the WebXR Interactions package. A configured prefab can be found in the Sample scene of WebXR Interactions named as SpectatorCameraHolder.prefab.

Expected hierarchy

The current configuration is expected for Mixed Reality Capture to work properly

- SpectatorCameraHolder
  - SpectatorCamera (Components: Camera, SpectatorCamera)
    - StackCameras
      - SpectatorBackgroundCamera (Components: Camera)
      - SpectatorWebcamLightingCamera (Components: Camera)
      - SpectatorForegroundCamera (Components: Camera)
      - Background (Components: MeshFilter with Quad, MeshRenderer with UnlitTransparent Material. Layer: Spectator) 
      - Foreground (Components: MeshFilter with Quad, MeshRenderer with UnlitTransparent Material. Layer: Spectator)
  - MixedRealityCaptureController (Components: MixedRealityCaptureController)
    - CameraPoint (Used as Visual reference for moving point)
    - TopPoint (Used as Visual reference for moving point)
    - BottomPoint (Used as Visual reference for moving point)
  - WebcamHolder
    - WebcamQuad (Components: PlayWebcam, MeshFilter with Quad, MeshRenderer with ChromaKeyUnlit Material. Layer: Webcam)
      - WebcamLightingQuad (Components: MeshFilter with Quad, MeshRenderer with White Legacy Diffuse Material. Layer: WebcamLighting)
    - CameraHint (Used as Visual reference for point on webcam)
    - TopHint (Used as Visual reference for point on webcam)
    - BottomHint (Used as Visual reference for point on webcam)

Layers

The SpectatorCameraHolder.prefab sample prefab uses pre-defined layers:

Configuring Mixed Reality Capture in a project

Some general steps to follow when implementing WebXR Mixed Reality Capture in a project:

That should handle all the configurations needed for Mixed Reality Captuer to work properly.

Enable Mixed Reality Captuer on runtime

Once the project runs, for the feature to be enabled, both the SpectatorCamera and MixedRealityCaptureController should be set to be enable in XR. Both components contains EnableInXR(bool) method to enable their functionality when user is switching to XR mode.

There are more customization and settings that can be handle by scripts like Chroma Key min and max range, check the MixedRealityCaptureController and PlayWebcam code for those options.