1

私が作成しているMinecraftのようなゲームでは、立方体に白いエッジが表示されます。

暗いテクスチャではるかに目立ちます。テクスチャは次のように設定されています。

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

何か助けはありますか?

4

1 に答える 1

2

If you're using nearest-neighbor filtering (glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST), this is the result of that. Because of the way vertices are transformed, sometimes this results in a texture lookup one pixel outside of the tile you want.

The solution is fairly simple, just take all your texture coordinates and move them into the tile by the size of half a pixel, i. e. (1.0f / width) * 0.5f. This guarantees that a pixel's nearest neighbor on the texture is never outside the tile you want it to be.

于 2012-12-19T00:50:10.357 に答える