OpenGL UV mapping for a sphere (having a seam)

I am having the following problem when trying to match UV coordinates to a sphere enter image description here

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?

+4
source share
2 answers

, "" 0, , . , GL_WRAP >= 1 ( 0). , , , "" .

+2

- "" .

, , .

, . , u = 0, . , : , .

+1

All Articles