Hacker News new | ask | show | jobs
by TT-392 1345 days ago
Feels kinda weird to be using a data type that gets less precise, the further you move out from the center. Unless the world is infinite (which it sometimes is), isn't it a bit of a waste of precision? I kinda doubt you need nanometer precision, but only within 1 meter from the center. I get that gpus have existing floating point hardware to accelerate stuff. But with more open worlds being a thing. Wouldn't it make sense to include some new, big, floating point data type in hardware / emulate it in software?
2 comments

Or like, I guess a 64 bit int would probably do the job
All those annoying trig functions get in the way since they're implemented for floats/doubles.
No reason you can't have intermediate int's. And if there's some nearby frame to do calculations against then you don't get the loss of precision.
Integer definitely seems like the right fit here. The precision is translationally invariant, which is the property you want for a Cartesian coordinate system.
Depends on what you want. If you're rendering a 3D world (with perspective projection) and use a coordinate system where the camera is always at the origin or close to it (floating origin), then floats give you more precision where it matters (objects close to the camera) and less precision where it doesn't (faraway objects).
But if you're doing it that way, why would you need higher precision floats to render a larger world? Single precision should be good enough for any draw distance, because the object dimension on the screen falls as 1/r.

If you want to move in the environment, you want to be able to store the relative positions of a teacup and a table in virtual London with the same precision as in virtual New York. So the coordinates of objects should be stored as integers. Then to render the world, the camera coordinate (also an integer) is subtracted from all objects, with no loss of precision, and the result cast to float for 3D rendering.

As seen in their video (the fact that movement is choppy, but not the rendering. Indicates they are already doing that