Announcement

Collapse
No announcement yet.

Double-Precision "Huge Worlds" In Unigine

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #11
    Originally posted by mirv View Post
    Problem with fixed-point arithmetic is the discrete nature of the results - what if your physics moves an object sub-millimetre, or sub-metre, or whatever your scaling system is? So you'll need extra fixed point places to handle that. And then some more for object to screen space conversion, and suddenly your range isn't as large as it was before, and if your data set is within floating point tolerance, you may as well use floats anyway.
    floats are just as discrete as ints. there are just as many 32bit float values as there are 32bit int values (2^32). the difference is that the float values are clustered near zero, and the int values are evenly spread over the range.

    in float if you are at position 10 km, and you try to move 1 mm then you have 1.000000e5 m + 1.000000e-3 m -> 1.000000e5 m, you can't move, because you step size is smaller than the precision.

    with int you have 10000000 mm + 1 mm -> 10000001 mm. if you need 0.1mm accuracy then you use 0.1mm as you base unit.

    i can't see the benefit of being able to describe a tiny movement if you can't add or subtract it to a location.

    Comment


    • #12
      Originally posted by ssam View Post
      floats are just as discrete as ints. there are just as many 32bit float values as there are 32bit int values (2^32). the difference is that the float values are clustered near zero, and the int values are evenly spread over the range.
      Read up on IEEE floating point definitions. Floats are well suited to a 0.0 - 1.0 range, but it's better to say that they're well suited to a "range with given precision" (whatever it is depends upon the numbers you're using).

      in float if you are at position 10 km, and you try to move 1 mm then you have 1.000000e5 m + 1.000000e-3 m -> 1.000000e5 m, you can't move, because you step size is smaller than the precision.

      with int you have 10000000 mm + 1 mm -> 10000001 mm. if you need 0.1mm accuracy then you use 0.1mm as you base unit.

      i can't see the benefit of being able to describe a tiny movement if you can't add or subtract it to a location.
      Hence the topic of this thread about double precision. The example you gave about accuracy applies equally to fixed point math. With a floating point value, however, imagine flying from the moon to earth - your scale will vary considerably, and floating point will handle the transitions much more gracefully than using fixed point.

      Comment


      • #13
        if you go to 64bit ints you will do even better. as the solar system is mentioned in article.
        resolution at the moon (with earth at center)
        32 float: 4 m
        32 int: 9 cm
        64 float : 40 nm
        64 int: 21 pm

        the resolution at pluto (assuming you put the zero at the sun).
        32 float: 70 km
        32 int: 1.8 km
        64 float : 0.7 mm
        64 int: 0.3 mu m

        Comment


        • #14
          Since GPUs implement floating point and not integer arithmetic, you can't really use that. Though I think there's talk about fixed point arithmetic in future GPUs, not sure.

          Also, it's easier to work with floating point (which is probably why it's used) since it allows you to perform calculations between numbers of different magnitudes without much fuss.

          Comment


          • #15
            Originally posted by ssam View Post
            if you go to 64bit ints you will do even better. as the solar system is mentioned in article.
            resolution at the moon (with earth at center)
            32 float: 4 m
            32 int: 9 cm
            64 float : 40 nm
            64 int: 21 pm

            the resolution at pluto (assuming you put the zero at the sun).
            32 float: 70 km
            32 int: 1.8 km
            64 float : 0.7 mm
            64 int: 0.3 mu m
            Minus one bit for sign.
            Minus some bits for sub-resolution (from both physics and perspective calculations, it's needed, not to mention rounding errors).
            Now normalise it against screen space.
            Also add in Alpha Centauri (perhaps too far, but the point is that though you might not be able to do any meaningful transformation to its co-ordinates because of precision, they can still be represented).
            It's the dynamic range, as I previously noted, that makes floats desirable over fixed point.

            Comment

            Working...
            X