Different Skyboxes for each Left and Right Eye

Using GVRMain to add Cardboard to the Scene, I’m unable to set a separate Skybox for each Main Camera Left and Main Camera Right as it seems whatever is in Main Camera simply overrides whatever is being seen on each Camera.

The reason I want to set two separate Skyboxes is to have a truly Stereoscopic view - I have two separate cubemaps with offsets to apply to each Left and Right eye accordingly.

However I noticed that when setting the Skybox dynamically in runtime through the GUI editor the desired effects to take place! Weird…

Is there a way to easily, programmaitcally, set the Skybox materials for each Main Camera Left and Main Camera Right cameras?

Thanks in advance

I don’t have any experience with google cardboard, but worked quite a bit with Unity + OVR … not entirely sure it applies to your Cardboard problem.

Anyhows: In the olden days, the VR camera rig would contain multiple cameras, but when they switched to Unity5 (I think that was when), they changed the approach to have one camera and a couple of anchors.

If I’m not entirely mistaken, when you start the project/scene, the stuff you have on your center camera is replicated somehow to the anchors which only then start working as cameras. It probably overwrites the skybox you set on the left/right anchors (which don’t actually need anything else than a transform now).

Anyhow, I’d suggest you make a script that finds one of the cameras and sets the skybox you want for it. I am not sure if the start method would be early enough for that - if it isn’t you probably want to make a co-routine and do a yield WaitForEndOfFrame() in it, so that you are sure that the VR cameras are done doing their awake/start stuff before you go and set skyboxes.

Hope you figure it out!

Thanks for putting that script up @Fabioloza.
I’m getting a null reference error.

I’m probably doing something stupid.
Where do I attach the script to ? The gvrmain prefab ?
Where are you setting the skybox to the right eye ?

The code works just fine in a scene that is not related to cardboard.

Thanks for any help Here man.
Cheers,
b,Hi @Fabio loza,
Thank you for putte that script up.
I’m getting a null reference error when I run it.

Am I supposed to attach this script on the the GVR main prefab or the camera rig.

Your script works when I attach it to a camera in a new scene that is unrelated to cardboard.

Thanks so much for any help here.
b

@behram yeah looks like you’re overwriting your references.

Before, GVR would attach Main Camera, Main Cam Left and Main Cam Right. As you say, now there’s only one?

You’re setting up camLeft as GameObject.Find(“Main Camera”) ← not sure if this is targeting the Left camera? Anyway, you then use “Main Camera” as your camRight reference as well.

I haven’t looked at the new version of the SDK but there must be a way to target the Left Camera and Right Camera separately. And it shouldn’t be through “Main Cam” as you’re currently doing.

Good luck!