Cardboard Package: Layers per eye?

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

The code that does the culling mask copying is in CardboardEye.cs, function CopyCameraAndMakeSideBySide(). It’s this line:
camera.CopyFrom(controller.GetComponent());
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.

2 Likes

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

Sure! Use Unity Free :smile:

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.

1 Like

New release of Cardboard (0.4.5) supports layers per eye and you can turn off the built-in substitution collection.

For people reading this post trying to figure out how to play stereoscopic 360 videos in cardboard, check out my answer to this related post: Cardboard - setting up culling mask works in editor but not on Android - Unity Engine - Unity Discussions