My game is tile-based. I am getting this lines between two tiles. They don't look nice. How can i resolve this issue?
1 Answer
These lines are caused by the interpolation in the texture sampler which samples texels from adjacent tiles in your tile atlas.
Both bilinear and trilinear (mipmaps) interpolation (and some rounding errors within the GPU) will cause this.
You need to add a border to your tiles consisting of N repeating pixels from your tiles on all sides & corners.
Where N is 2 to the power of (mipmap levels).
So if you want 3 mipmap levels you need to add a border of 8 pixels (1 << 3) all around your tiles in your atlas to ensure the texture sample will not sample texels from adjacent tiles.
You also need to limit the mipmap level by calling glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, max_mipmap_level);
The first level is 0, level 1 is (width/2, height/2), level 2 is (width/4, height/4), and so on.
-
4\$\begingroup\$ @Ankitsinghkushwah Don't forget to accept the answer if it solved your problem. \$\endgroup\$ Jan 15, 2017 at 22:02