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. Let us know your feedback about the Global Illumination changes in the 2023.2 beta.
    Dismiss Notice
  3. 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.