Search Unity

Cardboard Package: Layers per eye?

Discussion in 'AR/VR (XR) Discussion' started by Bitcloud, Dec 24, 2014.

  1. Bitcloud

    Bitcloud

    Joined:
    Feb 25, 2014
    Posts:
    8
    Hey guys,

    I'm currently attempting to display different objects per eye Camera via the Google Cardboard Package.

    It seems the heirarchy contains:
    Main Camera
    - Main Camera Left
    - Main Camera Right

    It's somehow set up to propagate all settings (including culling masks) from the Main Camera through to the left and right cameras, overriding anything you set there.

    I've tried a bunch of things, but I'm hitting a wall. I'm wondering, does anyone have any idea how to pop the hood on this asset in order to bring culling masks/layers back to each eye? (I don't mind if I lose the "Stereo Controller" Script and have to set my cameras manually)

    Cheers
    Lachlan
     
  2. dolims

    dolims

    Joined:
    Sep 13, 2014
    Posts:
    61
    The code that does the culling mask copying is in CardboardEye.cs, function CopyCameraAndMakeSideBySide(). It's this line:
    camera.CopyFrom(controller.GetComponent<Camera>());
    You could comment it out if you don't really need to keep the settings sync'ed. Or just add your own culling mask bits to the eye after this line.
     
    Taokey and JDMulti like this.
  3. Bitcloud

    Bitcloud

    Joined:
    Feb 25, 2014
    Posts:
    8
    Thanks heaps man! That's the ticket.

    You wouldn't happen to also know how to override the distortion would you? I'd prefer to put my own fish eye on, but it seems to break the stereo
     
  4. dolims

    dolims

    Joined:
    Sep 13, 2014
    Posts:
    61
    Sure! Use Unity Free :D

    Actually, there's a function in Cardboard.cs called canApplyDistortionCorrection(), which checks that all the prerequisites are available for doing the distortion. If you make this function return false, then the distortion will not be done. You can then do your own. If you do it as an Image Effect, make sure to clear the Direct Render checkbox on the StereoController -- this seems to be necessary for Image Effects to work right with side-by-side stereo.

    Just be careful with your distortion -- the Cardboard lenses are not doing a simple fisheye. They actually cause a pincushion distortion effect. The SDK in turn does a barrel distortion to counteract that. If your own distortion doesn't do effectively the same thing, it will look very weird.
     
    Taokey likes this.
  5. dolims

    dolims

    Joined:
    Sep 13, 2014
    Posts:
    61
    New release of Cardboard (0.4.5) supports layers per eye and you can turn off the built-in substitution collection.
     
  6. Rapskalian

    Rapskalian

    Joined:
    Jan 4, 2011
    Posts:
    45