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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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.