Seam issue when mapping a texture to a sphere in OpenGL

前端 未结 6 1934
清歌不尽
清歌不尽 2020-12-25 08:51

I\'m trying to create geometry to represent the Earth in OpenGL. I have what\'s more or less a sphere (closer to the elliptical geoid that Earth is though). I map a texture

6条回答
  •  攒了一身酷
    2020-12-25 09:48

    The general way this is handled is by using a cube map, not a 2D texture.

    However, if you insist on using a 2D texture, you have to create a break in your mesh's topology. The reason you get that longitudinal line is because you have one vertex with a texture coordinate of something like 0.9 or so, and its neighboring vertex has a texture coordinate of 0.0. What you really want is that the 0.9 one neighbors a 1.0 texture coordinate.

    Doing this means replicating the position down one line of the sphere. So you have the same position used twice in your data. One is attached to a texture coordinate of 1.0 and neighbors a texture coordinate of 0.9. The other has a texture coordinate of 0.0, and neighbors a vertex with 0.1.

    Topologically, you need to take a longitudinal slice down your sphere.

提交回复
热议问题