Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

unity_stereoEyeIndex with GLSL (Single Pass Implementation details)

Discussion in 'AR/VR (XR) Discussion' started by not_a_valid_username, Dec 4, 2018 at 11:37 PM.

  1. not_a_valid_username

    not_a_valid_username

    Joined:
    Jul 28, 2018
    Posts:
    5
    I'm trying to play a 3D video on a texture in Unity on Android. Because the video is a high resolution and framerate, I need to use OES textures for the video, which forces me to use a GLSL shader (as OES texture sampling is not currently supported in CG).

    My question is, how do I get the current eye being rendered when using GLSL? With CG, this can be easily accessed with unity_StereoEyeIndex, but I don't seem to be able to access that function when the shader is directly written in GLSL.
     
  2. not_a_valid_username

    not_a_valid_username

    Joined:
    Jul 28, 2018
    Posts:
    5
    By viewing a compiled CG shader, I see that unity_StereoEyeIndex is a uniform int in the fragment shader. Putting this in my GLSL shader seemed to do the trick
     
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    7,434
    Thanks for returning with the answer. Any chance you'll share your shader here, for posterity?