Parts of my tile source are clipping into the others

here is a video I recorded to show the problem:

it looks like at certain locations some tiles are bleeding into the tiles above them.

I thought this might have to do with the fact that I scaled all my game objects up 2x, but I scaled them back down and the problem remained

here is the tile source:

1 Like

On the tilesource for you level tiles, make sure extrude borders is set to at least 2.

2 Likes

Thank you, that worked. What does extrude borders do and why should it be at at least 2?

1 Like

I guess you have linear filtering on, which is the default sampling method in Defold. When the pixel shader wants to fetch a sample from your texture, the graphics driver (OpenGL in this case) will calculate a color value depending on what settings you have configured for that texture sampler. If the case of “linear” filtering, you will get a weighted value from on a 2x2 pixel grid in the texture and when you are using “nearest” filtering you will get whatever color value is closest to the pixel you are fetching .

Why is this relevant? Well, linear filtering will give you an averaged or weighted color value from a small region of the texture so what happens when you sample at the edges of one image in the texture atlas? You might get color values from disparate images in the atlas, which you don’t want (this is called bleeding). Normally, if you only had one texture, you would tell OpenGL to replicate the color value that’s just right at the border when you try to sample outside of the texture, but now since we are sampling within the texture atlas you have to do that in some other way. So that’s why things like padding and extrusion exists for texture atlases - it’s basically a way to avoid the bleeding that comes from textures that are side-by-side.

Now, I think you should be fine with setting just a 1 in that field unless you have set the sampler to use mipmapping, which adds another dimension to filtering and can introduce more tricky situations if you aren’t careful :slight_smile:

Also, you can force Defold to use “nearest” filtering as a standard filtering method for all textures, which is probably what you want for a pixel-art game:

This option is available in the game.project file under “Graphcis”. Good luck!

12 Likes