cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple layered cameras for large viewing distances...

Becoming
Honored Guest
For our game WSF (a realistic wingsuit simulation) we need a very close near clip and very far far clip planes. For the non VR version we solved this by having three cameras layered on top of each other:

Near Cam - Nearclip/Farclip: 0,01/2,20 - Depth: 0 - Clear Flags: Depth only
Mid Cam - Nearclip/Farclip: 2,00/5010 - Depth: -1 - Clear Flags: Depth only
Far Cam - Nearclip/Farclip: 5000/25000 - Depth: -2 - Clear Flags: Skybox
(little overlap is necessary to cover ptential gaps)

In our VR version we want to do the same but it is a bit tricky. I was thinking i could just parent the Mid and Far Cam to the Near Cam and apply the lens correction only to the cam rendered on top... From what i see, OVR used render to texture for the lenscorrection so this approach is not working. So far so good, then i was thinking i just apply the LC to all cameras but this is still not working. When looking through the Rift i see everything doubled. I assume the LC need the cameracontroller and the Cameracontroller can only handle 2 cameras.

So my workaround now is to have 2 complete OVR camera controllers layered on top of each other(very similiar to the solution above) and it works but of corse it is not an ideal solution. The tracking has to be done twice and when i move my head quickly i can see the edge of the first OVR camera controller moving at different speed than the second.

I'm no coder but an artist, so sorry if this is a stupid way to do it... however, if someone here has messed with such a muticam setup and can put me on the right track i can get the help of a programmer. It would help a lot if i can point him into the right direction. Help is much appreciated!! So..., is there a better way to do a layered multicam setup than just using multiple camera controllers?

Thanks,
Peter
30 REPLIES 30

monsenrm
Explorer
I will try a new project.

However, I wrote a script to change near clip and far clip on the fly. Again - it works perfectly in the editor. As soon as I compile and run it on Oculus - back to .1 to 1000.

First I tried the changing the Camera in the CenterEyeAnchor directly:
	void Update () {
ThisCamera.nearClipPlane = NearClip;
ThisCamera.farClipPlane = FarClip;

}


That worked perfectly in the editor. It was totally ignored in the compiled application. I then went a little more complicated and did it directly to the OVRCameraRig (myRigCamera here). That also worked perfectly in the editor and was totally ignored in the compiled application.


	void Update () {

myRigCamera.leftEyeCamera.farClipPlane = FarClip;
myRigCamera.leftEyeCamera.nearClipPlane = NearClip;

myRigCamera.rightEyeCamera.farClipPlane = FarClip;
myRigCamera.rightEyeCamera.nearClipPlane = NearClip;

}


So I am perplexed. I will try it on a fresh project but I can't understand how this could happen.

I have of course all the latest and greatest: Unity 5.1.1p3 and Oculus runtime .7 along with the new Unity utilities.

monsenrm
Explorer
Never mind - dumb - dumb - dumb mistake.

I saved my "new" scene with a slightly different name and didn't notice when I compiled that I was using the old scene.

Multiple cameras work perfectly!

I use two OVRCameraRigs but I can't help but wonder if that is the way Oculus envisions us to do this? It just seems a little - well - non-elegant. I would think they might rather add the ability to add additional cameras to the CenterEyeAnchor to do the same job.

DillonRobinson
Honored Guest
Hey monsenrm,

This has got to be my first forum post in ages!

Can you tell me how you got that to work exactly? I finally decided I'd try to get this working, as I have some very large and very distant deep-space objects to render.

I made two OVRCameraRigs, and it almost looked like it was going to work, but something about having a second nested camera made the player controller break entirely and not respond to input. Can I ask where you placed your second OVRCameraRig?

cybereality
Grand Champion
See vrdaveb's suggestion here: viewtopic.php?f=37&t=26416&p=295714#p295714

DillonRobinson
Honored Guest
Hmmm that's how I already had it set up. It was working, as in, rendering my skybox and distant objects just fine with the second camera, but something about having a second rig in there was stopping locomotion on behalf of the player controller obj.

Now, that's if I make it nested under the player controller alongside the other camera. Is there a stipulation I should know about?

If I leave it sitting there separate from the player, it seems to work, but I'd need to make a script to apply player rotation to it, or it doesn't rotate properly when the player does (obviously)

cybereality
Grand Champion
There are errors in the console you need to fix first. You'll need to change OVRPlayerController.cs around line 118 to:

else if (CameraRigs.Length > 1) {
Debug.LogWarning ("OVRPlayerController: More then 1 OVRCameraRig attached.");
CameraRig = CameraRigs[0];
}

DillonRobinson
Honored Guest
Thanks so much cyber! Missed that. I can now have both rigs and move. Oddly though, I gotta figure out now why the Y rotation of the camera seems to double up on itself and rotate the skybox more than it should. Probably doing something ignorant 🙂

cybereality
Grand Champion
Skybox seems to work for me, maybe something strange with your project.

DillonRobinson
Honored Guest
Yeah you're right, I just made a blank scene and applied the same camera setup/skybox and it's fine. So something is messing with it, but I have no idea what. Guess I'm at another indefinite standstill haha. I've got no code that touches cameras at all. So weird. Good stuff, Unity... Thanks for the assistance man. 🙂

DillonRobinson
Honored Guest
False alarm. It only looked like it was working (duh) because I didn't add distant objects yet.

Now I'm having another issue that's probably related.

Here's a high-res video of what's happening, and I hope it's easy to follow: https://www.youtube.com/watch?v=3XH5WejcYzo


Essentially, it looks like it's gonna work, and then in my Game View, many objects from the main Oculus CameraRig aren't rendering at all, or their shapes in relation to the close camera are creating a mask through which to render the distant-view CameraRig? Very bizarre!