Skip to main content
GameDev.net gamedev.net
🔒 Locked

Spherical texture mapping

Started by irreversible Aug 29, 2008 at 12:10 AM 2 replies 2.5k views
Original Post
irreversible
irreversible
I need to apply tiled textures to a spherical object and each of the methods I've tried either converges or leaves a "stretched" region at the equator along one of the axes. I've tried three different methods, which are: (1) u = x / sqrt(x*x + y*y + z*z); v = y / sqrt(x*x + y*y + z*z); This is from Wikipedia. (2) v = arccos(z/r) / pi u = ( arccos(x/(r sin(v pi))) ) / (2 pi) This is from Paul Bourke's page. (3) tu = asin(Nx)/PI + 0.5 tv = asin(Ny)/PI + 0.5 This is from this page. As far as I can see (1) and (3) should not work as these doen't incorporate the z axis. However, I'm not sure why I can see definite convergence using method (2). In fact, aren't these cylindrical texture mapping methods instead? PS - my source data is sphere normals (as in normalized vectors from the center of the sphere), which should be the source data for each of the three methods. Any ideas/comments? :P
calav3ra
calav3ra
the whole thing depends how you set up your vertices.
normal sphere, geo sphere (icosahedron stuff)
you need 2:1 textures for (2)
(2) should work.
look at his code, the formula and glNormal3f(e.x, ...)

i'll look into it next weekend, too

irreversible
irreversible
Heya,

much more likely the problem is that I'm using unwarped textures. Now that I think about it... :P

On the technical side, I'm using geospherical vertex calculation - I get my vertex positions by bisecting the faces on the icosahedron and I'm simply normalizing these to get the normals. I'm then running Bourke's conversion method to convert these to spherical coordinates directly. Which is wrong because I should be using cube mapping in the first place xD.

Silly me.

But thanks for the reply, dude! :)
irreversible
irreversible
Update: incidentally, this is what I went for - linky to continuous cube maps. It seems to work pretty decently, save for the fact that it could be less of a resource whore. Quality, especially at rough detail levels, still suffers quite visibly.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.