0
我的精靈是統一的精靈畫面的一部分,每個精靈都在四邊形的頂部和右側繪製有額外的像素。它們似乎來自相鄰的精靈。以下是我所定義的UV座標:UV Coords包含相鄰的Sprite
ratio = spriteCountX/spriteCountY;
UVcoords.x = (float)(index % spriteCountX)/(float)spriteCountX;
size.x = ratio/(float)spriteCountX;
UVcoords.y = (float)(index/spriteCountX)/(float)spriteCountY;
size.y = 1.0f/(float)spriteCountY;
和頂點數據:(X,Y,Z位置以及每個頂點的UV COORDS)
vertexData[] = { -size.x/2, size.y/2, 0, UVcoords.x, UVcoords.y,
-size.x/2, -size.y/2, 0, UVcoords.x, UVcoords.y + size.y,
size.x/2, -size.y/2, 0, UVcoords.x + (size.x/ratio), UVcoords.y + size.y,
size.x/2, size.y/2, 0, UVcoords.x + (size.x/ratio), UVcoords.y}
的紋理過濾器被定義爲:
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
GLES20.GL_NEAREST);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
GLES20.GL_NEAREST);
我試着加入GL_CLAMP_TO_EDGE
沒有運氣:
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
GLES20.GL_CLAMP_TO_EDGE);
這裏是我的意思的說明: