Working with Digital Eyewear in Unity

The digital eyewear samples demonstrate how to develop and configure Vuforia apps for both optical and video see-through Digital Eyewear.

There are two Digital Eyewear samples:
  • Stereo Rendering, for optical see-through devices
The stereo rendering sample will show you how to configure a stereo display for your Vuforia apps. This sample is applicable to supported optical see-through devices supported by the Vuforia SDK.
  • AR/VR, for video see-through devices
The AR/VR sample will show you how to develop AR/VR mixed reality experiences for video see-through devices that can seamlessly transition between AR and VR modes within the same app.

Integrating Cardboard to the AR/VR Sample
Integrating Oculus for GearVR with the AR/VR sample

Importing the samples

To import the Digital Eyewear samples into a new Unity project:
  1. Either double click on the unitypackage file (*.unitypackage to launch the Import Package dialog or import the same Unity package by selecting it from the Unity Editor menu from Assets > Import Package > Custom Package.
  2. Click the Import buttons at the bottom right of the Importing Package window.
To import the samples into an existing Vuforia Unity project:
  1. Follow the steps in the Vuforia Unity project migration guide, See: How To Migrate a Unity Project
  2. Follow the steps to import the sample into a Unity project set out above.

Running the samples

Before you build and run on the Android device

1. Obtain an App License Key and paste it into the field in the inspector for VuforiaBehaviour, See: How To add a License Key to your Vuforia App
2. Ensure the latest Android SDK has been installed and that its location has been defined in the Unity Editor ( Unity > External Tools > Android SDK Location ).
3. Ensure that you have configured the drivers for your eyewear device on your computer following the instructions provided by the manufacturer.
4. Connect the device to your PC/Mac and check that the command adb devices results in a log that shows that it is connected.

Building and Executing the Sample

1. Set your platform build target for Android in File > Build Settings.
2. Add your scene(s) to Scenes in Build.
3. Define a unique Bundle ID in Player Settings > Other Settings.
4. Define a unique Product Name to serve as the name of the app when installed on a device.
5. Select Build to generate an executable or Build & Run to both generate an executable and deploy it to a connected device.
6. You may be asked to specify the location of the installed Android SDK configured your Unity installation for Android already.

There is no need to change any of the default Player Settings to support Vuforia SDK for Digital Eyewear. You can customize the presentation of your app on the device by adding icons and splash images in Player Settings and setting the app s device orientation.

When running the sample on a device you should see a stereo rendering of the AR content with a different image delivered to each eye. The video background will be turned off. The devices will be switched to 3D mode by Vuforia prior to showing any augmentation.

Using the Unity Stereo Rendering Sample

The stereo rendering sample for Unity demonstrates how to configure a Vuforia Unity scene for stereo displays, to support both optical and video see-through digital eyewear apps.

This article highlights the prefabs and components that are significant to enabling stereo rendering and describes the configuration options that can be used to customize stereo rendering in a scene.

Sample Elements

Project Structure

Folder Name Contents

Target textures as both jpegs and PDFs for printing

/Plugins Vuforia plugin libraries for Android and iOS
/Scenes The sample scenes
/Scripts Scripts that are specific to the sample
/StreamingAssets/QCAR Device databases used in the sample
/Vuforia The Vuforia Unity extension libraries
/Vuforia/Prefabs All Vuforia prefabs encapsulating the features of the SDK

Scene Hierarchy

Name Role
ARCamera Manages the scene and device cameras along with the main Vuforia application process
ImageTargetStones A prefab instance for the Stones Image Target
ImageTargetChips A prefab instance for the Chips Image Target
ErrorCanvas A UI Canvas for presenting error messages
ErrorSystem An object encapsulating error handling behaviors

Scene View

The sample scene depicts two Image Targets configured for the StonesAndChips database augmented with teapot models.


Fields and Options
Name Role
App License Key The license key for your app. Video see-through apps should use a Mobile SDK license key. Optical see-through apps should use a Digital Eyewear license key.
Camera Device Mode A hint to indicating whether framerate or render quality should have priority when the app is running

Digital Eyewear

Name Role
Eyewear Type Defines the target See-Through device type, default is None

Digital Eyewear Video See-Through Selection

Name Role
Stereo Camera Config Indicates which stereo camera rig to use, support is provided for both Oculus and Cardboard. The default is the native Vuforia camera rig.
Viewer Type Defines which AR/VR Viewer to use, from a selection of supported viewers including Gear VR, Cardboard, Merge VR and also a Custom, developer defined, viewer type
Camera Offset Defines the distance between the stereo viewports. This setting can be used to set IPD and also to adjust eye convergence for scenes with subject matter that is very close.

Configuring the ARCamera Prefab for Digital Eyewear

Follow these instructions to configure the Digital Eyewear section of the VuforiaConfiguration asset to support either Optical or Video See-Through head-worn eyewear devices. These settings will configure your project for stereo rendering and also enable you to specify whether Vuforia should utilize the functionality for a 3rd party AR/VR SDK. 1. Add an ARCamera instance to your scene.
2. Select which eyewear type you are building for in the Digital Eyewear section

Selecting either Optical or Video See-Through will add a pair of stereo cameras to your ARCamera hierarchy.

After setting the Eyewear Type to Video See-Through, you can specify which Stereo Camera Configuration to use. This setting enables you to bind the Vuforia ARCamera to the camera rig of a 3rd party SDK, such as Oculus or Cardboard. If you aren't utilizing a 3rd party SDK with Vuforia, you can simply use the default Vuforia Stereo Camera Config.

Configuring for Optical See-Through Eyewear

Steps to configure for Optical See-Through Eyewear

Select the See Through Configuration for the eyewear device you are using. If you don't see a configuration specific to your device make and model, select the Vuforia configuration.

Note: if you are using HoloLens, you will need also need to bind the HoloLens camera to the Vuforia ARCamera, See: Developing Vuforia Apps for HoloLens

Configuring for Video See-Through Eyewear

Steps to configure for Video See-Through Eyewear

Now define which Viewer Type you are targeting - again, this only applies to Video See-Through eyewear.

4. Set a camera offset for Play Mode and video see-through eyewear

The camera offset should correspond to the interpupillary distance that you want to simulate in Play Mode and for apps running on devices such as the Gear VR. The interpupillary distance (IPD) is the distance between the centers of the pupils of someone's eyes. Typical IPD values for adults is between 54 and 68mm.

Note: Camera offset has no effect in apps running on optical see-through devices.

Viewport Configuration for Video See-Through Eyewear

The size and offset distance of the stereo viewports for camera see-through devices can be configured using the Camera Offset field in the VuforiaConfiguration asset which is accessible from the ARCamera's Inspector panel via the Open Vuforia Configuration button. You can also search for VuforiaConfiguration in the Project panel.

Camera Offset defines the distance between the stereo viewports in scene units (mm) and can be used to define an interpupillary distance ( IPD ) for the user. Camera Offset is only applicable to video see-through applications, and has no effect on optical see-through devices. The Camera Offset can be adjusted at runtime in Play Mode to evaluate the effect of different settings. The following example uses a camera offset of 42mm and a scale factor of 0.32.