Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

SteamVR - How to display content in left/right eye?

Discussion in 'AR/VR (XR) Discussion' started by iebaz, Apr 7, 2016.

  1. iebaz

    iebaz

    Joined:
    Apr 13, 2015
    Posts:
    9
    Question was:
    SteamVR - How to display content in left/right eye?

    Solution is:
    By manually adding a GameObject with the SteamVR_Render component on it to your scene, you can specify a left and right culling mask to use to control rendering per eye if necessary.
     
    Last edited: Apr 7, 2016
  2. getwilde

    getwilde

    Joined:
    May 4, 2016
    Posts:
    18
    When I look at the SteamVR_Render script, I see fields for External Camera and Tracking Space, etc, but I'm not seeing anything related to culling mask per eye. Can you provide more detail?

    UPDATE: I figured it out. See my reply below.
     

    Attached Files:

    Last edited: May 22, 2016
  3. getwilde

    getwilde

    Joined:
    May 4, 2016
    Posts:
    18
    Here's the solution (as of Unity 5.4.0b17, with SteamVR 1.1.0 plugin):

    1. Drag SteamVR "CameraRig" prefab onto the scene, per usual.
    2. Add two empty gameobjects to the scene. I named them CamLeft and CamRight, but they can be anything.
    3. Set both of them to the exact same coordinates in the scene.
    4. Add a SteamVR_Camera script component to each. I found it in SteamVR/Scripts/SteamVR_Camera.
    5. Create two new layers: "LeftEye" and "RightEye" (or equivalent)
    6. On the first object, in inspector, set Target Eye: Left, and Culling Mask: "LeftEye". Likewise on the second gameobject, set "Left" and "LeftEye"
    7. Ensure that whatever objects you want viewed with left or right eye are assigned to the appropriate layers, and at the same coordinates.
     
    Last edited: May 24, 2016
  4. slims

    slims

    Joined:
    Dec 31, 2013
    Posts:
    10
    I don't see Target Eye on the camera. There is only Target Display.

    EDIT: Nevermind, figured it out: you have to enable VR Supported to see that option on the camera.
     
  5. getwilde

    getwilde

    Joined:
    May 4, 2016
    Posts:
    18
    My "solution" posted above worked for about a day, but now I cannot get it to work without having two exception thrown, (one for each eye camera): "MissingComponentException: There is no 'Camera' attached to the "CamRight (head)" game object, but a script is trying to access it."
    Not sure what's going on...

    UPDATE: If the instructions above aren't working for you, see my next post for a solution. Good luck!
     
    Last edited: May 28, 2016
  6. getwilde

    getwilde

    Joined:
    May 4, 2016
    Posts:
    18
    For some reason the emptys that I created (as mentioned above) weren't instantiating(?) cameras at runtime. So here are updated steps:

    1. Drag SteamVR "CameraRig" prefab onto the scene, per usual.
    2. Add two empty gameobjects to the scene. I named them CamLeft and CamRight, but they can be anything.
    3. Set both of them to the exact same coordinates in the scene.
    4. Add a SteamVR_Camera script component to each. (I found the script in Assets/SteamVR/Scripts/SteamVR_Camera.)
    5. In the inspector, on the "SteamVR Camera" component you just added, click the "Expand" button. It ought to create three new nested objects in your scene: "CamLeft (origin) > CamLeft (head) > CamLeft (eye)". (See attached screenshot.)
    6. For some reason, the first time I click Expand, it only creates two objects and the third is missing. But clicking the same button a second time creates another set of objects with the correct hierarchy (and also causes my empty to disappear, which is fine). I then also deleted the incorrect "CamLeft (orig)" that only had one child.
    7. Repeat steps 5-6 for CamRight. Now you should have your two cameras set up correctly.
    8. Create two new layers: "LeftEye" and "RightEye" (or equivalent)
    9. In Heirarchy, drill down to the "CamLeft (eye)". In inspector, set Target Eye: Left, and in Culling Mask, untick "RightEye" Do the equivalent for "CamRight (eye)" with opposite values.
    10. Ensure that whatever objects you want viewed with left or right eye are assigned to the appropriate layers, and are positioned the same coordinates.

    In the end, your hierarchy ought to look like the attached screenshot. Good luck!
     

    Attached Files:

    Last edited: May 28, 2016
    laurachen likes this.
  7. slims

    slims

    Joined:
    Dec 31, 2013
    Posts:
    10
  8. slims

    slims

    Joined:
    Dec 31, 2013
    Posts:
    10
    I figured it out, I just had to also add a steam vr camera object to my skybox camera. I could then set the camera rig's eye camera to depth only and use proper layering.
     
  9. Carl007

    Carl007

    Joined:
    Jan 27, 2014
    Posts:
    1
    Getwilde, you are the light of my day with this solution. Anyway, I did not get it to work, perhaps you can share a working Unity file with this configuration? I must inform that I am a newbie in Unity development.

    Well Thanks again. It works if I use beta build 5.4!
     
    Last edited: Jun 10, 2016
  10. vicator

    vicator

    Joined:
    Oct 12, 2014
    Posts:
    25
    Doing this makes the gameobject that i've added a steam vr camera to to rotate with the head. Any way to disable this?
     
  11. Stankiem

    Stankiem

    Joined:
    Dec 4, 2013
    Posts:
    113
    I am really struggling with this also. Where in the hierarchy is you skybox camera located? Is it a child to the Camera(eye) object?

    Also whenever I have a second SteamVR Camera attached to any camera in the scene the editor won't run the game.
     
  12. MrMetwurst2

    MrMetwurst2

    Joined:
    Jul 16, 2009
    Posts:
    235
    Thankyou so much.
    I tried doing this directly on the rig and it kept crashing.
    I don't know why it works this way but it does. Thanks again :)
     
  13. StarmanF

    StarmanF

    Joined:
    Apr 1, 2017
    Posts:
    1
    Sorry, what do you mean by "create two new layers"?
     
  14. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    579
  15. HappyGoCrazee

    HappyGoCrazee

    Joined:
    May 16, 2017
    Posts:
    2
    It seems like adding in the [CameraRig] to your scene initially doesn't really do anything. Once the process of setting up the two new cameras is complete, it seems redundant, as disabling still allows everything to work properly. Am I missing something, or is it not needed?
     
  16. sylvie_

    sylvie_

    Joined:
    Mar 14, 2017
    Posts:
    1
    I followed these steps but only 1 cam, CamLeft (GameObject) is shown, Even in the Hierarchy, CamLeft is placed after CamRight. I think it's overriden. Still stuck with it.
    Also my GameObject not only have this --> "CamLeft (origin) > CamLeft (head) > CamLeft (eye)", but there was also (ear), so I deleted it. Is it okay ?