I’m currently trying to render a sky dome. The sphere is created using gluSphere and inside a vertex shader I extract the spherical coordinates from each vertex. I then map both sphere coordinates theta and phi to the range [0,1], just like normal texture coordinates. Currently, the fragment shader only considers phi.
As you can see, phi doesn’t seem to be mapped correctly, since the gradient appears two times, implying that phi is reset after pi revolutions.
I calculate theta and phi in the VS like this:
theta = acos(gl_Vertex.y/radius)/(pi);
phi = (atan(gl_Vertex.x/gl_Vertex.z)+pi)/(2*pi);
The color in the FS is simply:
gl_FragData[0].rgb = vec3(phi, phi, phi);

Nevermind, I was using atan(float x), instead of atan(float x, float y) which essentially is atan2.