Skip to main content
Inspiring
April 6, 2013

Any gotchas with a multiple ovrcameracontroller setup?

In my current game I need to have two rendering cameras, one for all the distant scenery (stars, nebulae, etc) and one for the player's view from a spaceship. In a normal game I'd just use two cameras and be done with it, for Oculus should I be using 2 OVRCameraController objects? If so are there any settings I need to be aware of or change to handle having multiple controllers active?
    This topic has been closed for replies.

    20 replies

    Inspiring
    April 17, 2013
    Just to chime in here, The game I will be making will require the use of 2 cameras, 1 for the close scenery and one for the far, however the far scenery will include a very 'basic' terrain with some larger low detailed building meshes and a dynamic sky box. The detailed terrain and game meshes will then be placed over the top of the lower detailed and then I can bring in the far clip plain and kill any z-fighting issues, while still rendering distant scenery. A lot of games will require this functionality and it should really come as an easy to set up thing in the SDK
    "In the future we will be designing dreams, worlds & experiences rather than games."
    Inspiring
    April 25, 2013
    I actually started another thread on the same topic. Must have missed this one. :oops:

    You mentioned you might post your solution(specifically, option number 2 from your earlier post)

    did you have a Unity package you'd be willing to share? It'd be much appreciated as I'm not a programmer and can't get it working myself

    thanks
    rjeAuthor
    Inspiring
    April 25, 2013
    So I just updated to 0.2.1, and it broke my existing working setup. So here's what I had to change in the SDK to make it so I could use multiple OVRCameraControllers.

    Note that I make no representation that this is the 'correct' way to do anything, but it's working for me so I can actually release a build next week as intended.

    OVRCameraController:

    Added a static global:
    public static Quaternion GlobalSharedOrientation = Quaternion.identity;


    OVRCamera:

    At line 271, added:
    OVRCameraController.GlobalSharedOrientation = DirQ;

    At line 277 (right after the if depth == 0.0 block) added:
    else {
    CameraController.SetSharedOrientation(OVRCameraController.GlobalSharedOrientation);
    }


    I fully admit this is hacky and probably will get broken in the future. If any oculus folks have a better suggestion I'm up for trying it so I don't have to keep hacking the SDK in the future.
    Twitter : @rje Web : rjevans.net Youtube : My Channel
    sh0v0r
    Up and Coming
    June 6, 2013
    I need to do this also as I have clipping issues.

    The 1st OVRCameraControllerwill only see the World so I can increase the near clip size and eliminate ZFighting problems particularly with building shadow decals.

    I want to use the 2nd OVRCameraController to render my cockpit with a very small near clip so that objects very close to the camera don't get clipped i.e. looking down and seeing your body.

    Below is how I have configured each OVRControllers Cameras

    -World
    <OVRLensCorrection> Component Disabled on Both cameras see code change below
    Nearclip 1.0
    Farclip 1500
    Right Camera Depth = 0
    Left Camera Depth = 1
    Clear Flags Solid Color (I have a custom skybox solution)

    -Cockpit
    Nearclip 0.01
    Farclip 10
    Right Camera Depth = 2
    Left Camera Depth = 3
    Clear Flags Depth Only

    I changed these lines in OVRCameraController:ConfigureCamera()

    // Centre of lens correction
    if (camera.GetComponent<OVRLensCorrection>().enabled)
    {
    camera.GetComponent<OVRLensCorrection>()._Center.x = distOffset;
    ConfigureCameraLensCorrection(ref camera);
    }
    New Participant
    December 10, 2013
    "cybereality" wrote:
    I don't have a good answer to this right now, but it's something we can look to improve in the future.
    Participant
    December 18, 2013
    Anyone made any progress working with multiple cameras yet?

    I've been working on a similar scenario: one camera for world, and one camera for cockpit view as well as immediate surroundings.

    Without hacking the sdk my scene works. So I am worried perhaps I am taxing latency by having both cameras responding to headtracking movement, perhaps the world cam should adjust its rotation to match the cockpit camera's headtracking movements instead of having both cameras responding to tracking?


    World camera:

    Disabled lens correction
    right camera depth: 0
    left camera depth: 1
    Follow Orientation: Cockpit (My space ships transform)
    Enable Orientation: checked
    Prediction On: checked

    Left & Right world camera:
    Clear Flags: Solid Color
    Culling Mask: Space (name of the layer I am using for world assets)
    Rending Path: Forward


    Cockpit Camera:
    Enabled lens correction
    right camera depth: 2
    left camera depth: 3
    Follow Orientation: Cockpit (My space ships transform)
    Enable Orientation: checked
    Prediction On: checked

    Left & Right cockpit camera:
    Clear Flags: Depth Only
    Culling Mask: Mixed
    Rendering Path: Forward
    Participant
    February 18, 2014
    I need to get this working to fix some zfighting stuff and improve shadows, but having no luck.

    Have gone over this thread a number of times but can't seem to figure it out. I've copied your solution Sean as much as I can but I always seem to end up with some weird circle in the middle of my frame and/or depth/clearing issues.

    Am I turning off Lens Correction (the checkbox) on the OVRCameraController object, or disabling that script on each camera, or both?

    Has anything changed since these posts? Do I need that script that you've shared for this to work with the current version?

    Should one OVRCameraController be parented to another, or be separate?

    Thanks!
    Jay
    Inspiring
    February 18, 2014
    "JayExbleative" wrote:
    I need to get this working to fix some zfighting stuff and improve shadows, but having no luck.

    Have gone over this thread a number of times but can't seem to figure it out. I've copied your solution Sean as much as I can but I always seem to end up with some weird circle in the middle of my frame and/or depth/clearing issues.

    Am I turning off Lens Correction (the checkbox) on the OVRCameraController object, or disabling that script on each camera, or both?

    Has anything changed since these posts? Do I need that script that you've shared for this to work with the current version?

    Should one OVRCameraController be parented to another, or be separate?

    Thanks!
    Jay


    Only the last OVRCameraController that renders should have Lens Correction (and chromatic aberration correction) enabled. They can be separate so long as you've got the depths in the right order, but you should definitely make sure they are occupying the same point in space so maybe it would be best to have both OVRCameraControllers be siblings under the same parent.

    This weird circle in the middle of your frame sounds like you have your far clip plane turned down too low. If you're having trouble getting the far clip plane values on your OVRCameraControllers to stick, try going into each camera (CameraLeft/CameraRight) and explicitly setting them there too?
    Titans of Space PLUS for Quest is now available on DrashVR.com
    Participant
    February 18, 2014
    Only the last OVRCameraController that renders should have Lens Correction (and chromatic aberration correction) enabled.


    Thanks, how do I know which is the 'last to render'? Is this based on depth? Ie the close camera renders over the distance camera, therefore that's the last?

    I just figured out that the circle was due to a custom skybox solution - used a different one and its fixed.
    Inspiring
    February 18, 2014
    "JayExbleative" wrote:
    Only the last OVRCameraController that renders should have Lens Correction (and chromatic aberration correction) enabled.


    Thanks, how do I know which is the 'last to render'? Is this based on depth? Ie the close camera renders over the distance camera, therefore that's the last?


    Yep it's based on their depths. Every frame, all cameras are rendered from the smallest (most negative) depth to the highest (most positive) depth. If you do fiddle with the camera depths, make sure you start with depth = 0 for the first Rift camera to render as the current Unity integration is expecting that (and that's how it knows when to grab orientation from the Rift's sensors).
    Titans of Space PLUS for Quest is now available on DrashVR.com