Sphere Texture Mapping Algorithm I am trying to generate UV coordinates automatically to map a texture on a sphere.

The problem is with seams when going from 0.8 to 0.2 there is a discontinuity and interpolation in fragment shader is incorrect. It should go from 0.8 to 1 and then from 1 to 0.2. But instead it will interpolate directly between 0.8 to 0.2.

https://en.wikipedia.org/wiki/UV_mapping





How to handle this discontinuity from 1 -> 0.

Here is what is currently happening at the seams
A few options:


Make the 0-1 discontinuity explicit in the mesh. That is create a 2 sets of vertices that lie exactly on the line where the value would be 1 or 0 (one set gets 1 and one gets 0) then connect the vertices up like they would makes sense.
Switch to a different texture mapping projection, I prefer a cubemap because it minimizes distortion at the poles and you don't need to have seams in the mesh.