Develop

Passthrough sample overview

Updated: May 7, 2026

Overview

This sample demonstrates how to implement mixed reality passthrough features in Unity using the Meta XR Core SDK. Across two interactive scenes, you explore runtime MR/VR toggling, contextual passthrough detection, style adjustments, selective surface projection, and hand-tracked interactions.

What you will learn

  • Toggle between VR and mixed reality modes at runtime with smooth fade transitions
  • Detect contextual passthrough at app launch and configure splash screens accordingly
  • Adjust passthrough appearance using brightness, contrast, saturation, color LUTs, and edge rendering — including adapting for device capabilities
  • Project passthrough onto specific mesh surfaces for selective visibility effects
  • Integrate hand tracking and controller input with passthrough features

Requirements

  • Meta Quest device with passthrough support (Quest 2, Quest 3, or Quest 3S, or later)
  • Unity development environment with Meta XR Core SDK installed
  • For detailed setup instructions, see the Meta Quest development environment setup.

Get started

Clone or download the Unity-StarterSamples repository from GitHub. Open the project in Unity and navigate to Assets/StarterSamples/Usage/Passthrough/Scenes/. Load either EnableDisablePassthrough.unity for interactive feature demos or PassthroughAtStartup.unity for contextual launch testing. Build and deploy to your Meta Quest device. For complete build instructions and project settings, see the sample README.

Explore the sample

The sample contains two scenes demonstrating different passthrough use cases.
SceneWhat it demonstratesKey concepts
EnableDisablePassthrough.unity
Interactive demos of passthrough features including runtime MR/VR toggling, hand-tracked flashlight, 3D drawing brush, selective surface projection, and style controls. Combines multiple passthrough techniques in a single experience.
Runtime passthrough toggling, selective passthrough, device capability queries, hand tracking
PassthroughAtStartup.unity
Contextual passthrough at app launch with a splash screen overlay and runtime info panel. Shows how to adapt launch behavior based on the user’s environment.
Contextual passthrough detection, splash screen configuration, project settings
ScriptWhat it demonstratesKey concepts
EnableDisablePassthroughController.cs
Runtime MR/VR toggle with fade transitions using OVRManager.instance.isInsightPassthroughEnabled and OVRPassthroughLayer
Passthrough subsystem control, layer visibility, event-driven UI updates
PassthroughAtStartupController.cs
Contextual passthrough detection via OVRManager.IsPassthroughRecommended() and conditional splash screen
Launch context detection, async scene loading
PassthroughStyler.cs
Style control UI: brightness/contrast/saturation via SetBrightnessContrastSaturation(), color LUTs via SetColorLut(), edge rendering
Passthrough appearance customization, device capability adaptation
SPPquad.cs
Selective passthrough projection onto mesh surfaces using AddSurfaceGeometry(GameObject, bool) and RemoveSurfaceGeometry(GameObject)
Surface-based passthrough windows, geometry registration
FlashlightController.cs
Dual-input flashlight: controller mode (A button toggle) and hand tracking mode (pinch gesture) using OVRSkeleton and OVRHand
Hand tracking integration, multi-input support
PassthroughBrush.cs
3D drawing tool creating passthrough strokes in space using LineRenderer
Real-time passthrough geometry creation
EnableUnpremultipliedAlpha.cs
Disables premultiplied alpha compositing via OVRManager.eyeFovPremultipliedAlphaModeEnabled = false
Correct alpha blending for selective passthrough

Runtime behavior

When you run the EnableDisablePassthrough scene, the environment appears in mixed reality or VR mode depending on launch context. The A button toggles between modes with a smooth fade transition. The scene provides several interactive objects for manipulation: a passthrough flashlight (toggled with the A button or a pinch gesture), a 3D brush that draws passthrough strokes in space, a selective passthrough quad showing the real world through a virtual surface, and a style control panel for adjusting passthrough brightness, contrast, saturation, color LUTs, and edge rendering. The Start button cycles to the next scene.
When you run the PassthroughAtStartup scene, the app checks OVRManager.IsPassthroughRecommended(). If passthrough is recommended (launched from MR Home), a splash screen overlay appears on the real world with a smooth fade-in. If not recommended (launched from VR Home), the scene fades in from black instead. An info panel displays the runtime status of contextual passthrough, system splash screen, and Unity splash screen settings.

Key concepts

Runtime MR/VR toggling

The sample demonstrates switching between VR and mixed reality modes at runtime by combining OVRManager.instance.isInsightPassthroughEnabled with OVRPassthroughLayer.enabled. The EnableDisablePassthroughController script subscribes to OVRPassthroughLayer.passthroughLayerResumed to synchronize UI updates with passthrough readiness. A custom shader (PassthroughFader) provides smooth visual transitions between modes. For related API details, see the OVRPassthroughLayer reference.

Contextual passthrough at app launch

The sample uses OVRManager.IsPassthroughRecommended() to detect whether the user launched the app from a passthrough context like MR Home. When true, PassthroughAtStartupController enables passthrough and shows a splash screen overlay. When false, the app fades in from black instead. For project configuration requirements, see the contextual passthrough documentation.

Passthrough style adjustment

The PassthroughStyler demonstrates two style modes using OVRPassthroughLayer.ColorMapEditorType. In ColorAdjustment mode, it adjusts brightness, contrast, and saturation via SetBrightnessContrastSaturation(). In ColorLut mode, it applies color look-up tables via SetColorLut() with OVRPassthroughColorLut instances. The script queries OVRManager.GetPassthroughCapabilities().SupportsColorPassthrough to adapt the UI for monochrome devices. For supported style parameters, see the passthrough styling reference.

Selective passthrough surface projection

The SPPquad script projects passthrough onto a specific mesh surface by calling OVRPassthroughLayer.AddSurfaceGeometry(gameObject, false) on start and RemoveSurfaceGeometry(gameObject) when grabbed. This creates a “window” into the real world on a virtual surface — useful for portals, virtual window frames, or spotlight effects. The flashlight uses the same technique to create a cone of passthrough visibility.

Unpremultiplied alpha compositing

The EnableUnpremultipliedAlpha script sets OVRManager.eyeFovPremultipliedAlphaModeEnabled = false to disable premultiplied alpha in framebuffers. This is required for correct blending when using non-binary alpha values in selective passthrough. Without this setting, the compositor assumes premultiplied alpha and produces incorrect transparency effects.

Extend the sample

  • Modify the passthrough brush to use custom materials or textures instead of solid passthrough strokes
  • Add spatial anchors to selective passthrough surfaces so they persist across sessions at fixed real-world locations
  • Implement additional passthrough style presets using color LUTs for artistic effects like sepia tone or high contrast
For related samples demonstrating spatial anchors and scene understanding, see the Unity-SharedSpatialAnchors sample and the Unity-SceneAPI sample.