EyeIndex not working

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.

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

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
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”?

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 MINIlink, from the AR Video Passthrough with Unity - Stereolabs 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.

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?

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.

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
  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).

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). 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).
    However this will distort the image so we do not recommend it.

Stereolabs Support

1 Like

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?

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”.

The shader graph is similar to yours :

Stereolabs Support