Draw a world map [WGS84] with OpenGL in a wide range

I want to draw a map consisting of 256x256 pixel tiles (many of them). They cover a large area.

Convert to convert lat | lon (from the globe) at x | y (map) produces quite large values. With these large values ​​it goes exactly, and therefore, if I go far from Point 0/0, I get inaccuracies of several pixels between the textures of two Tiles that are next to each other (for example, 2E8 | 0 and 2E8-1 | 0).

How can I fix these messy unwanted grids? The current unsuccessful implementation is to use float to draw primitives (this does not matter, since all Tiles are cropped to a multiple of 256 in both directions).

Note. I allready tried to use glTranslated for offset, but either double precision is not enough either, or this is not the cause of the glitches.

+3
source share
1 answer

In fact, I recently encountered the same problem in my implementation of rendering entire planets from space to earth. In fact, you need to create a new position structure that shares accuracy between different floats. For instance,

struct location
{
     vec3 metre;
     vec3 megametre;
     vec3 terametre;
     vec3 examtre;
     vec3 yottametre;
};

Then you code all the operators and enter the translation functions for this structure (+, -, *, /, toVec3), then use this location structure to encode the location of your camera and each grid. During rendering, you do not translate the camera, but instead you translate fragments by difference. For instance:

void render()
{
     // ...
     location diff = this->position - camera.position;
     vec3 diffvec = diff.toVec3();
     glPushMatrix();
     glTranslatef(diffvec.x, diffvec.y, diffvec.z);

     // render the tile
     glPopMatrix();
}

, OpenGL, , . , . O/p >

.

+4

Source: https://habr.com/ru/post/1730941/


All Articles