I am having the following problem when trying to match UV coordinates to a sphere

Here is the code I use to get the UV coordinates
glm::vec2 calcUV( glm::vec3 p)
{
p = glm::normalize(p);
const float PI = 3.1415926f;
float u = ((glm::atan(p.x, p.z) / PI) + 1.0f) * 0.5f;
float v = (asin(p.y) / PI) + 0.5f;
return glm::vec2(u, v);
}
The problem has been very well explained in this question https://stackoverflow.com/a/166268/2126 , although I still don't understand how to fix it. From what I read, I need to create a double pair of vertices. Does anyone know some good and effective way to do this?
source
share