Search Unity

Floating Point Precision, what are my options?

Discussion in 'Editor & General Support' started by Gibbonuk, Feb 24, 2015.

  1. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    162
    Ok, for a while now I have been ignoring the visible jitter I am getting when my game object is getting further away from centre. Its been down on my "todo" list and thought there would be something relatively simple to solve it. So for the last day or two I have been googling, reading and trying but so far I've not really come to much.

    Im asking because a lot of what I read is old posts and so I was wondering (hoping) there might be some new super duper solution?

    My project is a simulator, currently I have a terrain split into 4 each 20000+ in size. (effectively) 50km x 50km.

    The main "player" is made up of around 6 game objects and relies on physics. When the camera is "not close to objects" as in 3rd person view its not that bad. The problem is, majority of the time its FPV when you can see hands and 2 - 3 other game objects and its these that start jittering at around 4000ui away from centre, at 8000+ it just looks terrible.

    So far all I have tried is the FloatingOrigin script although I thought this might only be a temp solution as my project is multiplayer and I'm not quite sure how this world work. However, I have tried this script and there is a significant transition when everything is re-positioned so this isn't a great solution.

    Is there any solutions that make this process a little easier and effective?

    I see an asset in the store where it chunks terrains and loads them in but I feel again how does this bare with multiplayer?

    Thanks
     
  2. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    162
    Just to update, I have had success with moving all my objects and any spawned objects into a global parent GO and then I calculate the distance of the player object from origin and then position the global parent GO to make the player object back to origin. It works quite well actually, the only issue I am having now is when the re-positioning happens, sometimes I get a flash of pink in the screen, like a pink square?

    What could be casuing this? There isnt anything in the scene but the terrain and the player and sky? and everything has materials and shaders on them?

    Thanks
    Andy
     
  3. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,288
    Pink usually means a shader is not found. Would be a bit odd to have it most of the time, and for it to disappear occasionally.
     
  4. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    162
    After more testing, the "the pink thing" only gets created when I "move" everything as I am doing to get over the floating point issue. If i disable the script that simply loops through object and repositions, it doesn't show?

    Whats even more strange is, the pink thing gets created and stays, if i pause the game and move around in editor it rotates with the camera like a plane? Even more strange again is i can't click on it, move it or associate it with any object in the hierarchy?

    Andy
     
  5. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    162
    Ok I have fixed the pink object, was being caused by another plugin I had installed.

    I do now have a strange issue that I'm sure someone could explain to me why is happening?

    The floating origin script (http://wiki.unity3d.com/index.php?title=Floating_Origin) here works but I my physics object seems to have quite an impact when the "re-positioning" happens. But what I have noticed is if I remove this line:

    Code (CSharp):
    1. cameraPosition.y = 0f;
    it works fine. However, I would rather it not reposition the height of everything, just the x & y positioning as the script is meant to do? Why would this make a different on the physics side of things?

    Thanks
    Andy
     
unityunity