Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

unity_StereoEyeIndex is always 0

Discussion in 'EditorXR' started by ErdTod, Aug 9, 2018.

  1. ErdTod


    Jan 7, 2018
    Hello, community!
    I have enabled Single Pass Stereo Rendering, and trying to make my shader work with Unity built-in variable unity_StereoEyeIndex - however, it seems that it awlays outputs 0 - when I flip cameras target eye, nothing changes - I seem to always see left eye. There's oddly not too much of stuff explained about this, so if anyone here could help me figure out how to properly use this variable, and how can I see results of it working in unity Editor - I'm sure this would be useful for many users in the present and future, including myself!

    Should I set up something else in the Editor, after turning on VR support in Player Settings, and selecting Single Pass Stereo Rendering?
    Or, maybe, I need to have some includes, or defines in my custom (vert/frag) shader? I just want to utilize unity_StereoEyeIndex being 0 for left eye, and 1 for right eye.
    Or should I install some kind of SDK, or import some kind of unitypackage? What can I do to see the results in Editor, like, for example, in this video:
  2. amirebrahimi_unity


    Unity Technologies

    Aug 12, 2015
  3. mptp


    May 30, 2014
    Since this is the first result in Google for checking this error, I thought I might as well say that unity_StereoEyeIndex only has a valid value in your vertex shader. If you try to access it in the fragment shader, it'll have a value of zero.

    If you need to access the stereo eye index in your fragment shader, pass it through your vertex-to-fragment struct.