To complement Rahul's answer, there is a third, more involved option (although I would definitely opt for simply increasing the number of polygons) : you mentioned that you are using a shader - and I'll assume you're talking about a pixel shader. The issue arises because the texture coordinates are linearly interpolated inside the triangles in the pixel shader : but since you know that you are dealing with spheres, it becomes possible to manually compute the UV coordinates per pixel in the pixel shader (use the standard acos(z) and atan(y/x) formula with the (x,y,z) point being the current point rasterized in the object coordinate).
Using that, even if you use a very coarsely tesselated sphere, your should still be able to get relatively smooth textures.
EDIT: although I don't have a snippet at hand, here is a pseudo code:
Vertex shader:
- take the initial coordinates of the current vertex (without any matrix transform ; I'll assume that your sphere vertices are centered around the origin) and pass them directly to the pixel shader as a varying vec3 P
.
Pixel shader:
- r = sqrt(P.x*P.x + P.y*P.y + P.z*P.z)
- theta = acos(P.z/r)
- phi = atan2(P.y/r, P.x/r)
- u = theta*2/pi ; v = phi/(2*pi)+0.5
- use the (u,v) above to sample your texture in the tex2D()
You'll need to make sure that these uv coordinates indeed correspond to how your texture has been generated, but if so, you should get an almost distortion free mapping.