I’m really embarassed by a strange effect I’m getting with my OpenGL scene.
The scene contents is really simple: it’s a box with side length = 1.0. If I just draw the box, everything is fine - see the first snapshot below.
But what I need is slightly different. The box should be located at point (1e+6, 1e+6, 0.), not at the WCS origin. Actually the vertex coordinates come from an external file, so they are translated already by the above-mentioned values, and I just need to move the view CS so that the box is inside the viewing volume.
The result is shown on the second snapshot.
Obviously, the vertex coordinates are corrupted. It becomes even more obvious when I rotate the model: vertices do not move smoothly, they “jumps” in the scene as if they were snapped to some invisible “grid” with some rough step.
The first idea that came to my mind is that the coordinates are large (about 1e+6) and after applying the translation to “move” the box into the viewing volume there are some round-up errors. Does my idea have any connection to the OpenGL reality?
What is the internal representation of vertex coordinates? Is it usually a 4-byte float? Is it hardware-dependent?
But I was really surprised when I imported the file with the box into the third-party 3D modeler that was used to build the model…and the system displayed it correctly!
If I’m right and some loss of precision takes place, how can I manage this to make the box look fine in my application? Note that I have to draw the model coming from a file “as is”, I cannot recalculate its geometry to shift it back to WCS origin.
Otherwise, what might be the potential reasons for this effect?
Thank you a lot in advance for hints!