Please Select Your Location
Australia
Österreich
België
Canada
Canada - Français
中国
Česká republika
Denmark
Deutschland
France
HongKong
Iceland
Ireland
Italia
日本
Korea
Latvija
Lietuva
Lëtzebuerg
Malta
المملكة العربية السعودية (Arabic)
Nederland
New Zealand
Norge
Polska
Portugal
Russia
Saudi Arabia
Southeast Asia
España
Suisse
Suomi
Sverige
台灣
Ukraine
United Kingdom
United States
Please Select Your Location
België
Česká republika
Denmark
Iceland
Ireland
Italia
Latvija
Lietuva
Lëtzebuerg
Malta
Nederland
Norge
Polska
Portugal
España
Suisse
Suomi
Sverige

Passthrough

What will you learn?

You will learn how to add passthrough functionality to your project.

Note: In this tutorial we will use Unity 2021.3.9f1 and VIVE Devices.

What is Passthrough?

In this session, lets learn how to use the passthrough feature which enables an application to show the passthrough image to see the surrounding environment from the VR headset. The application is allowed to configure the passthrough image with the different appearances according to the demand of the application. There are 3 types of passthrough which are Passthrough Overlay, Passthrough Underlay and Project (Overlay). To read up on the different types of passthrough, you can reference the passthrough tutorial on our Wave SDK documentation site here. In this tutorial, we are going to focus on setting up Passthrough Underlay.

Option 1: Manual Setup

Step 1. In a scene with an XR Rig, create a C# class called PassthroughDemoHelper. Paste the following code in the class. In order for Passthrough Underlay to be visible and properly occluded by in-app objects, the area which the Passthrough Underlay should be visible should be in transparent black (i.e. Color(0,0,0,0)). To achieve this, you can change the Main Camera background color to transparent black and set the Clear Flag to Solid Color.

using System;
using UnityEngine;
using Wave.Native;

[Serializable]
public class PassthroughDemoHelper
{
    [SerializeField] private Camera hmd;

    public void ShowPassthroughUnderlay(bool show)
    {
        if (show)
        {
            hmd.clearFlags = CameraClearFlags.SolidColor;
            hmd.backgroundColor = new Color(0, 0, 0, 0);
        }
        else
        {
            hmd.clearFlags = CameraClearFlags.Skybox;
        }

        Interop.WVR_ShowPassthroughUnderlay(show);
    }
}

Step 2. In the Hierarchy window, create a new empty gameobject called PassthroughDemo. Create a new C# script called PassthroughDemo. Paste the following code in the script and add the script to the gameobject. The script uses the PassthroughDemoHelper script to call the method to activate passthrough.

using UnityEngine;
using Wave.Essence;
using Wave.Native;

public class PassthroughDemo : MonoBehaviour
{
    [SerializeField] private PassthroughDemoHelper passthroughHelper;

    // Update is called once per frame
    void Update()
    {
        if (ButtonFacade.YButtonPressed)
        {
            passthroughHelper.ShowPassthroughUnderlay(!Interop.WVR_IsPassthroughOverlayVisible());
        }
    }

    private static class ButtonFacade
    {
        public static bool YButtonPressed =>
            WXRDevice.ButtonPress(WVR_DeviceType.WVR_DeviceType_Controller_Left, WVR_InputId.WVR_InputId_Alias1_Y);
    }
}



Step 3. Update the Hmd reference with the Main Camera under the PassthroughHelper property in the PassthroughDemo script.



Step 4. Build and deploy your apk. Test passthrough using the Y button.

Option 2: Setup passthrough using a unity package

Step 1. Download the PassthroughInstaller unity package

Step 2. Import the unitypackage file in the Unity editor.

Step 3. In the Hierarchy window, create a new empty gameobject called PassthroughDemo. Add the PassthroughDemo script to the PassthroughDemo gameobject. The script uses the PassthroughDemoHelper script to call the method to activate passthrough.

Step 4. Update the Hmd reference with the Main Camera under the PassthroughHelper property in the PassthroughDemo script.

Step 5. Build and deploy your apk. Test passthrough using the Y button.