I've been racking my brain to think of a better way to map a 2D texture to a 3D sphere.

The common mapping functions are only useful for applying a single texture to a sphere, and I am interested in applying 'detail textures' which repeat several times across the geometry.
Having scoured the internet for a day and a night, it appears that nobody else is interested in doing this.
Their 'planets' must be pretty small, given that the maximum size of a single texture on today's hardware is 4096x4096 pixels !!! For a massive visualization, that won't work, it will look terrible !!

Anyway, during my investigations I thought about attempting to map a texture to high-order platonic solids such as the dodecahedron, and eventually settled on using an 'icosphere'.
Although this initially seemed like a complex problem, when I looked into how an icosphere is generated from a simple platonic solid, I noticed a feature that I can use.

To generate an icosphere, we take a regular platonic solid, discover its bounding sphere, then we subdivide it, pushing the new vertices out to rest apon the surface of the sphere, repeating this process until we're satisfied with the level of refinement.
I realized that if I could find a simple solid that was relatively easy to texture-map, the problem was simplified.

So imagine we take a 3D cube, and texture-map each of its six faces.. as long as we use an ODD number of texture repeats on each face, and providing the textures are 'truly tileable', we can repeat textures across a cube seamlessly, agreed?

So we do that, and then we turn the cube into an icosphere.
We can discover the UV texture coordinate for each new vertex through standard means.
The result is that we now have a sphere approximation which has repeating detail textures and which does not suffer from polar distortions !!

Note : this is NOT the same as cubemaps, which project LINEARLY onto the geometry, causing seams and distortion.

Someone should pay me for this.

Posted on 2008-09-12 04:12:21 by Homer