Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

VR Possible to detect which VR eye in shader?

Discussion in '5.4 Beta' started by Cubic_Creo, Mar 10, 2016.

  1. Cubic_Creo

    Cubic_Creo

    Joined:
    Oct 13, 2014
    Posts:
    47
    Is it possible to detect which VR eye is being drawn for in a shader?
     
  2. Cubic_Creo

    Cubic_Creo

    Joined:
    Oct 13, 2014
    Posts:
    47
    I've figured out a workaround. For anyone else looking for something like this, I've scoured the 5.4 docs, and I don't think there's anything explicitly for this purpose. But since the projection matrix is different for each eye, you can do this:

    Code (CSharp):
    1. if (unity_CameraProjection[0][2] < 0) {
    2.     o.Emission = tex2D(_LeftEyeTexture, screenUV).rgb;
    3. } else {
    4.     o.Emission = tex2D(_RightEyeTexture, screenUV).rgb;
    5. }
     
    SunnySunshine likes this.