Far away from 0,0,0


I’ve heard that OpenGL’s calculation is unprecise when it comes to geometry that is placed far away from 0,0,0.

My question is, in what radius from 0,0,0 is it “safe” to deal with geometry.

There is really no general answer to that, it heavily depends on your geomentry.

I don’t know for sure what format most hardware manufacturers use for internal geometry representation but for demonstration purposes lets assume it is 32 bit IEEE float.

This format uses a 23 bit mantissa, so you have a precision of 1/2^23, that is 1/8388608. So when you are 8388608.0 units away from the origin, the smallest distance that can be represented is 1.0, when you are only 83.88608 away, the smallest distance that can be represented is 0.00001.

In practical application this isn’t a problem, because when your objects are very large they usually have no very small details, because they would not be visible anyway.

Thanks for the reply.

What about if you have a geometry(10 units hight, width and deep), modelled in origo, and translate it 8388608.0 units away?

Would it be the same problem?


In theory, yes, you would get precision problems if you do that.

But if you have a cube of 10 units size that is 8388608.0 units away from the camera (after modelview transformation the camera is in the origin), it would be a lot smaller than a pixel, so you can’t see the precision problems…