4

I've got currently no solution for texture mapping an icosahedron without a seam from pole to pole. The texture mapping of this primitive seems to be a common problem, which is not completely solved yet. I've made a lot of research and I've tried a lot of different approaches for generating the uv coordinates, the most nearby ( and smallest ) approach is this:

GLfloat u = 0.5f * ( 1.0f + atan2( z , x ) * ( 1 / M_PI ));  
GLfloat v = acos( y ) * ( 1 / M_PI );

An icosahedron or geosphere is part of various open-source frameworks, such as jMonkeyEngine or Geist3D but none of the implementations seems to work correctly. It should be not impossible to map an unfolded rectangular texture or am I wrong? Every code snippet is welcome.

I've uploaded the Xcode project here which is built with openFrameworks 0.61 for iPhone. There are also two PNG files inside, each of them shows another seam variation.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Stephan
  • 43
  • 1
  • 3

3 Answers3

3

You need to change your texture image, the texture image you have is a distortion of the sphere where the pole is stretched into a line, you will never be able to map this properly to an icosahedron, in order to do so you would need a division more like the longitude and latitude system which such a distortion comes from. Instead you need a texture image where the pole is broken up into several distinct points. You can see this on some world maps where they try to minimize the distortion from mapping a sphere onto a flat surface. e.g. http://www.planetaryvisions.com/Project.php?pid=2236

You can find some good info on different ways to texture a sphere at http://www.vterrain.org/Textures/spherical.html

wich
  • 16,709
  • 6
  • 47
  • 72
  • Thank you wich for your quick reply. Please take a look at this: http://projects.stephanschulz.com/assets/Geosphere.swf This is geosphere created with a Flash framework called Alternativa3D. I've used the same texture and mapped it on the geosphere primitive. Except for one triangle on the north pole, the texture seems to be correctly wrapped around the polyhedra. Don't know how they achieve it, Alternativa3D is not opensource, but it seems to be possible somehow. Here is the source http://projects.stephanschulz.com/assets/geosphere.zip – Stephan Jan 15 '11 at 16:33
  • possibly the faces surrounding the poles could be quads with two incident vertices, but I still think that a proper texture image for an icosahedron would be far preferential. – wich Jan 15 '11 at 16:39
  • Sure, but icosahedral textures are rare and there is no mapserver providing this format. The application is supposed to visualize mapdata e.g. from civicmaps without any trouble at the poles, which is not possible with a stacks and slices based sphere. I think this is the advance of using a geosphere. How would you handle this? – Stephan Jan 15 '11 at 17:04
  • well, you should be able to generate an icosahedral texture from a basic map. – wich Jan 15 '11 at 17:14
  • Do you know any examples or literature dealing with this? – Stephan Jan 15 '11 at 17:18
  • http://www.vterrain.org/Textures/spherical.html mentions "this is now implemented in the VTP software, a pre-processing utility projects a conventional earth texture map onto 20 faces (10 square texture maps)" – wich Jan 15 '11 at 17:42
3

Surface of icosahedron has a topology of a sphere. Surface of a 2D texture has a topology of a plane. There exist no diffeomorphism between sphere and plane. That is, there is no mapping without stretches and tears between 2D texture and icosahedron surface.

However, there is a mapping between a cubemap and an icosahedron.

mbaitoff
  • 8,831
  • 4
  • 24
  • 32
  • Thank you mbaitoff. What do you mean with there is a mapping between a cubemap and an icosahedron? I know there is no distortion free mapping possible, but nevertheless an approach would be interessting. – Stephan Jan 15 '11 at 16:39
  • it's like putting the sphere in a cube and then blowing each point on the sphere in the direction of the normal onto the cube, this way you'll get a gnomonic projection on the 6 faces of the cube which you put into a texture image. It's also explained in the link I posted. – wich Jan 15 '11 at 16:44
  • Yes, there is a limited-distortion mapping between the cube and the sphere. It has been implemented in OpenGL as extension, then as ARB, then as a standard (GL_TEXTURE_CUBE_MAP). – mbaitoff Jan 15 '11 at 16:59
1

I realize this question is old, but since nobody mentioned the following solution, I thought I'd reply.

Two possible solutions:

  1. When constructing the mesh, detect if a triangle sits on the seam. If so, adjust the texture coordinates by using x + 1 for each vertex on the far side of the seam. Set your texture to wrap horizontally and you will get rid of the seam, at least for most of your polygons.
  2. Even better: calculate the texture coordinate in your fragment shader, based on the surface normal. This will get rid of the seam completely.
Paul Houx
  • 1,984
  • 1
  • 14
  • 16