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

floating point imprecision at normal positions

Discussion in 'Editor & General Support' started by ObliviousHarmony, Dec 18, 2015.

  1. ObliviousHarmony

    ObliviousHarmony

    Joined:
    Jul 3, 2014
    Posts:
    79
    Hello,

    I'm currently on 5.3.1f1, and experiencing a pretty nasty bug. The best demonstration of it is this: http://upload.obliviousharmony.com/files/2015-12-18_11-53-46.mp4

    The first part is Unity 4.5 (oldest I have, sorry!), and the second part is the latest version. I found that this was the simplest way to demonstrate the issue I'm encountering, but it occurs with everything. My animated meshes jitter themselves apart, and even at 500 units my meshes jitter quite unfortunately. I tried making a new project, as well as installing on another computer and encountered the same issue.

    It also happens in a standalone build. I filed a bug report on it, but I thought I'd post here as well.

    Edit: Case number is 755486
     
    Last edited: Dec 18, 2015
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    What is exactly wrong in that video? You move the editor point of view, everything in the scene moves... it looks right to me. Am I missing something?
     
  3. Giometric

    Giometric

    Joined:
    Dec 20, 2011
    Posts:
    170
    The framerate of the video is too low to make out the effect well, but ny's talking about how in Unity 5 the movement of the scene view panning is a bit more jittery.

    I don't know why it would be different between Unity 4 and 5 (maybe some difference in how the units are being calculated internally for the scene view?), but your camera is out at 5000 units in Z, not 500. At that distance, I'm not surprised to see some jitter in the movement.

    One thing that may be contributing is scale values. If you've got objects that are scaled to be very small or very large, you lose precision right out of the gate, and you'll get jittering at much shorter distances than with an object scaled at or close to 1.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    You get about six or seven decimal digits of precision with floating point. That's not much. If you start scaling things, that gets used up fast. That's why you want to always stay "normalized" around the zero point, if at all possible.

    That's one of the things that makes implementing a crazy telephoto sniper lens in video games difficult: precision placement of far distant objects is impossible unless you go to double precision. Not to pick on Battlefield 1943 but when you looked through the sniper rifles you could clearly see other moving units floating above the ground. I'm guessing it was related to precision.
     
  5. ObliviousHarmony

    ObliviousHarmony

    Joined:
    Jul 3, 2014
    Posts:
    79
    Hello,

    To clarify a few points, it's worth noting that my character and the world are not of abnormal scale. To demonstrate what effect this has on a practical use-case, here is my character: http://upload.obliviousharmony.com/files/2015-12-18_10-40-09.mp4 You will note that he is shaking. Initially, I had thought this was an issue with the animation. After ruling that and a few other cases out, the only remaining cause was floating point imprecision.

    My reason for the initial video was to demonstrate that in Unity 4.5 I did not encounter the same behaviour. When I use the pan and move my mouse in a straight line, the camera is very shaky and jumps around. This is very telling of the aforementioned issue, and as improbable as it might be, it's seemingly what I'm experiencing.

    As a final point; I am only using 5km to increase the visible impact the issue has. It is much less pronounced at smaller positions, but still present enough to cause visible issue with the game. Pay close attention to the lower-left portion of the arm: http://upload.obliviousharmony.com/files/2015-12-18_10-34-06.mp4 Even at 500m, it begins shaking in a way that makes the game look bad.