Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice
  2. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

unity_StereoEyeIndex is always 0

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

  1. ErdTod

    ErdTod

    Joined:
    Jan 7, 2018
    Posts:
    8
    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!

    So,
    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

    amirebrahimi_unity

    Unity Technologies

    Joined:
    Aug 12, 2015
    Posts:
    380
  3. mptp

    mptp

    Joined:
    May 30, 2014
    Posts:
    29
    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.
     
unityunity