spheres without glu

Started by
14 comments, last by TheMatrixXXX 21 years, 10 months ago
check out www.spheregames.com
in the skydome tut they describe how to calculate the sphere texture coords.
maybe it help


--=[[TheMatrixXXX]]=--
Advertisement
quote:Original post by TheMatrixXXX
check out www.spheregames.com
in the skydome tut they describe how to calculate the sphere texture coords.
maybe it help


I''ve tried that, that''s actually the tutorial that I started with originally.. When implementing the texture mapping using their routines, the texture looks all funky and has Squares of textures... Hard to explain w/o showing you, but either way, it doesn''t match the way these sphere are being generated or something cause it looks really bad.


Did you try using spherical texture mapping on the mesh to generate coordinates? Note that if you are making a unit sphere, then the normal at each vertex is exactly equal to the vertex itself.
quote:Original post by invective
Did you try using spherical texture mapping on the mesh to generate coordinates? Note that if you are making a unit sphere, then the normal at each vertex is exactly equal to the vertex itself.


I believe I''m doing it correctly... I''ve tried both sources of sphere mapping I could find..


  // Create our texture mapping coordinatesp->u = (float)(atan2( p->x, p->z ) / (PI * 2)) + 0.5f;p->v = (float)(asinf( p->y ) / PI) + 0.5f;-and this way-// Create our texture mapping coordinatesp->u = (asinf( p->x ) / PI) + 0.5f;p->v = (asinf( p->y ) / PI) + 0.5f;  


And I end up with pretty much the same thing either way, which looks like this

NOTE: The squares on the side of the sphere...
I posted my version in this thread. It uses recursion to tesselate an octohedron(?). Probably not as fast as the other functions, but very understandable =) It''s also useful for normal triangle tesselation too(just take out the calls to normalize).
I replyed earlier to a similar post you can actully have openGL generate the Texture cordinates for you automaticlly not sure on a ny performance hit this is how i do it if you look up the OpenGL red book it will detail all the options for the comands but this is how i do it

Sphere is my quadric object
texture5[0] is my texture and it''s assocaited filter

gluQuadricOrientation (Sphere,GLU_OUTSIDE);
gluQuadricTexture (Sphere,GL_TRUE);
glBindTexture(GL_TEXTURE_2D, texture5[0]);
glTexGenf(GL_S, GL_OBJECT_PLANE, GL_OBJECT_LINEAR );
glTexGenf(GL_T, GL_OBJECT_PLANE, GL_OBJECT_LINEAR );

this is used to wrapp one large texture around a huge sphere you do get some deformation at the poles of the sphere

This topic is closed to new replies.

Advertisement