This repository contains a generalized sample project demonstrating two advanced XR implementations in Unity: a seamless "Hole Punching" Portal between Mixed Reality (Passthrough) and Virtual Reality, and a network-based Motion Capture streaming solution using Rokoko Studio.
These features have been extracted and generalized from a larger production environment to serve as a reference implementation for standalone VR headsets (Meta Quest).
- About The Project
- Built With
- Prerequisites
- Installation & Setup
- Configuration
- Usage
- Troubleshooting
- License
This project solves two common challenges in modern XR development:
- Immersive Transitions: Creating a non-euclidean portal that allows users to physically walk from their real-world environment (Passthrough) into a virtual world using URP Stencil Buffers.
- Remote Animation: Streaming high-fidelity body data from a motion capture suit (Windows PC) to a mobile VR client (Android/Quest) in real-time over a local network.
- Engine: Unity 2022.3 (Universal Render Pipeline)
- XR Framework: Meta XR Core SDK (Building Blocks)
- Networking: Photon Fusion
- Mocap Integration: Rokoko Studio Live
Before cloning the repository, ensure you have the following:
- Unity Hub & Editor: Unity 2022.3 LTS or newer with Android Build Support and OpenJDK installed.
- Hardware: Meta Quest 2, 3, or Pro.
- Mocap Hardware (Optional): Rokoko Smartsuit Pro and Rokoko Studio installed on a Windows PC (required only for testing the streaming feature).
-
Clone the Repository
git clone https://github.com/FKI-HTW/SamplesPhygitalIntimacy.git
-
Open in Unity Add the project to Unity Hub and open it. Allow Unity to resolve packages.
-
Import Dependencies If not already present, ensure the following packages are installed via Package Manager or Asset Store:
- Photon Fusion
- Rokoko Live for Unity
- Meta XR All-in-One SDK
CRITICAL: The portal rendering relies on a specific Universal Render Pipeline (URP) configuration that may not persist when moving the project between machines. Follow these steps to ensure the portal renders correctly.
- Open Edit > Project Settings > Tags and Layers.
- Add a new User Layer named
VirtualWorld. - Assign your entire 3D environment (all virtual objects) to this layer.
- Navigate to your URP Renderer Data asset (usually located in
Settings/ForwardRendererorMobile_Renderer). - In the Inspector, under Filtering, find Opaque Layer Mask and uncheck
VirtualWorld. - Click Add Renderer Feature and select Render Objects.
- Name it
Stencil Maskand configure it as follows:- Event: AfterRenderingOpaques
- Filters > Queue: Opaque
- Filters > Layer Mask: Check only
VirtualWorld - Overrides: Check
Stencil - Stencil > Value:
1 - Stencil > Compare Function:
Equal(Objects render only where Stencil is 1) orNotEqual(Objects render everywhere except where Stencil is 1), depending on your desired masking logic.
Note: For the provided sample scene, use Equal if the portal defines the visible area, or NotEqual if the portal defines the "hole" to reality.
The transition between MR and VR is handled by the PortalTriggerController script.
- Trigger Mechanism: The script detects the
CenterEyeAnchor(Camera) entering the portal geometry. - State Switching:
- To VR: The script deactivates the Meta Passthrough Building Block and enables the full rendering of the
VirtualWorldlayer. - To MR: The script activates the Passthrough Building Block (Underlay) and applies the Stencil Mask to hide the virtual world outside the portal frame.
- To VR: The script deactivates the Meta Passthrough Building Block and enables the full rendering of the
- Customization: You can adjust
Transition DelayandRandomize Orderin the inspector to create a dissolving transition effect.
- Open Rokoko Studio on your PC and enable Live Stream (ensure the PC and Headset are on the same Wi-Fi).
- In the Unity Scene, ensure the
StudioManagerGameObject is active. - The
Actorcomponent on the character rig is configured to receive the data stream.
If you encounter build failures when deploying to Meta Quest regarding native plugins, you must remove incompatible libraries from the Rokoko package.
- Go to
Assets/Rokoko/Plugins/(or the relevant installation folder). - Delete the folders
armeabi-v7aandx86. - Rebuild the project.
- Check that your Main Camera Background Type is set to
Solid Colorwith Alpha 0(0,0,0,0). - Ensure the Passthrough capability is enabled in
OVRManager. - Verify the URP Renderer Feature steps listed in the Configuration section.
This project is licensed under the MIT License.