GL_SPHERE_MAP problems

Apologies for cross-posting. The beginner list didn’t have much to say.

I think I must be doing something wrong. I’m trying to use GL_SPHERE_MAP but keep getting what I think are odd results.

To see what’s going on, I’m using this simple rainbow texture:

And mapping it onto a glut solid sphere, I get this:

My sense is that sphere-mapping a sphere is essentially an identity function – that I should see the texture itself.

I’m pretty sure I’m doing things right:



I’ve tried using GL_NORMALIZE and not, and using GL_AUTO_NORMALIZE and not. I’ve played with the teapot and various other GLUT objects.

I think something is wrong with my normals. When I manually make a cylinder with a unit outward normal, I get what I expect, but the glu and glut objects all seem broken, What’s more, if I cull the front faces of the glut objects, the back faces look right, or at least like the front faces should.

What could be wrong?

It looks like nobody has an answer. Let me ask an easier question: Does that sphere-mapped sphere look wrong, given the texture map? Shouldn’t it look exactly like the circle at the middle of the texture?

i don’t know if I’m helping you with this.
But the problem of sphere mapping is that it does only look good from certain viewpoints. On other sides of the sphere, it doesn’t look good, because of deformations of the texture. That is because you’re putting a square texture on a sphere and parts of it are squeezed together.
the solution may be cube environment mapping. But i can’t help you with that, because i’m also still on figuring that out.


Raoulduke, thanks for the reply. I don’t think that’s the problem. The sphere looks the same from every direction.

this page discusses the problem you mention, but it also shows an example of a sphere map and that sphere map mapped onto a sphere With the exception of the edge artifacts it describes, the two look the same. In the two images I posted, the texture is being distorted as it is sphere-mapped onto the sphere. This shouldn’t happen, right? Sphere mapping a sphere should be an identiy mapping, so to speak, right?

The problem is most like you have not enable normal array when rendering the sphere.

Here’s the actual drawing code. I do call gluQuadricNormals(), so I think normals should be generated. At this point sphere mapping is enabled in S and T, texture mapping is enabled, and the texture is bound:

GLUquadricObj * theQuadric = gluNewQuadric();
gluQuadricNormals(theQuadric, GLU_SMOOTH);
gluSphere(theQuadric, 1, 30, 30);

I also tried glutSolidSphere(), which seemed to give the same results. The teapot looked a bit better, but I think that’s just because the surface is more compicated; it still looked wrong when I thought about it.

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.