Skip to main content
Up and Coming
August 24, 2013

Can't change OVRCameraController backgr. color or clipping?

OVRCameraController (and the 2 child cameras) defaults to a blue background color, which I need to change to black.

Following the PDF docs, I change the color in the OVRCameraController. (This is Unity 4.2 and OVR SDK 0.2.4.)

But when I hit Play, it reverts to blue. (If I also change the colors for the 2 individual cameras, one of them reverts to blue but not the other.)

When I hit Stop, the blue remains, even though Unity playback shouldn't normally permanently affect Inspector values.

EDIT: Same for near clip and far clip; the editor shows my values, even after a quit and reload--until I hit Play. Then they revert to defaults, and stay there even after I Stop.

I'm going to modify the OVR code to try to override this, but it's a hacky approach. What's the right way to do change settings for OVRCameraController and its child cameras?

EDIT 2: I have added [SerializeField] in a few places to help (I'm a JavaScript guy, not C#, but I found that tip here for clipping planes). And it works--the settings stick. But...

- Is there a way to just use those settings as explained in the PDF, without modding the OVR scripts? I worry that my changes will be lost with new SDKs if that's the way to do it. (I'm at least leaving my name in comments to find those lines again.)

- My chosen clipping planes work when I Play in the editor--but are ignored in an actual build. Probably a bug--looks pretty bad (you can see your own body sliced off at the chest, hollow legs and all, when you look down). Then, after the build (even if I quit and reload) the clip values stop working in editor play too; but when I click on the OVRCameraController to check the values, my own values are still shown (not reverted). And then when I Play again, the editor clipping is fine once again. It's as though Build temporarily reverts to default clipping values, and a simple click t select OVRCameraController is enough to resolve the problem--but only in the editor, not in the executable.

Any workarounds to make a Build use my clipping values? (I haven't tried hard-coding them into the C#... hacky and not future-proof, but I'll try it if I can find where to do it.)

Thanks for any ideas!
    This topic has been closed for replies.

    21 replies

    Up and Coming
    November 20, 2013
    I posted a fix for the clipping plane issue a while back. You just have to modify the ConfigureCamera method:
    bool ConfigureCamera(ref Camera camera, float distOffset, float perspOffset, float eyePositionOffset)
    {
    Vector3 PerspOffset = Vector3.zero;
    Vector3 EyePosition = EyeCenterPosition;

    // Vertical FOV
    camera.fieldOfView = VerticalFOV;

    // Aspect ratio
    camera.aspect = AspectRatio;

    // Centre of lens correction
    camera.GetComponent<OVRLensCorrection>()._Center.x = distOffset;
    ConfigureCameraLensCorrection(ref camera);

    // Clip Planes
    camera.nearClipPlane = NearClipPlane;
    camera.farClipPlane = FarClipPlane;

    // Perspective offset for image
    PerspOffset.x = perspOffset;
    camera.GetComponent<OVRCamera>().SetPerspectiveOffset(ref PerspOffset);

    // Set camera variables that pertain to the neck and eye position
    // NOTE: We will want to add a scale vlue here in the event that the player
    // grows or shrinks in the world. This keeps head modelling behaviour
    // accurate
    camera.GetComponent<OVRCamera>().NeckPosition = NeckPosition;
    EyePosition.x = eyePositionOffset;

    camera.GetComponent<OVRCamera>().EyePosition = EyePosition;

    // Background color
    camera.backgroundColor = BackgroundColor;

    return true;
    }