Search Unity

possible to scale camera & tracking rather than scaling the world?

Discussion in 'AR/VR (XR) Discussion' started by JoeStrout, Jun 5, 2020.

  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Suppose in real life you are 2 m tall. When you crouch, your head moves about 1 m. If your character in VR is also 2 m tall, then it can crouch the same amount and everything's fine. But what if your character is 0.5 m tall? Moving the head by 1 m would put it through the floor. Or, if your character is 10 m tall, then you'd hardly be able to move its head at all.

    The obvious solution is to keep your avatar exactly 2 m tall, and scale the world to make you appear to be 0.5 m or 10 m tall. But that gets very thorny in a networked game, where we're syncing world positions of transforms with the server and other clients.

    Is there any way to instead scale (1) the tracking of the head and hands, and (2) the stereo separation of the eyes? If you could do this then it would have exactly the same effect as scaling the world (i.e. make you appear larger or smaller than your real size), but be dramatically easier to manage.

    (I found Camera.stereoSeparation, but the docs note that setting this has no effect on most platforms.)
     
  2. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,932
    I haven't tried this recently, but I looked into similar issue with Oculus Rift DK1/2 (yes, that long ago!) and Unity 5, and a couple of observations (That still hold true):

    1. A lot of core Unity is broken in bad ways when it comes to scale. Many many Unity employees have written code where they "forgot" about the .scale variable on GameObject.transform, and so as soon as you use non-uniform scales you start running into some seriously wierd bugs. It's no coincidence that instead of scaling a BoxCollider they built a whole CUSTOM SIZING CONTROL (just so you don't scale it!) and embedded that into the core Inspector ;).

    2. So: you want to do everything in your power to keep scales at 1/1/1, or to only scale limited things, and never a whole object-hierarchy.

    3. Zooming forwards to 2020, and the XR system / XRIT ... I'd start by looking at TrackedPoseDriver's source code, and seeing if I could hook into it and apply a constant multiplying factor on the reported distances / change in distance. That way all scales in the engine remain 1.1.1, but you get to scale the input/tracking.

    (but overall: Unity in general just can't handle non-1 scales. The kernel of the engine itself is fine, it's perfect, it does exactly what it's supposed to - but that means it exposes all the many bugs in Unity API and Editor code where people only tested with 1/1/1 scales and then shipped their changes into live Unity. Debugging those is a nightmare, and you don't want to go there. It's no-one's fault, but you're fighting literally 15 years (!) of bugs if you try and do this, so it's best to do everything in your power to avoid non-1.1.1 scales)

    PS: for the record - yes, I have logged these bugs over the years, generally the most extreme/simple ones, and most of them have eventually been fixed. But there are some that have been ignored/rejected as being too difficult to fix, so the best thing is to accept that and stick to 1/1/1 :).

    PPS: I also made the same mistake myself. Back in 2013-2016 I used to often forget to test new code with non-unifrom scale, and got caught out if I ever scaled things - weird bugs appeared in my code. But these days it's one fo the first things I test everytime I write anything that accesses "transform.[anything]".
     
  3. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Think wrong perception of scale in vr is more a matter of calibrating the headset. If the headset is trying to squeeze in to much FoV in to small displays, and lenses, everything will appear smaller. It´s the same effect when wearing glasses to compensate for near, of farsightedness. They can also make the world look smaller, or bigger to you.

    I think scaling of movement in roll, pitch, and yaw aren't necessary. Perhaps you would like to scale the real world movement to simulate shorter, or longer legs making you walk faster, or slower. Or put the hands closer or further away to mimic the length of your arms, or your head higher, or lower above the ground, in other words what you was asking for. Think Google Daydream had settings to tweak the arm length to the GvrController, not sure how it´s done for other headsets.
     
    Last edited: Jun 6, 2020