Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Adjusting VR camera parameters

Discussion in 'AR/VR (XR) Discussion' started by Hanaper, Jun 22, 2015.

  1. Hanaper

    Hanaper

    Joined:
    Jun 22, 2015
    Posts:
    1
    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?
     
  2. Kevin.Ferravanti

    Kevin.Ferravanti

    Joined:
    Aug 31, 2012
    Posts:
    18
    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).
     
  3. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    303
    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.
     
  4. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
    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.
     
  5. Kevin.Ferravanti

    Kevin.Ferravanti

    Joined:
    Aug 31, 2012
    Posts:
    18
    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.
     
  6. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
    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?
     
  7. Kevin.Ferravanti

    Kevin.Ferravanti

    Joined:
    Aug 31, 2012
    Posts:
    18
    @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.
     
  8. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
    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.
     
  9. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Fov is read from Sensor. The value exposed on inspector is overwritten
     
  10. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
  11. Kevin.Ferravanti

    Kevin.Ferravanti

    Joined:
    Aug 31, 2012
    Posts:
    18
    @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.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. [RequireComponent(typeof(Camera))]
    5. public class LogCameraFOV : MonoBehaviour {
    6.     public const string    logPrefix    = "LogCameraFOV: ";
    7.  
    8.     private IEnumerator Start () {
    9.         var camera    = GetComponent<Camera>();
    10.         Debug.Log(logPrefix + " at Start(), " + camera.fieldOfView);
    11.         yield return new WaitForFixedUpdate();
    12.         Debug.Log(logPrefix + " at FixedUpdate(), " + camera.fieldOfView);
    13.         yield return new WaitForEndOfFrame();
    14.         Debug.Log(logPrefix + " at EndOfFrame, " + camera.fieldOfView);
    15.     }
    16. }
    17.  
    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()
     
    Last edited: Jun 26, 2015
  12. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
    Wow, thanks so much!
     
  13. XeviaN360

    XeviaN360

    Joined:
    Jun 3, 2010
    Posts:
    181
    +1 for having cameras exposed. I need to set different visiblility settings for the two cameras :)
     
  14. BradHerman

    BradHerman

    Joined:
    Jan 10, 2013
    Posts:
    21
    +1
    This is a huge blocker for us. We use Left/Right layers for Stereo Movie playback.
     
  15. kideternal

    kideternal

    Joined:
    Nov 20, 2014
    Posts:
    82
    +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. :p
     
  16. TOES2

    TOES2

    Joined:
    May 20, 2013
    Posts:
    135
    -1 for removing the support again in 5.6 :(
     
    EyePD likes this.
  17. info-360-vid-ca

    info-360-vid-ca

    Joined:
    Jul 31, 2017
    Posts:
    3
    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.