# EyeIndex not working

**URL:** <https://community.stereolabs.com/t/eyeindex-not-working/6905>\
**Category:** Unity\
**Tags:** unity\
**Created:** [August 27, 2024, 8:18am UTC](https://community.stereolabs.com/t/eyeindex-not-working/6905 "2024-08-27T08:18:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![RobinW](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/r/41988e/32.png) [@RobinW](https://community.stereolabs.com/u/RobinW)\
**Post date:** [August 27, 2024, 8:18am UTC](https://community.stereolabs.com/t/eyeindex-not-working/6905/1 "2024-08-27T08:18:35Z")

</div>

I am building a seethrough VR project.  
I need to show a different texture based on the eye the picture is rendered in.  
The unity way of solving this seems to be using EyeIndex in the shader, however this doesn’t work, and the eye index is 0 on the right and left eye.

 ![image](https://community.stereolabs.com/uploads/default/original/2X/b/b630594899fce983de8ce2bfaf30a32632886519.png)

How do I figure out which eye is currently rendering, when using ShaderGraph?

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [August 27, 2024, 9:35am UTC](https://community.stereolabs.com/t/eyeindex-not-working/6905/2 "2024-08-27T09:35:31Z")

</div>

Hi Robin,

In our shaders, we are using the `unity_StereoEyeIndex` variable. You can see how its used here : [zed-unity/ZEDCamera/Assets/SDK/Helpers/Shaders/Unlit/ZED\_Unlit.shader at master · stereolabs/zed-unity · GitHub](https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/SDK/Helpers/Shaders/Unlit/ZED_Unlit.shader#L59)  
I suppose you can create a custom function that outputs the value of this variable. Maybe that’s what you did with “EyeIndex”?

I’m not sure If that’s necessary but did you set your VR Rendering mode to “single pass”?

---

<div class="post-metadata">

**Author:** ![RobinW](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/r/41988e/32.png) [@RobinW](https://community.stereolabs.com/u/RobinW)\
**Post date:** [August 27, 2024, 10:44am UTC](https://community.stereolabs.com/t/eyeindex-not-working/6905/3 "2024-08-27T10:44:18Z")

</div>

Hello Benjamin,  
thank you for your answer. “EyeIndex” is already a prebuild node in Unity that accesses the StereoEyeIndex AFAIK, however I also already tried making a custom function outputting unity\_StereoEyeIndex instead, to no avail. (I also tried using SinglePass and MultiPass)

There might be something wrong with my XR setup in unity maybe? I am doing trial and error, because the [Vive Pro setup with ZED MINI](https://www.stereolabs.com/zed-mini/setup/vive/)link, from the [AR Video Passthrough with Unity - Stereolabs](https://www.stereolabs.com/docs/unity/video-passthrough) guide doesn’t work anymore.

I have OpenXR installed & enabled, I use URP, and the Unity/ZED output shows up in the Headset (Vive Pro 2) with no problems.

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [August 27, 2024, 11:15am UTC](https://community.stereolabs.com/t/eyeindex-not-working/6905/4 "2024-08-27T11:15:23Z")

</div>

If you can see the zed images in your headset with no problem, it can’t be an installation issue.

We are already using this variable to know which eye we need to render. The only difference with you is that we are doing it in a shader, not a shader graph.

Do you think the issue comes from our plugin? Did you try to not use our plugin at all and display a different texture on each eye using a simple camera from Unity?

---

<div class="post-metadata">

**Author:** ![RobinW](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/r/41988e/32.png) [@RobinW](https://community.stereolabs.com/u/RobinW)\
**Post date:** [September 3, 2024, 6:03pm UTC](https://community.stereolabs.com/t/eyeindex-not-working/6905/5 "2024-09-03T18:03:27Z")

</div>

Ok finally got to test it again:

Without the addon, in URP with just the basic camera and one plane + this very basic shader it works flawlessly. (OpenXR is active, if that makes a difference). I use the LTS version (2022) of Unity.

 ![image](https://community.stereolabs.com/uploads/default/original/2X/9/94ef0f45919edd4a060817c809fbbd8476ebfb07.png)

Then I tried opening the Planetarium scene (again, only OpenXR active + I did the URP conversion) so I could figure out if maybe my setup is wrong (because presumably the example scenes should be correct).  
Now 2 things:

1. The Materials for the planets except the Sun don’t load, but that likely not relevant  
 ![image](https://community.stereolabs.com/uploads/default/original/2X/9/94717449f203c9a11aafa03ed4415eb97e9ac7f1.png)
2. This selector, that allows me to choose left/right/both eyes doesn’t do anything (in no scene of the ZED), this does work in a normal Scene with just one camera (when using a VR headset) tho.
3. Again, after adding a plane with the basic shader, it doesn’t work (i.e. eye index = 0).
4. In VR there is only an image plane/screen floating of what the camera sees instead of being “surrounded” by the View. But this is likely the way it is supposed to work?

I am guessing i am doing something wrong/missing a step to enable true VR? That is why I tried the example scene, but even that doesn’t seem to work. Sadly the guide on how to setup Mixed Reality with the Vive that is linked on the " AR Video Pass-through with Unity" guide doesn’t exist anymore (links straight to the homepage).

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [September 4, 2024, 7:22am UTC](https://community.stereolabs.com/t/eyeindex-not-working/6905/6 "2024-09-04T07:22:47Z")

</div>

Hi,

1. I’ll check on my side but that’s probably a material issue coming from URP. Should not be related to your issue as you said.
2. This is “normal”. This call ([https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/SDK/Helpers/Scripts/ZEDManager.cs#L2126](https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/SDK/Helpers/Scripts/ZEDManager.cs#L2126)). It replaces the default view of the left eye which would have the black borders you are seeing.
3. I’ll reproduce your setup on my side and see if I have the same issue.
4. It’s not really possible to completely fill the screen because the FoV of the ZED camera and the headset are different (Quest is bigger).  
One workaround is to either increase the size of the plane where the image is displayed or decrease the Fov of the headset (it is explained here : [https://github.com/stereolabs/zed-unity/issues/157](https://github.com/stereolabs/zed-unity/issues/157)).  
However this will distort the image so we do not recommend it.

[Stereolabs](https://www.stereolabs.com/) Support

---

<div class="post-metadata">

**Author:** ![RobinW](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/r/41988e/32.png) [@RobinW](https://community.stereolabs.com/u/RobinW)\
**Post date:** [September 11, 2024, 3:34pm UTC](https://community.stereolabs.com/t/eyeindex-not-working/6905/7 "2024-09-11T15:34:26Z")

</div>

Well my workaround is going to be just hiding the plane from one of the cameras and having a different one for the other. Would still be nice to know if there is a proper way to achieve this with just eyeindex. Did it work for you?

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [October 1, 2024, 10:13am UTC](https://community.stereolabs.com/t/eyeindex-not-working/6905/8 "2024-10-01T10:13:08Z")

</div>

Hi Robin,

Sorry for the very late reply, I was out of office for the last weeks.

With the current implementation, you can not have 2 planes without doing significant modifications of the plugin’s code.

I tested it using a simulated headset because I don’t have one right now and it seems to work as expected. However, it needs to be set to “single pass instanced”, not “multi pass”.

![](https://stereolabs.zendesk.com/attachments/token/hcLjqZFUa6Pd9tXfd2PJb1PsB/?name=image.png)

The shader graph is similar to yours :

![](https://stereolabs.zendesk.com/attachments/token/dzcSzzsmgmnV4e8rikoQIWqUl/?name=image.png)

[Stereolabs](https://www.stereolabs.com/) Support

---

<div class="post-metadata">

**Author:** ![kit-macallister](https://community.stereolabs.com/user_avatar/community.stereolabs.com/kit-macallister/32/5213_2.png) [@kit-macallister](https://community.stereolabs.com/u/kit-macallister)\
**Post date:** [October 21, 2025, 4:13pm UTC](https://community.stereolabs.com/t/eyeindex-not-working/6905/9 "2025-10-21T16:13:25Z")

</div>

This was the key for me as well:  
[The OpenXR Mock HMD] needs to be set to “single pass instanced”, not “multi pass”.
