Sphere mapping is used to get a cheap reflection effect, and the texture you use should be an image of the surrounding environment as seen from the reflecting object. Was that what you wanted? Here’s a link on environment mapping .
Endash, that looks good to me, buts its always a little hard to tell with sphere maps. heres a great little derivation of the texture coords you might find interesting: http://www.cs.unc.edu/~hoff/techrep/spheremap.html
Thanks for noticing the broken link. I made the usual HTML-link (<a href=… ), and forgot to remove href= when I remembered the board had it’s own tags. Link fixed now.
hey Bob, could have happened to anybody by the way, your link made it into my library. sgi’s got some kick-ass docs. i like that version much better than the one i had.
topic:
you know, whenever i debug cube maps, i always use a texture with text in it, like a letter in the middle of each face. that way i know exactly what it should like like, and how it should be oriented. much easier to see than gradients or lines. for a sphere map, maybe just a big “G” in the middle, some letter thats not symmetric in the x or y.
OK, I looked over the derrivations a bit, but I’m still getting odd results. As <bonehead> suggested, I was using a non-uniform texture so I could see what how the texture coordinates were being mapped, but if you look at the two screenshots, something seems wrong.
The topmost point on the sphere is gray, corresponding to (0.5, 0); it should be (0.5,1), right?
Similarly, the rightmost is black, corresponding to x = 0; shouldn’t it be (1, 0.5) there?
Am I wrong that sphere-mapping a sphere should draw the texture undistorted?
I figured it out. I had modified the texture example program from the red book. It uses glOrtho. My camera position was in the middle of that sphere, as far as the spehere mapping was concerned, even though geometrically I was outside of the sphere. glTranslate(0,0,theNearClipPlane) solved it.