LWJGL/OpenGL 为什么我贴图到半球体或球体时,贴图的边缘有点?

LWJGL/OpenGL Why are there dots on the edge of my texture when i map it onto half-sphere or sphere?

是什么导致这些点(在某些情况下是一条线,取决于摄像机角度)出现在我映射到半球体或球体上的纹理边缘?当我在半圆柱体上映射相同的纹理时,它工作正常,没有点(线)。

这是它的样子:


这是我设置纹理参数的方式:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

我是这样画半球的:

float x, y, z;
float s, t;
double alpha1, alpha2, beta;

for(double j = 0; j < gradation; j++) {
    alpha1 = j/gradation * Math.PI;
    alpha2 = (j+1)/gradation * Math.PI;
    for(double i = 0; i <= gradation; i++) {
        beta = i/gradation * Math.PI;

        z = (float) (Math.sin(alpha1)*Math.cos(beta));
        x = (float) (Math.sin(alpha1)*Math.sin(beta));
        y = (float) Math.cos(alpha1);

        s = (float) (beta / Math.PI);
        t = (float) (alpha1 / Math.PI);

        posCoords[3*newVertexIndex] = x*radius;
        posCoords[3*newVertexIndex + 1] = y*radius;
        posCoords[3*newVertexIndex + 2] = z*radius;
        texCoords[2*newVertexIndex] = s;
        texCoords[2*newVertexIndex + 1] = t;
        indices[vertexCounter++] = newVertexIndex++;

        z = (float) (Math.sin(alpha2)*Math.cos(beta));
        x = (float) (Math.sin(alpha2)*Math.sin(beta));
        y = (float) Math.cos(alpha2);

        t = (float) (alpha2 / Math.PI);

        posCoords[3*newVertexIndex] = x*radius;
        posCoords[3*newVertexIndex + 1] = y*radius;
        posCoords[3*newVertexIndex + 2] = z*radius;
        texCoords[2*newVertexIndex] = s;
        texCoords[2*newVertexIndex + 1] = t;
        indices[vertexCounter++] = newVertexIndex++;
    }
}

我终于设法解决了这个问题。问题是我使用单个 GL_TRIANGLE_STRIP 来绘制我的半球体,如果共享顶点具有不同的纹理坐标则无法使用,在这种情况下您需要使用 GL_TRIANGLES。我是在这个 site.

上发现的