c++opengl-esmappingtexturespolyhedra

OpenGL Icosahedron Texture Mapping


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.


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