3

Right now I am building an application in OpenGL. The application maps a spherical Earth texture map to a polygon approximating a sphere. When I use any of the sphere textures such as from http://planetpixelemporium.com, the map fits neatly and latitude and longitude values returned are accurate. However I am unable to successfully map a image created from QGIS to the sphere. The map appears slanted to one side.

I assumed this was because the spherical textures are different from the images produced by QGIS. Now using QGIS and https://www.naturalearthdata.com/ for maps would be a great asset for my project.

Is there a way to map this into the texture format that fits my OpenGL sphere?

Update: The map created in QGIS can be applied the Miller Cylindrical Projection. This allows mapping of the natural earth data (which is quite good) to an OpenGL texture map (according to my code). However this map becomes increasingly inaccurate as the poles are approached with respect to latitude.

If any one has any other suggestions, I'm still working on a better solution.

5
  • What format are the "sphere texture" files in?
    – csk
    Commented Apr 4, 2019 at 18:41
  • "These maps are simple cylindrical projections, designed to be applied to spheres using spherical projection. If you use any other projection method, the map will appear distorted on the final product." - planetpixelemporium.com/planets.html
    – csk
    Commented Apr 4, 2019 at 19:18
  • That's just it. I don't know. The type of files, planetpixelemporium.com/earth.html, map accurately to my sphere in OpenGL. The images I produce in QGIS however map in some slanted orientation. The latitude maps correctly but not the longitude. Here I am assuming their is some special process to making spherical texture for OpenGL and I want to know how. Commented Apr 4, 2019 at 19:19
  • So I applied Sphere_Miller_Cylindrical for a coordinate reference system and I got some luck. It is not quite as accurate as the mapping from the site. There cylindrical map was probably chose because it fits a sphere nicely. With what I am using, the latitudes become less accurate as they approach the poles. Commented Apr 4, 2019 at 20:11
  • If your issue is fixed, feel free to post the solution as an answer to help other site visitors with the same issue. If you're not quite satisfied and hope for more help, please update (edit) your question with the information you just mentioned, so others can understand the full question without having to mine the comments for information. Good luck.
    – csk
    Commented Apr 4, 2019 at 20:28

1 Answer 1

2

I ran into the same problem (it's now 5 years later) and figured it out:

  1. You want the World_Plate_Carree projection (in QGIS, under CRS > Projected > Equidistant Cylindrical). This will match the projection of the maps at http://planetpixelemporium.com, or most sphere textures in game software, e.g. Unity. This makes meridians vertical and circles of latitude horizontal, leaving you with square subdivision. More context and illustration here: https://en.wikipedia.org/wiki/Equirectangular_projection

  2. You need to export a viewport that's 2:1 (width:height) to match the number of parallel/meridian "squares" and capture the full globe. In QGIS 3.36, I did this with:

  • Project > Import/Export > Export map to image
  • Calculate extents from an OpenStreeMap layer: this gives you the right width
  • Increase the height manually to be half the width: this will pad the image to properly cover the poles

With these settings, my exported images match the earth textures I found quite exactly.

Last hurdle to render this properly in Unity: low resolution spheres still have UV distortion at the poles, see here for workarounds:

Not the answer you're looking for? Browse other questions tagged or ask your own question.