I am facing a very strange problem in my application. I display a 2D traingular grid in OpenGL using vertex arrays. Everything works very well, until I came across a case, where a grid to be displayed covered a large area 3500 sq. km. With this grid loaded, when I keep zooming in, I reach at a point where the smooth zooming stops, and the grid node point starts jumping. Basically, the value of the node remains same, but it appears to shift at consecutive zoom steps (steppy effect). I am not sure what is the actual term used for that, but probably, it may be related to the precision or format where there is no further division of pixels.
Can anyone guide me how to overcome this problem? Any links to solve this problem?
That is a precision problem. The coordinates of your vertices are represented with single-precision floating-point numbers. That means only cca 6 decimal digits are correct. The most elegant solution is to use local coordinate system located at the viewer’s position, not the grand fixed one.
First, let’s determine whether the grid is geometric or it is a texture-overlay. If it is a geometry, then the problem is in precision. If it is a texture then the problem is in resolution.
If you draw it as a geometry, where is the origin of the grid? Assuming it is in the lower left corner, you have an error of 1dm on the upper right corner of 60km long grid. That error cannot be seen until you zoom scene to proximately 100x50m on the full HD screen. If you zoom even further a jitter is becoming more apparent. In order to avoid jitter, you should generate grid from your focal point (where you are actually looking at), or to be more precise, snapped to the closest grid point.
Yes, I am drawing grid as a geometry. And the origin lies at the lower left corner. Well, I forgot to write one more thing. This problem comes not only for grid, but also when I display a set of points. If the points are very close to each other, then at the beginning it self I observe the steppy effect. I checked the coordinates, and as you said, only 6 decimal digits are considered.
You also mentioned in your post to generate grid from the focal point. I wonder, how to do this, because every time I do not generate a grid. Some times grid data is loaded from a file which can come from other source. Can you point me out to some literature or article to overcome this issue?
The problem of precision is common for all objects, not only your grid.
Yes, you need to regenerate the grid on each viewer’s motion (on translation only, not rotation) on such way that the vertex closest to the viewer have coordinates (0,0,0). It shouldn’t be an expensive operation.
Some useful remarks and references on rendering relative-to-eye (RTE) can be found in chapter 5 of the “3D Engine Design for Virtual Globes” book.