Archived

This topic is now archived and is closed to further replies.

laeuchli

Sphere Texture mapping

Recommended Posts

laeuchli    338
Dear All, I''m trying to texture map a sphere. I got a equation off this site(http://astronomy.swin.edu.au/pbourke/texture/spheremap/), that as far as I can tell is correct(works out exactly the same as on the site when I do the problem). However, when I use the code, there is a ring from the top of the sphere to the bottom, and the top and bottom are blank. Here is my code: texturev = acos(sphere[i].z) / PI ; if (normal.y >= 0) textureu[i] = acos(sphere[i].x/(sin(PI*(texturev[i])))) / TWOPI; else textureu[i]= (PI + acos(sphere[i].x/(sin(PI*(texturev[i]))))) / TWOPI; Anyone see what I''m doing wrong???? Thanks, Jesse www.laeuchli.com/jesse/

Share this post


Link to post
Share on other sites
Chock    122
Well, it took me quite some time to understand that code, but as it seems to me, it splits up the sphere into two parts (the if/else part) along the textureu coordinate. This way, the texture is split in the middle. The ring seems quite normal for me, then. If I get the code right, your texture must be similar on the left side and the left half, and on the right side and the right half. If you paint a 128x256 texture and then paste a copy of it right to it, the ring should disappear. Maybe it could also work if you change the else clause to:
textureu = (TWOPI - acos(sphere[i]......
And then only make the left and the right part of your texture the same.
But as what you said about the top and the bottom. What does your texture look like? The algorithm uses the _whole_ texture space for texturing. Dont just draw a sphere in your texture, you must fill the whole texture.

Share this post


Link to post
Share on other sites