Adjusting VR camera parameters

I’d like to play with adjusting individual VR camera parameters. That is, read and write access.
As a start, just IPD and FOV would be fine.
It’d also be nice to also get raw eye position and rotation, relative to the tracked head.

Is write access already exposed someplace that I’ve missed? Or, any plans to expose it?

Anybody been able to hack something similar into the Oculus SDK integration scripts?

Hopefully someone in the know will answer you, but as far as I can tell these options aren’t exposed in UnityEngine.VR as of right now.
You can try adjusting the fov on the Camera directly, but it seems Unity VR never stops setting the Camera’s fov it to whatever value it chose, so manually setting fov via script or dragging the slider in the inspector has no effect. It would be great if this was changed to be like the OVR plugin, where they set the fov once at startup and then you can play with it as you like - such as being able to fov-zoom, which is something I’d like to have word on.
It would also be nice to know where the second Camera is; right now all of my World GUIs that are attached to the camera are slightly to the left since I’m not sure where the center of the two Cameras is exactly. Speaking of which, in GearVR there seems to be considerable stutter in the movements of objects that are children of the camera, this doesn’t seem to be an issue with the Oculus Rift though. I considered it might be a performance issue, but even in an empty scene with just a couple things attached to the camera the latency and jumpiness is noticeable (again, for objects attached to the camera specifically, head movement still feels smooth).

Like Kevin said, the two above options are not exposed currently in UnityEngine.VR. However, we are using the values directly from the OculusConfig on the machine the application is running on. So the IPD and FOV will be set to what you have chosen as your IPD and FOV in your Oculus Configuration Utility.

As for getting the Eye Position and Rotation, Please read the documentation on Input tracking here: http://docs.unity3d.com/ScriptReference/VR.InputTracking.html

This will teach you how to get the position/rotation of the left, right, or center eye.

We do plan to expose more properties that the Oculus Legacy Plugin exposes but we currently do not. These should be coming out soon.

As for the jutter issue that you are seeing on GearVR, our QA team is looking into the issue and we have a bug report already filed on the issue.

I need the FOV and height resolution to calculate the minimum size of an object to prevent it from disappearing when it is smaller then one pixel. This might not sound like much but it is a showstopper in my application.

Please provide these variables, I really need them.

Thanks for the reply @Ed_unity , I totally overlooked VR.InputTracking for getting the eye position.
Also in regards to that jutter issue I spoke of, I put a FPS counter in the scene, and as I was sort of suspecting, the Samsung Galaxy S6 that I use with the GearVR appears to be capped at 60fps, which makes sense since it is a phone after all, and then even with my simple scene it drops to 50fps. So my particular issue with stutter is probably rooted from that. Hopefully once lightmapping gets back in shape on Android this problem will go away.

@Elecman , if you only need to get those variables they are exposed for grabbing. Fov just isn’t settable in the Unity Editor at the moment, you have to use the Rift config utility like Ed said.

So I have to ask my users to go into the rift config utility before starting the game, note those variables, then go to google, find out the resolution and not that too, then start my app, and plug in those variables?

@Elecman , I don’t think I understand your use case. As you probably know, if you need the Camera’s fov, you can get that from the Camera, if you need the Screen’s resolution you can get that from Screen; admittedly that screen resolution is probably not going to match up with the VR Eye’s resolution but I’m sure you can get the math going right with that.
If you need your users to set their own fov, then yes, right now they have to use the Oculus Configuration Utility before entering your game. Hopefully this functionality will be added to UnityVR very very soon.
If you need your users to enter in their own resolution, then you can at least fill it in with “default” values that you can calculate yourself.

When I got the FOV and resolution from the Camera component (and Screen), I got incorrect values. It probably fetches the values from the monitor instead.

Fov is read from Sensor. The value exposed on inspector is overwritten

Sigh.

@Elecman , you’re probably getting the fov too soon, UnityVR hasn’t set it yet. Here’s a script to show you what I mean, just attach the behavior to the main Camera in your scene and run it with your VR device plugged in.

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Camera))]
public class LogCameraFOV : MonoBehaviour {
    public const string    logPrefix    = "LogCameraFOV: ";

    private IEnumerator Start () {
        var camera    = GetComponent<Camera>();
        Debug.Log(logPrefix + " at Start(), " + camera.fieldOfView);
        yield return new WaitForFixedUpdate();
        Debug.Log(logPrefix + " at FixedUpdate(), " + camera.fieldOfView);
        yield return new WaitForEndOfFrame();
        Debug.Log(logPrefix + " at EndOfFrame, " + camera.fieldOfView);
    }
}

Hopefully it’s consistent and you should see 3 logs, and they’ll look like this:
LogCameraFOV: at Start(), 60
LogCameraFOV: at FixedUpdate(), 60
LogCameraFOV: at EndOfFrame, 106.1888
So you can see UnityVR doesn’t set it until sometime between FixedUpdate and the EndOfFrame.

As for your Screen resolution problem, if you’re using an Oculus Rift you know exactly what resolution that is, and if you’re using a GearVR then you can take that Screen resolution of the phone and probably just divide the width in half or something, I’ve never had to calculate it myself yet so I’m not 100% sure that’ll be perfectly accurate but it’s a decent starting place.

Edit: if EndOfFrame is too late, it appears to even be set before LateUpate()

Wow, thanks so much!

+1 for having cameras exposed. I need to set different visiblility settings for the two cameras :slight_smile:

+1
This is a huge blocker for us. We use Left/Right layers for Stereo Movie playback.

+1 for being able to adjust Camera Field of View once again with an Oculus Rift.
… and another +1 for being able to disable head tracking!

I can’t release my project without them. :stuck_out_tongue:

-1 for removing the support again in 5.6 :frowning:

1 Like

Is the FOV editable anymore? Really need to adjust my Unity camera’s FOV setting for our VR application to work. Using a GearVR + S7.