Sign in to follow this  
jujumbura

Texture mapping a sphere

Recommended Posts

Top 'O the mornin to all. I've been going through lots of tutorials which set up 3D Geometric models as C++ classes, and I decided to do a sphere from pseudocode myself. My sphere looks pretty good, but there's one problem: when I texture map it, there's a narrow, vertical strip where the texture repeats itself. I know I've heard about this problem before in one of my readings about mapping on spheres. My guess is that it comes from the fact that when I get to the last vertex in a row, the TU coordinate is 1.0, and the beginning vertex's TU coordinate is 0.0. Since I draw polygons from the last vertex to the first vertex in the rows to complete the circles, the texture is probably mapping from 1.0 to 0.0 on that polygon, and just interpolating backwards over the bitmap. So anyway. The only way I can think of to fix this problem is to add an additional column of vertices which have the same position/normal values as the FIRST column of vertices. Then I use that to connect the last polygons in a row, which should look the same but not result in that backwards little texture strip, because the vertices with TU of 1.0 and 0.0 are only getting used once. But is there way to do this without adding the extra column? For some odd reason I thought I remembered seeing an example which mentioned some kind of way you could modify the texture coordinates so that you didn't have to insert that dupliate column. Maybe I'm wrong though. In any case, adding a column won't be terribly hard, it just makes the indexing a bit more of a pain. Any known suggestions? Thanks much! Mike [Edited by - Michael Kron on August 30, 2005 1:44:18 PM]

Share this post


Link to post
Share on other sites
Will you post images of the rendered sphere and the texture?

It will make figuring out the problem much easier.

Share this post


Link to post
Share on other sites
Yes your guess is correct, and there's no smart way to change the texture coordinates on the fly. Even if you tried to change them in a vertex shader there would be no way that the vertex shader would know if this was the beginning or the end since each vertex is independant.

SO your solution is the correct one - add an extra row of identical vertices. Make sure you COPY the values rather than recalculate them. I've seen cases where floating point errors mean slightly different vertex points because sin(0) and sin(360) are not quite the same.

Share this post


Link to post
Share on other sites
Oh really? Shnaps! I just rotated an extra dTheta around the sphere axis, I was hoping making a point at 2PI would be identical to one at 0.

What does the rounding error do exactly? Gaps between the first and last polygon or something? It looks fine to me after applying that fix, but then I guess I haven't gotten *really* up close to it.

Mike

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this