Search Unity

Stereoscopic side-by-side image rendering in Unity with Oculus Rift Integration package

Discussion in 'AR/VR (XR) Discussion' started by Lancophone, Oct 31, 2015.

  1. Lancophone

    Lancophone

    Joined:
    Mar 30, 2015
    Posts:
    8
    Hi folks

    I'm looking for some help with rendering stereoscopic image in Unity with the Oculus SDK.
    I know very little about photography, but I have managed to capture some stereo images using a single camera, shifting it to the left/right by my own measured IPD.

    In order to render inside the rift, I have tried two different method so far:

    1) First, I thought it would be as simple as rendering the images to the cameras of the Oculus Rift stereo rig. I wrote a simple GLSL texture shader which literally just binds a texture to the resulting image from Unity using the OnImageRender callback function in a C# script. Applying this shader to the leftEyeAnchor and rightEyeAnchor, applying the left and right images respectively as textures, results in a visibly real stereoscopic effect, however the the camera view is as if I have moved right up towards the focused object in the image, althought the image was captured from about 30 feet away, using a 50mm lens.

    2) The second method I have tried is to place 2 plane objects in the Unity scene, and place each in a separate layer. I then set each eye anchor camera's culling mask to the respective layer. Each plane then has a material which uses the same shader as above, binding each L-R image as a texture and plastering it onto the plane object. I finally place each plane at the exact same position, rotation, and scale in space. This also results in a visibly stereoscopic effect, which I am yet to try out in the rift (I will try it on Monday in the office). However the player preview in Unity seems to be displaying the correct images inside the viewports.

    I am asking for help from any specialists as to whether or not either (or neither) of my methods above are valid for displaying sterescoopic, side-by-side images inside the Oculus rift? As I've said above, I am no photographer, and would like help on understanding how stereoscopic images should be rendered

    Thanks in advance
     
  2. Lancophone

    Lancophone

    Joined:
    Mar 30, 2015
    Posts:
    8
    Here's the shader I am using for displaying the textures if it helps.
     

    Attached Files:

  3. telferman

    telferman

    Joined:
    Jan 25, 2016
    Posts:
    35
    i'm currently working on a similar project. did you ever resolve this?