Skip to main content
Participant
August 17, 2013

Multiple layered cameras for large viewing distances...

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
    This topic has been closed for replies.

    30 replies

    sh0v0r
    Up and Coming
    June 24, 2014
    "vrdaveb" wrote:
    Your camera setup looks good, sh0v0r. We have seen cases where the World camera's output gets dropped when using image effects, HDR, or deferred lighting on the World camera rig, but they aren't 100% consistent. You may need to enable "Use Camera Texture" on the OVRCameraController. If that has no effect, I may be able to send a code change that splits the RenderTextures up on a per-eye basis like we did in 0.3.1. The World camera GameObject with the OVRCameraController on it should not have an active OVRDistortionCamera or Camera component. You can just disable the ones that are already there.


    OK, so yeah it turns out that we see that problem in either Deferred Rendering or in Forward Rendering with a Sun Shaft image effect on the (near) Cockpit Cameras.

    If you are able to send through a code fix that would be great, I am using the latest SDK that was sent out to Pilot DK2 developers. The kit hasn't arrived yet but I would like to start getting this setup for Lunar Flight and the Sun Shafts are a key bit of eye candy in the cockpit.
    sh0v0r
    Up and Coming
    July 11, 2014
    "vrdaveb" wrote:
    If that has no effect, I may be able to send a code change that splits the RenderTextures up on a per-eye basis like we did in 0.3.1.


    Just a follow up I have created a small project for you to download which has this already setup to demonstrate the issue we have.

    https://www.dropbox.com/s/hp5nxoboh50rqgd/LayeredCameraBug.zip

    Note the Left eye on the near camera rig seems to be combining the Right Eyes view.

    This issue only occurs in Deferred rendering, I am not experiencing it in Lunar Flight which is Forward.

    Our new project ZVR requires Deferred however.
    Inspiring
    July 11, 2014
    Thanks for the project. I built it with Unity 4.5.1 and saw only the Far Text. We'll clean up this use case for the next release.
    Up and Coming
    August 2, 2015
    Was any progress made on this?
    sh0v0r
    Up and Coming
    August 23, 2015
    "digital" wrote:
    Was any progress made on this?


    You can just use multiple rigs now with the depth and layers set for each camera.

    Seems to be working OK for me in U5 0.6.0.1, not sure what the overhead is for having multiple Rig Controllers though?
    Up and Coming
    August 26, 2015
    This is fascinating thread, but I was wondering if one of you can explain the "why" to me?

    Why do you need two cameras?
    Participant
    August 31, 2015
    I tried it and it works fine in the editor. One OVRCameraRig is set for .1 to 5 - clear is Depth only and Depth of 1. The other is set to 4 to 5000 and Clear Flags are Skybox. Depth is 0.

    Again - it works perfectly in the editor.

    However, when I compile and run the application both cameras/OVRCameraRigs default back to .1 to 1000.


    Any ideas out there?
    Inspiring
    August 31, 2015
    "sh0v0r" wrote:
    not sure what the overhead is for having multiple Rig Controllers though?

    It does take a little extra fill rate, depending on the rendering cost of each pass. It should work fine on PC in most cases, but I wouldn't recommend it on Android.

    "wheatgrinder" wrote:
    Why do you need two cameras?

    There are a few reasons:
    (1) In a space fighter game, once the player gets >1km from the origin, floating point error becomes significant (>1cm), causing visible vibration in nearby objects. You might want to render things like a cockpit in a different reference frame from the rest of the world.
    (2) You may want to render close-up objects at a different quality level or with different depth precision than far-away objects.
    (3) If you have content that ranges from from 1mm to 100km away, you can't just set Unity's clipping planes to those values because there will be z-fighting (parts objects will appear on top of each other in the wrong order). You might want to split the depth range up to keep the ratio of near/far below 1000.
    Inspiring
    August 31, 2015
    "monsenrm" wrote:
    when I compile and run the application both cameras/OVRCameraRigs default back to .1 to 1000.

    I can't reproduce this. It sounds like you set things up right. Does it still happen for you in a fresh project?
    Participant
    September 1, 2015
    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.