Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
MShekow's avatar
MShekow
Honored Guest
12 years ago

Skydome + virtual objects (AR scenario) problems

Hi there,

I have the following Unity scene (not considering the Rift yet):

  • 1. A skydome, that is, a sphere with inverted normals on which a panorama image is mapped. The diameter does not matter, but for now I've used 2 meters (= 2 Unity units) as an arbitrary value. This sphere represents the "reality" part of my AR application. It is placed in a user layer called "Background" that I created.

  • 1.1 A "Main camera" that renders the virtual objects (see point 2 below). Its clear flags is "depth only", and culling mask is setup such that it includes all layers except the background layer. The camera itself (and its child) is in the Default layer

  • 1.1.1 A "Background camera" which renders only the skydome image. By assigning depth values intelligently, I enforce the background camera to be rendering to screen first, followed by the Main camera. This way, the virtual objects are always shown, regardless whether they are inside or outside the sphere.

  • 2. Several 3d objects that may be inside or outside the sphere (these are the virtual objects that augment reality). They are in the default layer.


The transform component, i.e. x, y and z coordinates, are all set to 0/0/0 for the elements.

Now this works fine when using other HMDs, or simply rendering it to screen. That is, rendering the same image on both eyes.

Now I tried to integrate the Oculus Rift and I'm running into issues. First, I had to create a copy of the CameraLeft (named CameraLeftBG for “background”), likewise for CameraRight (getting a CameraRightBG) and configure their culling mask and clear flags accordingly. Then I modified the OVRCameraController script: I created two additional camera instances, OVRCameraController::CameraLeftBG and OVRCameraController::CameraRightBG, assigned them in Awake(). In UpdateCameras() I added two calls to ConfigureCamera(). In SetPortraitMode() I also added some code (straightforward copy/paste, changing CameraLeft to CameraLeftBG, likewise for CameraRight).

However, I discovered that when testing this, the virtual objects would not stay in fixed position (relating them to the skydome image, that is), but they would be "floating" unexpectedly. This can be mitigated by disabling the "Lens correction" checkbox of the camera controller object, but then I would somehow get headaches when looking at the virtual objects, having the impression that I have to "concentrate" as otherwise I'd feel as if I were squint-eyed. Playing around with the IPD value would improve the feeling, but I'm not able to get rid of it completely.

I understand that it may have to do with the fact that I'm combining a flat picture (skydome) with true 3-d information (virtual objects). But I don't have enough background knowledge to know how to proceed. I would be fine having stereo rendering disabled completely, but I'm not sure how to do that or whether it will help.

For your reference, you can find the example project here. When you disable the OVRCameraController in the hierarchy and enable the MainCamera, you can move the mouse to simulate the headtracker.

Best regards!
Marius

4 Replies

Replies have been turned off for this discussion
  • This is kind of a tough one. The current integration doesn't really play well with multiple cameras.

    What you can try is creating multiple OVR Camera Controllers, and then un-checking the lens correction box on the first one. This will avoid the double distortion you are seeing. However, you may still have to figure out why the 3D objects don't line up with the background.
  • MShekow's avatar
    MShekow
    Honored Guest
    Thank you so much! It works well to duplicate the camera controller and let the one do the lens correction whose cameras are rendered last. The 3D objects do line up with the background perfectly.

    Still, I'd be interested to know whether it's possible to disable the stereo-rendering in Unity in general (I'm aware that this will require some modifications to the scripts).

    Best regards!
    Marius
  • If you disable stereo rendering then the image would not be viewable on the Rift. Even if you were to duplicate a 2D image, it still wouldn't work. Since the Rift has partial overlap of the left and right eyes, it will only work with a unique image for each eye.