Skip to main content
Inspiring
June 12, 2014

Zooming with the new SDK

I can imagine that the ability to zoom in a VR game is a sensitive topic, and likely to invite a "don't do that" / "violation of best practices", etc. As far as I can tell, users enjoy the zoom feature in Titans of Space, and Yosemite Spyglass made great use of it. Then you have something like Private Eye where the whole premise is looking through binoculars. I believe Desperate Gods also has an implementation of zoom as well, but I imagine positional tracking would render it obsolete in that particular case.

In the past, I accomplished this by smoothly adjusting the OVRCameraController's vertical FOV via SetVerticalFOV(), and this worked reasonably well as long as you're not zooming onto something that's very close to you.

In the newer SDK however, SetVerticalFOV() appears to have new behavior, where it simply changes the size of the "hole" through which the player can view the scene. Understandable, because the true rendered FOV is now internally calculated as a function of eye relief and other factors.

In addition, probably because it has to recalculate the distortion mesh every time something fundamental as the FOV is changed, this sort of smooth adjustment incurs a serious performance hit. In the video below, it goes from 125 FPS (capped at 60 in the video because of video capture software) down to 45-50 FPS when SetVerticalFOV() is being called every frame with a new value.




I suppose there are other options for zooming, such as moving the actual camera rig itself out along the line of sight but this breaks down if there's anything in the foreground that should be in the zoomed view, and in general it's really not the same since it also involves a change in perspective.

Any suggestions from other devs that have played with zooming and the new SDK, or even suggestions from the Oculus team on what the recommended approach should be going forward? Many thanks in advance!
    This topic has been closed for replies.

    33 replies

    Up and Coming
    July 25, 2014
    "drash" wrote:
    "Podden" wrote:
    You actually can change the depth of field of the OVRCamera, but you have to change it seperatly in the CameraRight and CameraLeft camera.fieldofview varibales instead of the OVRController.

    Thank you! :) It does seem like I'm getting the same effect as before just changing the camera FOV's directly -- thought the distortion params needed to be recalculated or something.


    Can't seem to get this working in 4.

    The variables are CameraRight AND CameraLeft with the variable camera.fieldofview not camera.fov? Both to change against the same reducing or increasing float or int?

    Are their any other parameters that need changing that I may have missed?? :roll:

    Cheers

    Unclebob
    Feel free to drop by.... http://www.VRCraftworks.com and contact us
    drashAuthor
    Inspiring
    July 26, 2014
    Hi unclebob, I got your PM but was unable to reply due to:
    "Some users couldn’t be added as they have disabled private message receipt."

    In any case, to answer your post here, camera.fieldOfView is the same as camera.fov except that the latter has been obsolete for a while, and might not be available anymore. And yes, you would need to change the FOV of both left/right cameras in tandem. I haven't tried this with 0.4 SDK yet though.
    Titans of Space PLUS for Quest is now available on DrashVR.com
    Inspiring
    July 26, 2014
    The 0.4.0 SDK no longer uses Camera.VerticalFOV for rendering. The FOV comes straight from the profile that you set in the OculusConfigUtil. To zoom, you will either have to render with another camera or dolly the OVRCameraController forward and backward.
    Up and Coming
    July 27, 2014
    "drash" wrote:
    Hi unclebob, I got your PM but was unable to reply due to:
    "Some users couldn’t be added as they have disabled private message receipt."

    In any case, to answer your post here, camera.fieldOfView is the same as camera.fov except that the latter has been obsolete for a while, and might not be available anymore. And yes, you would need to change the FOV of both left/right cameras in tandem. I haven't tried this with 0.4 SDK yet though.


    Thanks mate have changed the setting now in the user control panel.

    Will give the fov a go later tonight mate.

    Thanks

    Unclebob :)
    Feel free to drop by.... http://www.VRCraftworks.com and contact us
    Up and Coming
    July 27, 2014
    "vrdaveb" wrote:
    The 0.4.0 SDK no longer uses Camera.VerticalFOV for rendering. The FOV comes straight from the profile that you set in the OculusConfigUtil. To zoom, you will either have to render with another camera or dolly the OVRCameraController forward and backward.


    Thanks vrdaveb. Will look into this and let you know how it works. Dolly moves seem to induce motion sickness but different cue's may antidote that. Radial_G being a perfect example.

    Have a great weekend.

    Unclebob :)
    Feel free to drop by.... http://www.VRCraftworks.com and contact us
    Up and Coming
    July 27, 2014
    Ha ha

    put in the changes and realised that I need to reinstall the OVRService which crashes when detects the tracking camera.

    Oh well. :roll:

    Too much to do a quick fix and tryout.

    Will hit it tomorrow.

    Cheers

    Unclebob
    Feel free to drop by.... http://www.VRCraftworks.com and contact us
    Up and Coming
    August 5, 2014
    "unclebob" wrote:
    "vrdaveb" wrote:
    The 0.4.0 SDK no longer uses Camera.VerticalFOV for rendering. The FOV comes straight from the profile that you set in the OculusConfigUtil. To zoom, you will either have to render with another camera or dolly the OVRCameraController forward and backward.


    Thanks vrdaveb. Will look into this and let you know how it works. Dolly moves seem to induce motion sickness but different cue's may antidote that. Radial_G being a perfect example.

    Have a great weekend.

    Unclebob :)


    So using the different FOV and FieldOfView variables as expected don't work. So have been looking at some of the OVR scripts.

    Seems that the OVRCameraController.cs has this info

    // Using the calculated FOV, based on distortion parameters, yeilds the best results.
    // However, public functions will allow to override the FOV if desired
    VerticalFOV = CameraMain.GetComponent<OVRCamera>().GetIdealVFOV();


    Referencing OVRCamera.cs
    /// <summary>
    /// Call this in CameraController to set up the ideal FOV as
    /// defined by the SDK
    /// </summary>
    /// <returns>The ideal FOV.</returns>
    public float GetIdealVFOV()
    {
    int resH = 0; int resV = 0; float fovH = 0; float fovV = 0;
    OVRDevice.GetImageInfo(ref resH, ref resV, ref fovH, ref fovV);

    return fovV;
    }


    Not that comfortable "override the FOV if desired" as suggested by Oculus in their script so will throw this back as a support question as I would not want to "break" anything.

    If anyone has any other suggestions???

    Cheers
    Feel free to drop by.... http://www.VRCraftworks.com and contact us
    New Participant
    August 6, 2014
    (edit : I suggest you ignore the musings here and go straight to "edit 2" at the bottom where I found & fixed the problem)

    Hmm, even if they mention that GetIdealVFOV() being public allows it to be overrided, that's not really the case, is it? It's not virtual, so it can't be overrided by an inheritor. I can shadow it with a

    	public new float GetIdealVFOV()
    {
    return myFOV;

    //return base.GetIdealVFOV();
    }


    But that's not super pretty. It should work, though.

    Edit : That doesn't work, shadowed functions don't get called via polymorphism like overridden function would.
    Anyway that's beside the point, because calling SetVerticalFOV() changes the FOV on the camera directly, and that doesn't work either in 0.4.0, so it looks like a bug that's rooted deeper.

    As an aside, there are two "code typos" in OVRCameraController, the setters for the IPD and VerticalFOV properties don't set the right dirty flag, they should be setting UpdateCamerasDirtyFlag but they set UpdateDistortionDirtyFlag... :(

    Edit 2 : Ah ha! Found the culprit. The fieldOfView of the camera isn't actually used when building the projection matrix... If you go to line 384 of OVRCameraController, it calls OVRDevice.GetCameraProjection() and does not supply any information about the FOV that you want.

    If you replace that line with :
    OVRDevice.GetCameraProjection(cam.EyeId, NearClipPlane, FarClipPlane, camera.fieldOfView, camera.aspect, ref camMat);


    And then change that function in OVRDevice (line 343 and onwards) with this one :
    	public static bool GetCameraProjection(int eyeId, float nearClip, float farClip, float vFOV, float aspect, ref Matrix4x4 mat)
    {
    if (HMD == null || !SupportedPlatform)
    return false;

    float tanHalfVerticalFov = Mathf.Tan(Mathf.Deg2Rad * vFOV / 2);
    float tanHalfHorizontalFov = Mathf.Tan(Mathf.Deg2Rad * vFOV / 2 * aspect);
    var fov = new ovrFovPort
    {
    DownTan = tanHalfVerticalFov,
    UpTan = tanHalfVerticalFov,
    LeftTan = tanHalfHorizontalFov,
    RightTan = tanHalfHorizontalFov
    };
    mat = Hmd.GetProjection(fov, nearClip, farClip, true).ToMatrix4x4();

    return true;
    }


    And zooming using the FOV works! :D
    Up and Coming
    August 6, 2014
    "renaudbedard" wrote:
    (edit : I suggest you ignore the musings here and go straight to "edit 2" at the bottom where I found & fixed the problem)
    And zooming using the FOV works! :D


    Superb work sir.

    renaudbedard, I doff my hat and throw you a salute of respect.

    Let me know if you are in London or down in Brighton.

    Beers on me. 8-)

    Cheers

    Unclebob
    Feel free to drop by.... http://www.VRCraftworks.com and contact us
    Up and Coming
    August 6, 2014
    Hi guys

    can confirm that the above works really well with no unwanted side effects yet.

    You have to use the following variable on BOTH cameras.

    cameraleft/right camera.fieldOfView as a float, obvioulsy.

    Simples.

    Cheers Unclebob :D
    Feel free to drop by.... http://www.VRCraftworks.com and contact us