Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top