TileRenderer Buggy lines

I find it hard to explain so here is an image to describe what i mean

I’d thought you’d figured this out by now, but it’s really hard to check someone else’s code without their code.

Put in the tile rendering code (if it’s long use the pastebin) please.

I have researched this many times but it is a graphical bug not a code one…

This is because you need to add a padding to your tiles.

This is a pretty common problem and you are not the first to encounter it. Basically due to rounding errors when scaling and panning around, sometimes you will render the area "between" two tiles, which will result in nothing being rendered -> black background colour comes through.

You basically need to use some tools to add the padding to your tileset. In this forum thread I explained how to do it.

There is also one more questions regarding this topic on stackoverflow here.

but I have no idea how to do that… padding? When looking through other peoples code I dont see anything different then i am doing…

I don’t use the Tiled program to make maps but I think a tileset is actually a file of all the sprites and some extra data. I think the tileset itself has to be modified for padding.

Hmm neither do I but I am having the exact same problem

Are you using atlases in some form for your tiles? If so, if you have direct access to the atlas image/texture, maybe you could post the image. If the atlases are created procedurally using some tool or using the LibGDX API, you could instead post the relevant settings or code. (Basically, just tell us as much as you can about how the tile textures are being created/manipulated.)

I am using a Spritesheet which i created myself

I don’t use Tiled anymore, but by padding I believe it means getting the tile drawn to correspond with the tile sheet. If your background is black, then the size of the tile may be the problem here. Have you tried comparing the brick sizes to that of the stone tiles?

As far as i know each tile is 60x60

Can you post the image? Or is it something that’s created procedurally?

The spritesheet?

Well, I’m not sure if by ‘spritesheet’ you mean an image, or a LibGDX class, or something else. If it’s an image, post that. If it’s something else, tell us what it is. Basically, just post whatever you have :slight_smile:

Its not the same file but it is very similar

When I opened it in Gimp the tiles were 16x16 (not 60x60). So firstly, do you know enough on how the tilemap loader works? Maybe the tiles need to be shifted to the right by 1. Otherwise, try a tile sheet from a t tutorial or a random one online and compare them. Another problem may be with the Tiled editor and how you configured it. Does that tilemap look like this in Tiled as well?

I am sorry the tiles in that sheet is 16 x 16 however i scale them in the game to 60 x 60 - just to make things a little bit clearer

Even small differences could matter, but that’s probably enough to go on.

Just to be thorough, one possible cause of artifacts like those in your original images would be if your tile vertex positions don’t match up exactly (which can happen if the positions are computed using inconsistent floating-point arithmetic). You can test for this by clearing the screen to some distinct color (like magenta) before rendering. If the lines are then magenta, it’s a geometry problem. If they’re still black, it’s probably a bleeding problem.

Looking at your image though, it looks like it’s probably a bleeding problem as discussed earlier. One fix is to use point sampling (‘nearest’ filtering in OpenGL terms), and make sure the texture coordinates capture the desired tiles exactly (I can’t remember off the top of my head how this works in OpenGL, but it may involve referencing the centers of the corner pixels exactly). Another option is to put padding between your tiles and fill in the pixels adjacent to the tiles with the nearest pixels from the tiles. As alluded to elsewhere, there are tools that will do this for you. (Note that you can still run into problems here when using mipmaps.)

Perhaps it should also be mentioned that another option is not to use atlases at all, which will solve the bleeding problem entirely (and allow you to use mipmaps without concern). The (or a) main reason for using atlases is to reduce the number of draw calls, but I’d say it’s not a given that a few more draw calls would be a problem. With no atlases, you might want to group visible tiles by texture before rendering to keep the number of draw calls down, which would add some overhead, but on desktop at least I doubt it would be a problem (I’m not sure what platforms you’re targeting).

Its called “bleeding” just search the forum for it