Getting The Data of Eye Tracker (Beta)
The Eye Tracker feature provided by VIVE OpenXR allows you to get eye tracking related data for each eye of the user.
Supported Platforms and Devices
Platform | Headset | Supported | Plugin Version | |
PC | PC Streaming | Focus 3/XR Elite/Focus Vision | V | 2.4.2 and above |
Pure PC | Vive Cosmos | X | ||
Vive Pro series | V | 2.4.2 and above | ||
AIO | Focus 3 | X | ||
XR Elite | V | 2.5.0 and above | ||
Focus Vision | V | 2.5.0 and above |
Specification
This chapter will explore how to create more immersive experiences using the Eye Tracker feature within the VIVE XR Eye Tracker extension.
The eye tracking related data for each eye of the user is organized into the following buckets:
Gaze Data: This provides information about eye position and orientation.
Pupil Data: This provides information about pupil diameter and position.
Geometric Data: This provides information about geometric attributes such as openness of the eye.
Environment Settings
Before starting, remember to check if your development environment meets the following requirements.
Step 1. Check your VIVE OpenXR Plugin package version
Go to Window > Package Manager, the VIVE OpenXR Plugin version should be 2.5.0 or newer.
Step 2. Enable the Eye Tracker feature
For Android: Go to Project Settings > XR Plug-In Management > OpenXR and enable VIVE XR Eye Tracker.
For PC: Go to Project Settings > XR Plug-In Management > OpenXR and enable VIVE XR Eye Tracker.
Golden Sample
In this chapter, I am going to teach you how to use VIVE OpenXR Eye Tracker, for I believe it is simpler, more efficient and covers most user scenarios.
Get Gaze For Each Eye In XR
Take left eye as an example.
Step 1. Create empty GameObjects named LeftGaze.
Step 2. Create small Sphere named Sphere under LeftGaze.
Set an appropriate distance and scale to represent the location where the gaze direction is projected.
Step 3. Create a script called UpdateLeftGaze.cs and attach to LeftGaze gameobject.
In UpdateLeftGaze.cs, first, we add two namespaces.
using VIVE.OpenXR;
using VIVE.OpenXR.EyeTracker;
These two namespaces allow us to use the VIVE OpenXR Eye Tracker.
In Update(), we’ll retrieve the gaze data for both eye from XR_HTC_eye_tracker.Interop.GetEyeGazeData().
XR_HTC_eye_tracker.Interop.GetEyeGazeData(out XrSingleEyeGazeDataHTC[] out_gazes);
XrSingleEyeGazeDataHTC leftGaze = out_gazes[(int)XrEyePositionHTC.XR_EYE_POSITION_LEFT_HTC];
if(leftGaze.isValid)
{
transform.position = leftGaze.gazePose.position.ToUnityVector();
transform.rotation = leftGaze.gazePose.orientation.ToUnityQuaternion();
}
Now, we are ready to go. Let’s build and run this app and see your left eye gaze in the XR world.
Get Pupil Data For Each Eye In XR
Take right eye as an example.
Step 1. Create empty GameObjects named RightPupil.
Step 2. Create a script called UpdateRightPupil.cs and attach to RightPupil gameobject.
In UpdateRightPupil.cs, first, we add two namespaces.
using VIVE.OpenXR;
using VIVE.OpenXR.EyeTracker;
These two namespaces allow us to use the VIVE OpenXR Eye Tracker.
In Update(), we’ll retrieve the pupil data for both eye from XR_HTC_eye_tracker.Interop.GetEyePupilData().
XR_HTC_eye_tracker.Interop.GetEyePupilData(out XrSingleEyePupilDataHTC[] out_pupils);
XrSingleEyePupilDataHTC rightPupil = out_pupils[(int)XrEyePositionHTC.XR_EYE_POSITION_RIGHT_HTC];
if(rightPupil.isDiameterValid)
float rightPupilDiameter = rightPupil.pupilDiameter;
//Do something
if(rightPupil.isPositionValid)
XrVector2f rightPupilPosition = rightPupil.pupilPosition;
//Do something
Now, we are ready to go. Let’s build and run this app to get your right eye pupil data in the XR world.
Get Geometric Data For Each Eye In XR
Take right eye as an example.
Step 1. Create empty GameObjects named RightEyegeometric.
Step 2. Create a script called UpdateRightEyeGeometric.cs and attach to RightEyegeometric gameobject.
In UpdateRightEyeGeometric.cs, first, we add two namespaces.
using VIVE.OpenXR;
using VIVE.OpenXR.EyeTracker;
These two namespaces allow us to use the VIVE OpenXR Eye Tracker.
In Update(), we’ll retrieve the geometric data for both eye from XR_HTC_eye_tracker.Interop.GetEyeGeometricData().
XR_HTC_eye_tracker.Interop.GetEyeGeometricData(out XrSingleEyeGeometricDataHTC[] out_geometrics);
XrSingleEyeGeometricDataHTC rightGeometric = out_geometrics[(int)XrEyePositionHTC.XR_EYE_POSITION_RIGHT_HTC];
if(rightGeometric.isValid)
float rightEyeOpenness = rightGeometric.eyeOpenness;
float rightEyeeyeSqueeze = rightGeometric.eyeSqueeze;
float rightEyeeyeWide = rightGeometric.eyeWide;
//Do something
Now, we are ready to go. Let’s build and run this app to get your right eye geometric data in the XR world.