1

In a minecraft-like game I'm making, I get white edges on my cubes:

It is much more noticeable in darker textures. The textures are being setup like this:

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

Any help?

Luis Cruz
  • 187
  • 9

1 Answers1

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.

Robert Rouhani
  • 14,512
  • 6
  • 44
  • 59