enter image description here

My game is tile-based. I am getting this lines between two tiles. They don't look nice. How can i resolve this issue?

  • \$\begingroup\$ How are you drawing your tiles? \$\endgroup\$
    – DMGregory
    Jan 15, 2017 at 20:51
  • \$\begingroup\$ If you are asking about the order then that is from left-top row by row \$\endgroup\$ Jan 15, 2017 at 20:57

1 Answer 1


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.

For example: enter image description here

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .