Forum Discussion

rolsct's avatar
rolsct
Honored Guest
11 years ago

Setting IPD in code ?

Hi there,

Found nothing about this on the forum, so excuse me if this question has already been answered.

For my custom needs, I cannot rely on the users management provided by the OVR config tool, and I have to override this behavior, so that I can set the IPD from somewhere else (by code, either directly from my Unity application, or from another application).

Is there any proper way to do this ? (by setting up a registry key, or modifying a config file before running my VR application ?)

Thanks,
Roland Tomczak

4 Replies

  • You should be able to update the user profile's IPD in the current process by calling
    OVRManager.capiHmd.SetFloat(Ovr.Hmd.OVR_KEY_IPD, newIpd);
  • rolsct's avatar
    rolsct
    Honored Guest
    Hum.. I must have missed something !
    But the somewhat simple sequence

    float newIpd = 0.068f;
    OVRManager.capiHmd.SetFloat(Ovr.Hmd.OVR_KEY_IPD, newIpd);
    var refFloat = OVRManager.capiHmd.GetFloat(Ovr.Hmd.OVR_KEY_IPD, DEFAULT_IPD);

    doesn't returns my custom IPD, but the one being registered in the Oculus config profil.

    So, I cannot be really sure that the custom IPD is taken in account. Am I missing something ? I tried to set up this snippet at different places (before the OVR prefab is instantiated, before the Menu component is instantiated, OnUpdate, etc..), it doesn't seem to have any impact.

    Thank you !

    Rolsct
  • Sorry, it turns out OVR_KEY_IPD is read-only. So you will have to restart the app with a different user profile to change it. So OVRCameraRig doesn't support custom IPDs. You can write your own camera behavior and add a handler to the OVRCameraRig.UpdatedAnchors event to override ours.